Skip to content

Commit

Permalink
Fix types for exports (#542, #543, #545) (#549)
Browse files Browse the repository at this point in the history
### Summary & motivation

Two fixes here:
1. Types for ES modules need to be specified on a per-module basis, as suggested in microsoft/TypeScript#52363 (comment)
1. A separate path reference fix for the `pure` module

### Testing & documentation

I tested this against packages which were compiled in webpack/vite with `"moduleResolution": "node16"` and `"moduleResolution": "bundler"` in `tsconfig.json`. I confirmed this fix works fore TypeScript 4+.
  • Loading branch information
fruchtose-stripe authored Feb 13, 2024
1 parent da83d87 commit 9c24a64
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
20 changes: 16 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,24 @@
"module": "dist/stripe.mjs",
"exports": {
".": {
"import": "./dist/stripe.mjs",
"default": "./dist/stripe.js"
"import": {
"types": "./types/index.d.ts",
"default": "./dist/stripe.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/stripe.js"
}
},
"./pure": {
"import": "./dist/pure.mjs",
"default": "./dist/pure.js"
"import": {
"types": "./types/pure.d.ts",
"default": "./dist/pure.mjs"
},
"require": {
"types": "./dist/pure.d.ts",
"default": "./dist/pure.js"
}
}
},
"jsnext:main": "dist/stripe.mjs",
Expand Down
2 changes: 1 addition & 1 deletion types/pure.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
///<reference path='./types/index.d.ts' />
///<reference path='./index.d.ts' />

export const loadStripe: typeof import('@stripe/stripe-js').loadStripe & {
setLoadParameters: (params: {advancedFraudSignals: boolean}) => void;
Expand Down

0 comments on commit 9c24a64

Please sign in to comment.