Skip to content

Commit

Permalink
Add --generate-types option (developit#589)
Browse files Browse the repository at this point in the history
  • Loading branch information
developit committed Dec 18, 2020
1 parent fdafaf7 commit 25b2b62
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ function createConfig(options, entry, format, writeMeta) {
: () => resolve(options.cwd, 'mangle.json');

const useTypescript = extname(entry) === '.ts' || extname(entry) === '.tsx';
const emitDeclaration = !!(options.generateTypes || pkg.types || pkg.typings);

const escapeStringExternals = ext =>
ext instanceof RegExp ? ext.source : escapeStringRegexp(ext);
Expand Down Expand Up @@ -476,7 +477,7 @@ function createConfig(options, entry, format, writeMeta) {
map: null,
}),
},
useTypescript &&
(useTypescript || emitDeclaration) &&
typescript({
typescript: require(resolveFrom.silent(
options.cwd,
Expand All @@ -488,6 +489,8 @@ function createConfig(options, entry, format, writeMeta) {
compilerOptions: {
sourceMap: options.sourcemap,
declaration: true,
allowJs: true,
emitDeclarationOnly: options.generateTypes && !useTypescript,
declarationDir: getDeclarationDir({ options, pkg }),
jsx: 'preserve',
jsxFactory:
Expand Down

0 comments on commit 25b2b62

Please sign in to comment.