From 1dba15f03b47ffeb028c529d7b8a42508a90cefc Mon Sep 17 00:00:00 2001 From: Eric Fennis Date: Mon, 5 Apr 2021 16:48:25 +0200 Subject: [PATCH] Fix bugs in types --- packages/lucide/scripts/buildTypes.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/lucide/scripts/buildTypes.js b/packages/lucide/scripts/buildTypes.js index 9dfc4f0..04b954e 100644 --- a/packages/lucide/scripts/buildTypes.js +++ b/packages/lucide/scripts/buildTypes.js @@ -2,14 +2,15 @@ import path from 'path'; import { readSvgDirectory, resetFile, appendFile, toPascalCase } from '../../../scripts/helpers'; +import defaultAttributes from '../src/defaultAttributes'; + const TARGET_DIR = path.join(__dirname, '../dist'); const ICONS_DIR = path.resolve(__dirname, '../../../icons'); const TYPES_FILE_NAME = 'lucide.d.ts'; -import defaultAttributes from '../src/defaultAttributes'; - // Generates header of d.ts file include some types and functions const typeDefinitions = `\ +declare module 'lucide' export interface SVGProps extends Partial ${JSON.stringify(defaultAttributes, null, 2)} export declare type IconNode = readonly [tag: string, attrs:SVGProps, children?:IconNode]; @@ -19,16 +20,16 @@ export type Icons = { [key: string]: IconNode } export interface CreateIconsOptions { /** * List of icons you want to replace - * + * * For example: \`{ Menu, Circle}\`. - * + * * For replace all icons in lucide library, import \`icons\` and use it. */ icons: Icons; /** * Search HTML emelemt by \`nameAttr\` property. - * + * * For example if define \`\`, fill by \`lucide-icon\`. * * @default 'icon-name' @@ -60,7 +61,7 @@ svgFiles.forEach(svgFile => { const nameSvg = path.basename(svgFile, '.svg'); const namePascal = toPascalCase(nameSvg); - appendFile(`export declare const ${namePascal}: IconData;\n`, TYPES_FILE_NAME, TARGET_DIR); + appendFile(`export declare const ${namePascal}: IconNode;\n`, TYPES_FILE_NAME, TARGET_DIR); }); console.log(`Generated ${TYPES_FILE_NAME} file with`, svgFiles.length, 'icons');