Skip to content

Commit

Permalink
feat: Expands generateTypes flag to support TS entries (#865)
Browse files Browse the repository at this point in the history
* feat: Expands generateTypes flag to support TS entries

* fix: Returning previous .d.ts generation

* test: Modifying `--generateTypes false` test for use on TS projects

* docs: Adding changeset
  • Loading branch information
rschristian authored Oct 6, 2021
1 parent 76272fd commit 2980336
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/slimy-roses-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'microbundle': patch
---

Expands generateTypes flag to support libs with TS entrypoints
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,12 @@ function createConfig(options, entry, format, writeMeta) {
tsconfigDefaults: {
compilerOptions: {
sourceMap: options.sourcemap,
declaration: true,
declaration: options.generateTypes !== false,
allowJs: true,
emitDeclarationOnly: options.generateTypes && !useTypescript,
declarationDir: getDeclarationDir({ options, pkg }),
...(options.generateTypes !== false && {
declarationDir: getDeclarationDir({ options, pkg }),
}),
jsx: 'preserve',
jsxFactory:
// TypeScript fails to resolve Fragments when jsxFactory
Expand Down
3 changes: 2 additions & 1 deletion test/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2730,9 +2730,10 @@ ts-custom-declaration
index.js.map
index.umd.js
index.umd.js.map
node_modules
package.json
src
index.js
index.ts
tsconfig.json
types
index.d.ts
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/ts-custom-declaration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ts-custom-declarations",
"main": "dist/index.js",
"types": "types/index.d.ts",
"source": "src/index.js",
"source": "src/index.ts",
"scripts": {
"build": "microbundle --generateTypes false"
}
Expand Down

0 comments on commit 2980336

Please sign in to comment.