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

fix: add typings to package.json export #2

Merged
merged 1 commit into from Aug 2, 2023

Conversation

kouloumos
Copy link
Contributor

When importing the package in a project made with Vite, I get the following error:

Could not find a declaration file for module '@nostr-dev-kit/ndk-react'. '/my-dir/node_modules/@nostr-dev-kit/ndk-react/dist/ndk-react.es.js' implicitly has an 'any' type.
  There are types at '/my-dir/node_modules/@nostr-dev-kit/ndk-react/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@nostr-dev-kit/ndk-react' library may need to update its package.json or typings.ts(7016)

This seems to be a known issue when using moduleResolution: "bundler" via Vite. You can see the related discussion in microsoft/TypeScript#52363 as well as the same fix applied to other projects [1, 2].

This PR adds the missing type specification in exports of package.json.

Steps to reproduce

  1. Create a new vite-react-app using npx vite@latest .
  2. Install the @nostr-dev-kit/ndk-react package and import it somewhere it in the application.
  3. Confirm that the types are not able to load.

fixes the issue of not be able to load definition files when using
`moduleResolution: "bundler"` via Vite
@jinglescode jinglescode merged commit 7bf762a into nostr-dev-kit:main Aug 2, 2023
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