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

Make TypeScript consumption easier #101

Open
samestep opened this issue Sep 18, 2023 · 0 comments
Open

Make TypeScript consumption easier #101

samestep opened this issue Sep 18, 2023 · 0 comments

Comments

@samestep
Copy link
Contributor

Currently the npm package doesn't show the "TS" icon to indicate that it has type definitions, despite having them; judging from this Stack Overflow thread, this seems to be caused by our package.json files not having a "types" field. If you install Rose in a fresh project and try to import it, TypeScript gives this error:

Cannot find module 'rose' or its corresponding type declarations.

As described in the top answer of that Stack Overflow thread, you can resolve this error on the client side via this tsconfig.json:

{ "compilerOptions": { "moduleResolution": "Node16" } }

However, we should probably configure Rose itself to work properly with TypeScript even for users who don't know or don't care to use the more modern module resolution, probably by just setting "types".

Incidentally, if you just use the above in tsconfig.json, TypeScript also complains, due to a recent change in TypeScript 5.2:

Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'.

The error can be resolved via this tsconfig.json:

{ "compilerOptions": { "module": "Node16", "moduleResolution": "Node16" } }

We have the same error in our own tsconfig.json files in this repository; it would probably be a good idea to fix those errors, but I don't immediately know how to do that because I don't know what "module": "Node16" actually means as contrasted with "module": "ES2022".

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

1 participant