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" to package.json exports to fix module type resolution #264

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

trevorsmith
Copy link

This commit fixes the following Typescript error:

Could not find a declaration file for module 'urlcat'. 'foo/node_modules/urlcat/dist/index.mjs' implicitly has an 'any' type.
There are types at 'foo/urlcat/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'urlcat' library may need to update its package.json or typings.

Copy link

@Jack-Works Jack-Works left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change is wrong.

    ".": {
      "import": { "types": "./dist/index.d.ts", "default": "./dist/index.mjs" },
      "require": { "types": "./dist/index.d.ts", "default": "./dist/index.js" }
    }

this is correct (not strictly, but reasonably correct). you may want to know more about how the ordering is important, and how "types" in "exports" actually work.

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