From 3df75357b2d40f71a447c57a5cd74017a26c704d Mon Sep 17 00:00:00 2001 From: Thomas Digby Date: Wed, 25 Mar 2026 17:20:06 +0000 Subject: [PATCH] fix: output types --- package.json | 1 + scripts/build-export.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/package.json b/package.json index 9da87f8..7970fb3 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "@atom-learning/icons", "main": "dist/index.cjs.js", "module": "dist/index.js", + "types": "dist/index.d.ts", "version": "1.21.0", "description": "", "files": [ diff --git a/scripts/build-export.ts b/scripts/build-export.ts index 638015e..6b43af2 100644 --- a/scripts/build-export.ts +++ b/scripts/build-export.ts @@ -61,6 +61,19 @@ const outputESEntry = async (icons) => { await fs.writeFile(path.resolve(DIRECTORY_OUTPUT, 'index.js'), template) } +const outputTypeDeclarations = async (icons: Record) => { + for (const [name] of Object.entries(icons)) { + const componentName = changeCase.pascalCase(name) + const declaration = `import { FC, SVGProps } from 'react';\nexport declare const ${componentName}: FC>;\n` + await fs.writeFile(path.resolve(DIRECTORY_OUTPUT, `${name}.d.ts`), declaration) + } + + const indexDeclaration = Object.entries(icons) + .map(([name]) => `export * from './${name}';\n`) + .join('') + await fs.writeFile(path.resolve(DIRECTORY_OUTPUT, 'index.d.ts'), indexDeclaration) +} + const outputCJSBundle = async () => { await buildSync({ entryPoints: [path.resolve(DIRECTORY_OUTPUT, 'index.js')], @@ -137,6 +150,7 @@ const run = async () => { await fs.writeFile(path.resolve(DIRECTORY_OUTPUT, `${name}.js`), code) } + await outputTypeDeclarations(icons) await outputCJSBundle() }