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

import syntax for TypeScript compiler - perhaps add to documentation #342

Open
morrisonbrett opened this issue Jan 6, 2024 · 4 comments

Comments

@morrisonbrett
Copy link

I found that this did not work:

import { Event } from 'nostr-tools/lib/types/pure';

In order to get this to work:

import { Event } from 'nostr-tools/pure';

I had to add this to tsconfig.json:

{
  "compilerOptions": {
    "paths": {
      "nostr-tools/*": ["./node_modules/nostr-tools/lib/types/*"]
    }
}
@fiatjaf
Copy link
Collaborator

fiatjaf commented Jan 6, 2024

What version of TypeScript?

I think it should work out of the box because of the stuff we have in package.json, but I don't understand TypeScript.

Why can't you just import from nostr-tools/pure directly?

@alexgleason
Copy link
Collaborator

https://arethetypeswrong.github.io/?p=nostr-tools%402.1.2

@morrisonbrett
Copy link
Author

https://arethetypeswrong.github.io/?p=nostr-tools%402.1.2

This is a great resource. Thanks for posting.

@morrisonbrett
Copy link
Author

What version of TypeScript?

I think it should work out of the box because of the stuff we have in package.json, but I don't understand TypeScript.

Why can't you just import from nostr-tools/pure directly?

Latest version, of course. I imagine most consumers of nostr-tools are using it with Node. I'm using it in the browser in a TypeScript React project.

This can probably be fixed with an export file at the root of the project.

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

No branches or pull requests

3 participants