Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: Expands generateTypes flag to support TS entries #865

Merged
merged 4 commits into from
Oct 6, 2021

Conversation

rschristian
Copy link
Collaborator

What kind of change does this PR introduce?

Feature, expands the --generateTypes flag to also support projects with TS entry points.

Did you add tests for your changes?

Modified an existing test

Summary

Closes #863

The problem with the existing --generateTypes behavior is that it is only relevant when used with JS entry points.

emitDeclaration is derived from options.generateTypes and is only used in the following spot:

(useTypescript || emitDeclaration) &&

Which means that when useTypescript is truthy, that option holds no power whatsoever. useTypescript would be truthy on any project that had TS entry points:

const useTypescript = extname(entry) === '.ts' || extname(entry) === '.tsx';

To allow projects with TS entry points to disable types from being output, we now simply disable TS's declaration compiler option if options.generateTypes is set to false.

Does this PR introduce a breaking change?

No

@changeset-bot
Copy link

changeset-bot bot commented Jul 15, 2021

🦋 Changeset detected

Latest commit: 2677748

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
microbundle Patch

Not sure what this means? Click here to learn what changesets are.

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

@@ -2728,9 +2728,10 @@ ts-custom-declaration
index.js.map
index.umd.js
index.umd.js.map
node_modules
Copy link
Owner

@developit developit Jul 15, 2021

Choose a reason for hiding this comment

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

to fix CI

Suggested change
node_modules

Copy link
Collaborator Author

@rschristian rschristian Jul 15, 2021

Choose a reason for hiding this comment

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

Clicked "Commit suggestion" too fast there. What was not working w/ the CI? Seemed to be passing w/out any issues?

When rpt2 is used, it creates some cache files in node_modules. As this test now uses a TS entry point, rpt2 will be used.

Copy link
Owner

@developit developit left a comment

Choose a reason for hiding this comment

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

LGTM! Just the one nit about node_modules in the snapshot

@rschristian rschristian force-pushed the feat/generateTypes-ts branch from d707d35 to 2677748 Compare July 15, 2021 18:09
@developit developit merged commit 2980336 into master Oct 6, 2021
@developit developit deleted the feat/generateTypes-ts branch October 6, 2021 14:07
@preact-bot preact-bot mentioned this pull request Oct 6, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clarify the correct way to not generate types
2 participants