Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<SVGSVGElement>) => <Svg><g /></Svg>;
const SvgComponent = (props: SvgProps, ref: Ref<Svg>) => <Svg><g /></Svg>;
const ForwardRef = forwardRef(SvgComponent);
export default ForwardRef;"
`;
Expand All @@ -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<SVGSVGElement>) => <Svg><g /></Svg>;
const SvgComponent = (_, ref: Ref<Svg>) => <Svg><g /></Svg>;
const ForwardRef = forwardRef(SvgComponent);
export default ForwardRef;"
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down