You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add "types": ["vite-plugin-svgr/client"] to compilerOptions in tsconfig.node.json
Change to "moduleResolution": "node16" in tsconfig.json.
Change all existing relative imports to include the extension to make them compatible to node16 resolution.
Add the svgr plugin to vite.config.ts.
Add a SVG import.
Run type check with tsc --noemit. There will be an error:
error TS2688: Cannot find type definition file for 'vite-plugin-svgr/client'.
The file is in the program because:
Entry point of type library 'vite-plugin-svgr/client' specified in compilerOptions
tsconfig.json:9:30
9 "types": ["vite/client", "vite-plugin-svgr/client"]
~~~~~~~~~~~~~~~~~~~~~~~~~
File is entry point of type library specified here.
For an easy fix add the following to the exports in vite-plugin-svgr package.json:
"./client": {
"types": "./client.d.ts"
}
The text was updated successfully, but these errors were encountered:
Typescript requires package exports with condition "types" for subpath imports like "vite-plugin-svgr/client" when moduleResolution node16 is enabled.
Reproduction is easy:
Create a minimal React Typescript App with Vite and add like:
Add
"types": ["vite-plugin-svgr/client"]
to compilerOptions in tsconfig.node.jsonChange to "moduleResolution": "node16" in tsconfig.json.
Change all existing relative imports to include the extension to make them compatible to node16 resolution.
Add the svgr plugin to vite.config.ts.
Add a SVG import.
Run type check with tsc --noemit. There will be an error:
For an easy fix add the following to the exports in vite-plugin-svgr package.json:
The text was updated successfully, but these errors were encountered: