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

package.json's exports mapping does not include types field #429

Closed
jeffposnick opened this issue Aug 20, 2022 · 0 comments · Fixed by #444
Closed

package.json's exports mapping does not include types field #429

jeffposnick opened this issue Aug 20, 2022 · 0 comments · Fixed by #444

Comments

@jeffposnick
Copy link

When trying to import the preact-router and preact-router/match modules from inside a project written using TypeScript 4.7+ with moduleResolution: "NodeNext", TypeScript is unable to find the corresponding type definitions.

If I manually modify node_modules/preact-router/package.json to add types fields to the preact-router and preact-router/match exports, then TypeScript will pick up the type definitions:

"exports": {
	".": {
		"module": "./dist/preact-router.mjs",
		"import": "./dist/preact-router.mjs",
		"require": "./dist/preact-router.js",
		"types": "./index.d.ts"
	},
	"./package.json": "./package.json",
	"./match": {
		"module": "./match/index.mjs",
		"import": "./match/index.mjs",
		"require": "./match/index.js",
		"types": "./match/index.d.ts"
	},
	"./match/package.json": "./match/package.json"
},

Can this module be published with the addition of those types fields in the exports section of package.json? I'm happy to file a PR to add them if that seems reasonable.

See developit/microbundle#990 for a related discussion about documenting this as part of microbundle's TypeScript guidance.

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 a pull request may close this issue.

1 participant