Skip to content

Add --generate-types option#589

Merged
marvinhagemeister merged 14 commits into
masterfrom
generate-types-option
Dec 18, 2020
Merged

Add --generate-types option#589
marvinhagemeister merged 14 commits into
masterfrom
generate-types-option

Conversation

@developit

@developit developit commented Apr 17, 2020

Copy link
Copy Markdown
Owner

This requires TS 3.7: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#--declaration-and---allowjs

One thing I wasn't sure of: maybe this could just be enabled by default? Currently I think it's possible via tsconfig.json, but doing so would potentially run TypeScript on all of node_modules.

TODO:

  • tests

@developit developit marked this pull request as ready for review May 4, 2020 15:16
@marvinhagemeister

Copy link
Copy Markdown
Collaborator

+1 on enabling it as default

@Hotell

Hotell commented May 25, 2020

Copy link
Copy Markdown

maybe this could just be enabled by default?

Absolutely (even folks not aware about typescript will ship at least some amount of definitions - happy consumers)

doing so would potentially run TypeScript on all of node_modules.

It would not: setting "skipLibCheck": true, flag will mitigate that (it's turned on by default since TS 3.9)

Comment thread src/index.js Outdated
Comment thread src/index.js Outdated
Comment thread src/index.js Outdated
: () => resolve(options.cwd, 'mangle.json');

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just checking if pkg.types || pkg.typings is present in package.json would be enough to trigger this?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love that idea! Made #631 that does enable declarations only when pkg.types || pkg.typings is present 🎉

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marvinhagemeister I copied your change into this PR 👍

@changeset-bot

changeset-bot Bot commented Dec 17, 2020

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 3472dd5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment thread src/index.js Outdated

@katywings katywings left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good ^.^

@marvinhagemeister marvinhagemeister merged commit 25b2b62 into master Dec 18, 2020
@marvinhagemeister marvinhagemeister deleted the generate-types-option branch December 18, 2020 19:17
@developit developit added this to the 0.13.0 milestone Dec 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants