Skip to content

Commit

Permalink
Add "types" condition to "exports" in package.json.
Browse files Browse the repository at this point in the history
The `package.json` has a `"types"` field which points to `./types/util.d.ts`. But it also has an `"exports"` field. The `"exports"` field, when provided, is supposed to supersede fields like `"main"` and `"browser"`. TypeScript respects this as well, and ignores the `"types"` field when `"exports"` is present.

Due to this, the latest version of TypeScript will ignore the `"types"` field, giving the following error:

> error TS7016: Could not find a declaration file for module 'node-inspect-extracted'. 'node_modules/.pnpm/[email protected]/node_modules/node-inspect-extracted/index.mjs' implicitly has an 'any' type.

It also follows up with the following message:

> There are types at 'node_modules/node-inspect-extracted/types/util.d.ts', but this result could not be resolved when respecting package.json "exports". The 'node-inspect-extracted' library may need to update its package.json or typings.

This PR resolves this issue by adding a `"types`" condition to the `"exports"` field which matches the existing top-level `"types"` field.
  • Loading branch information
simoncave authored Feb 1, 2024
1 parent f379559 commit c04970a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"module": "./index.mjs",
"browser": "./dist/inspect.js",
"exports": {
"types": "./types/util.d.ts",
"import": "./index.mjs",
"require": "./dist/inspect.js"
},
Expand Down

0 comments on commit c04970a

Please sign in to comment.