kristerkari/react-native-svg-transformer

Identifier 'Svg' has already been declared

thibaultcapelli opened this issue ยท 6 comments

I have this error when I upgrade to 1.1.0

  1 | import * as React from "react";
  2 | import Svg, { Path } from "react-native-svg";
> 3 | import type { SvgProps, Svg, Path } from "react-native-svg";
pehagg commented

I would encourage you to read the error message and your code again.

You can't import the same declarations twice, the typescript compiler will choke on this. Just use regular imports. Type imports are for more esoteric cases when you run into issues with transpilers. For a detailed description, see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export.

Hello @pehagg

I understand the error but the code is not mine. It provide from an SVG I import with this lib. I guess it is the transpiled code. I do not have this issue with the 1.0.0

pehagg commented

@thibaultcapelli , sorry, I missed the "when I upgrade" part. For context, have you upgraded any other libs in your project or is it this lib only?

Looks like this is a possible bug in SVGR:
gregberge/svgr#891

Looks like there is a fix for it: gregberge/svgr#894

If you run into this problem, please check that your lockfile is using the 8.1.0 or newer version for the following react-native-svg-transformer dependencies:

@svgr/core
@svgr/plugin-jsx 
@svgr/plugin-svgo