diff --git a/packages/babel-plugin-transform-svg-component/src/__snapshots__/index.test.ts.snap b/packages/babel-plugin-transform-svg-component/src/__snapshots__/index.test.ts.snap index 29057829..38b4beb9 100644 --- a/packages/babel-plugin-transform-svg-component/src/__snapshots__/index.test.ts.snap +++ b/packages/babel-plugin-transform-svg-component/src/__snapshots__/index.test.ts.snap @@ -395,7 +395,7 @@ exports[`plugin typescript with "native", "ref" and "expandProps" option adds im import Svg from "react-native-svg"; import type { SvgProps } from "react-native-svg"; import { Ref, forwardRef } from "react"; -const SvgComponent = (props: SvgProps, ref: Ref) => ; +const SvgComponent = (props: SvgProps, ref: Ref) => ; const ForwardRef = forwardRef(SvgComponent); export default ForwardRef;" `; @@ -404,7 +404,7 @@ exports[`plugin typescript with "native", "ref" option adds import from "react-n "import * as React from "react"; import Svg from "react-native-svg"; import { Ref, forwardRef } from "react"; -const SvgComponent = (_, ref: Ref) => ; +const SvgComponent = (_, ref: Ref) => ; const ForwardRef = forwardRef(SvgComponent); export default ForwardRef;" `; diff --git a/packages/babel-plugin-transform-svg-component/src/variables.ts b/packages/babel-plugin-transform-svg-component/src/variables.ts index 90129701..dae6cafc 100644 --- a/packages/babel-plugin-transform-svg-component/src/variables.ts +++ b/packages/babel-plugin-transform-svg-component/src/variables.ts @@ -66,6 +66,12 @@ const tsTypeReferenceSVGRef = (ctx: Context) => { getOrCreateImport(ctx, ctx.importSource).specifiers.push( t.importSpecifier(identifier, identifier), ) + if (ctx.opts.native) { + return t.tsTypeReference( + identifier, + t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier('Svg'))]), + ) + } return t.tsTypeReference( identifier, t.tsTypeParameterInstantiation([