Skip to content

Commit 6147088

Browse files
authored
Export IconComponent type (#1385)
1 parent 32a4d17 commit 6147088

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2664,7 +2664,7 @@ export interface IconProps extends BoxProps<'svg'> {
26642664
}
26652665

26662666
/* Start generated icons */
2667-
type IconComponent = React.ForwardRefExoticComponent<React.PropsWithoutRef<IconProps> & React.RefAttributes<SVGElement>>
2667+
export type IconComponent = React.ForwardRefExoticComponent<React.PropsWithoutRef<IconProps> & React.RefAttributes<SVGElement>>
26682668
export declare const AddIcon: IconComponent
26692669
export declare const AddColumnLeftIcon: IconComponent
26702670
export declare const AddColumnRightIcon: IconComponent

tools/generate-icons.js

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
#!/usr/bin/env node
22
'use strict'
33
const path = require('path')
4-
const fs = require('fs-extra')
54
const { IconSvgPaths16, IconSvgPaths20 } = require('@blueprintjs/icons')
65
const camelCase = require('camelcase')
6+
const fs = require('fs-extra')
77
const prettier = require('prettier')
88

99
const iconsPath = path.resolve(__dirname, '../src/icons/generated')
1010
const iconsIndexPath = path.resolve(__dirname, '../src/icons/index.js')
1111
const indexPath = path.resolve(__dirname, '../src/index.js')
1212
const typedefPath = path.resolve(__dirname, '../index.d.ts')
13-
const iconNamesMapperPath = path.resolve(
14-
__dirname,
15-
'../src/icons/generated/IconNameMapper.js'
16-
)
13+
const iconNamesMapperPath = path.resolve(__dirname, '../src/icons/generated/IconNameMapper.js')
1714
const fileHeader = `// This is a generated file. DO NOT modify directly.\n\n`
1815

1916
async function main() {
@@ -122,22 +119,15 @@ export const ${iconName} = memo(forwardRef(function ${iconName}(props, ref) {
122119
// update the typedefs to include icons
123120
// =====================
124121

125-
const iconTypeDefs = iconNames
126-
.map(
127-
componentName => `export declare const ${componentName}: IconComponent`
128-
)
129-
.join('\n')
122+
const iconTypeDefs = iconNames.map(componentName => `export declare const ${componentName}: IconComponent`).join('\n')
130123

131124
const iconsTypeDefs = `/* Start generated icons */
132-
type IconComponent = React.ForwardRefExoticComponent<React.PropsWithoutRef<IconProps> & React.RefAttributes<SVGElement>>
125+
export type IconComponent = React.ForwardRefExoticComponent<React.PropsWithoutRef<IconProps> & React.RefAttributes<SVGElement>>
133126
${iconTypeDefs}
134127
/* End generated icons */`
135128

136129
let typedefs = await fs.readFile(typedefPath, 'utf8')
137-
typedefs = typedefs.replace(
138-
/\/\* Start generated icons \*\/[\s\S]*?\/\* End generated icons \*\//i,
139-
iconsTypeDefs
140-
)
130+
typedefs = typedefs.replace(/\/\* Start generated icons \*\/[\s\S]*?\/\* End generated icons \*\//i, iconsTypeDefs)
141131

142132
await fs.writeFile(typedefPath, typedefs)
143133
}

0 commit comments

Comments
 (0)