From 38ab65b3dd7c1ab9d4333063703fdffd7a012ec4 Mon Sep 17 00:00:00 2001 From: Maik Marschner Date: Tue, 12 Dec 2017 19:15:24 +0100 Subject: [PATCH] Generate TypeScript definitions. Closes #5 --- generate-module.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/generate-module.js b/generate-module.js index 3e7c0ba..8cbd708 100755 --- a/generate-module.js +++ b/generate-module.js @@ -76,12 +76,19 @@ export default (props) => ${svg} presets: ['es2015', 'react', 'stage-0'], compact: process.env.NODE_ENV === 'production' }).code) + + // typescript definition + fse.writeFileSync(path.join(__dirname, 'package', `${name}.d.ts`), `export { default } from 'material-ui/SvgIcon' +`) } // es2015 module syntax const allExports = icons.map(({ name }) => `export { default as ${name} } from './${name}'`).join('\n') fse.writeFileSync(path.join(__dirname, 'package', 'index.es.js'), allExports) +// typescript index definition (looks exactly the same) +fse.writeFileSync(path.join(__dirname, 'package', 'index.d.ts'), allExports) + // commonjs module fse.writeFileSync(path.join(__dirname, 'package', 'index.js'), babel.transform(allExports, { plugins: ['transform-es2015-modules-commonjs'],