gregberge / svgr

Transform SVGs into React components 🦁
https://react-svgr.com
MIT License
10.49k stars 415 forks source link

Module '"svgo"' has no exported member 'OptimizeOptions' #825

Open kaiyoma opened 1 year ago

kaiyoma commented 1 year ago

🐛 Bug Report

When using this library and running the type checker, I get this error:

../../common/temp/node_modules/.pnpm/@svgr+core@6.5.1/node_modules/@svgr/core/dist/index.d.ts:2:10 - error TS2305: Module '"svgo"' has no exported member 'OptimizeOptions'.

2 import { OptimizeOptions } from 'svgo';
           ~~~~~~~~~~~~~~~

Found 1 error in ../../common/temp/node_modules/.pnpm/@svgr+core@6.5.1/node_modules/@svgr/core/dist/index.d.ts:2

I've tried forcing versions 2.8.0 and 3.0.2 of svgo and I get the same error in both cases. It seems that possibly @types/svgo has this OptimizeOptions type, but that package is deprecated now: https://www.npmjs.com/package/@types/svgo

Run npx envinfo --system --binaries --npmPackages @svgr/core,@svgr/cli,@svgr/webpack,@svgr/rollup --markdown --clipboard

Paste the results here:

*** Clipboard option removed - use clipboardy or clipboard-cli directly ***

## System:
 - OS: Windows 10 10.0.22621
 - CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
 - Memory: 4.04 GB / 15.71 GB
## Binaries:
 - Node: 16.19.0 - C:\Program Files\Node.js\node.EXE
 - npm: 9.2.0 - C:\Program Files\Node.js\npm.CMD
## npmPackages:
 - @svgr/webpack: 5.5.0 => 5.5.0
gregberge commented 1 year ago

@TrySound any idea?

j-m commented 1 year ago

Just ran into this, too. Looks like svgo isn't listed in the dependencies at all, and this may only work locally because you've included @types/svgo in your devDependencies. https://github.com/gregberge/svgr/blob/main/packages/core/package.json#L48

To ship the type you could duplicate the definition, or just change it to be a normal dependency

(I don't know anything about these packages so apologies if this is unrelated)

kaiyoma commented 1 year ago

I think the latest version (8.0.0) fixes all the annoying TypeScript issues I've had with this package. If you upgrade to the latest versions of @svgr/core and svgo all the type issues seem to resolve themselves.

1EDExg0ffyXfTEqdIUAYNZGnCeajIxMWd2vaQeP commented 11 months ago

I think svgo should be a normal dependency (not dev). That should also fix #904