pd4d10 / vite-plugin-svgr

Vite plugin to transform SVGs into React components
MIT License
568 stars 54 forks source link

[Help] Issue pulling in svgr types. #51

Open mikeymop opened 2 years ago

mikeymop commented 2 years ago

I recently updated to module version 2.2.1 and noticed that I now have a hard-to-figure-out error in my tsconfig.json in relation to this plugin.

Interestingly, this is fine in my vite.config.ts. Is it expected to include tsconfig.json in it's own includes?

tsconfig.json

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

at

{
  "compilerOptions": {
    "target": "ESNext",
    "lib": ["dom", "dom.iterable", "esnext"],
    "types": ["vite/client", "@types/vite-plugin-svgr/client", "@types/react", "jest"],
    ...
    }
  "files": [ // is it expected to include tsconfig.json here?
    "vite.config.ts",
    "public/source-env.js",
  ],
  "include": [
    "src",
    "env/*.js",
    "src/**/*.test.ts",
  ]
}

package.json

"devDependencies": {
    "vite-plugin-svgr": "^2.2.1",
    ...
}
sni-J commented 1 year ago

@mikeymop Is this resolved? Seems like changing @types/vite-plugin-svgr/client -> vite-plugin-svgr/client in compilerOptions.types might help.