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

Add "types" condition to "exports" in package.json. #25

Merged
merged 1 commit into from
Feb 1, 2024
Merged

Add "types" condition to "exports" in package.json. #25

merged 1 commit into from
Feb 1, 2024

Conversation

simoncave
Copy link
Contributor

@simoncave simoncave commented Feb 1, 2024

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.

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.
@hildjj
Copy link
Owner

hildjj commented Feb 1, 2024

Thanks. I will bring the current code up to match the latest node version and do a release tomorrow.

@hildjj hildjj merged commit cfd913d into hildjj:main Feb 1, 2024
7 checks passed
@hildjj
Copy link
Owner

hildjj commented Feb 1, 2024

Fixed in 3.0.1

@simoncave simoncave deleted the patch-1 branch February 11, 2024 05:26
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.

2 participants