Replies: 1 comment
-
|
Style dictionary makes use of exports field in package.json to define where the type definition files can be found. This is somewhat "modern" where node module resolution won't be enough to understand it. Changing it to bundler is generally the way to do it, it usually is more supportive of modern type resolution while also giving you leniency for stuff that's specific to node moduleResolution. Usually that change shouldn't negatively impact you that much. There isn't really another way to do it afaik. nodenext module resolution is more restrictive than bundler, and recommended, but will require you to make more changes in your code. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I’m using Style Dictionary in a TypeScript project, and I’m running into an issue with type resolution.
Here’s my tsconfig.compilerOptions:
{ ... "compilerOptions": { "target": "es2024", "module": "es2022", "moduleResolution": "node" } ... }When I try to import Style Dictionary like this:
I get the following error:
I understand that changing moduleResolution to node16/nodenext/bundler would fix it, but I cannot change this setting for the whole project since it would impact other packages.
👉 My question:
What’s the recommended way to use Style Dictionary with TypeScript while keeping moduleResolution: "node" and still benefiting from type safety (without resorting to @ts-ignore)?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions