Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix types for node16/bundler module resolution strategies #553

Merged
merged 4 commits into from
Feb 15, 2024

Conversation

fruchtose-stripe
Copy link
Contributor

@fruchtose-stripe fruchtose-stripe commented Feb 15, 2024

Summary & motivation

This is a more canonical fix for types than what shipped in v3.0.1, as verified w/ this command:

yarn build && npx @arethetypeswrong/cli --pack .

This fix took a couple days because the combination of quirks in our codebase, quirks in TypeScript, and quirks in available tooling made it difficult to ascertain a fix. Historically, we have shipped types from a ./types directory with corresponding entrypoint definition files. And since we shipped multiple .d.ts files, we essentially shipped our types as written. This approach is not compatible with .d.mts files, since these are not apparently resolved by any TypeScript tooling. As a result, it took some time to find a way to ship a single .d.mts definition file for ES modules.

The rollup-plugin-dts Rollup plugin turned out to be the best option after trial and error. It requires minimal changes. As a result of this change, both .d.ts and .d.mts declarations are now shipped as single files. However, this is not a breaking change because we have allowed the use of barrel exports from the main TypeScript modules.

As a result of this change, we now ship compliant types for node16 CJS, node16 ESM, and bundler resolution configurations. node10 support is included for the main @stripe/stripe-js module. Support for @stripe/stripe-js/pure is not included in this fix.

@fruchtose-stripe fruchtose-stripe changed the title Fix types for node16 imports Fix types for node16/bundler module resolution strategies Feb 15, 2024
@fruchtose-stripe fruchtose-stripe changed the title Fix types for node16/bundler module resolution strategies Fix types for node16/bundler module resolution strategies in TypeScript Feb 15, 2024
@fruchtose-stripe fruchtose-stripe changed the title Fix types for node16/bundler module resolution strategies in TypeScript Fix types for node16/bundler module resolution strategies Feb 15, 2024
@fruchtose-stripe fruchtose-stripe merged commit 9d3c711 into master Feb 15, 2024
2 checks passed
@fruchtose-stripe fruchtose-stripe deleted the fruchtose/dts branch February 15, 2024 22:58
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.

None yet

2 participants