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 @@ -332,7 +332,7 @@ export default SvgComponent;"

exports[`plugin typescript with "descProp" and "expandProps" adds "desc", "descId" props and expands props 1`] = `
"import * as React from "react";
import type { SVGProps } from "react";
import type { ComponentProps } from "react";
interface SVGRProps {
desc?: string;
descId?: string;
Expand All @@ -341,14 +341,14 @@ const SvgComponent = ({
desc,
descId,
...props
}: SVGProps<SVGSVGElement> & SVGRProps) => <svg><g /></svg>;
}: ComponentProps<'svg'> & SVGRProps) => <svg><g /></svg>;
export default SvgComponent;"
`;

exports[`plugin typescript with "expandProps" add props 1`] = `
"import * as React from "react";
import type { SVGProps } from "react";
const SvgComponent = (props: SVGProps<SVGSVGElement>) => <svg><g /></svg>;
import type { ComponentProps } from "react";
const SvgComponent = (props: ComponentProps<'svg'>) => <svg><g /></svg>;
export default SvgComponent;"
`;

Expand Down Expand Up @@ -411,9 +411,9 @@ export default ForwardRef;"

exports[`plugin typescript with "ref" and "expandProps" option expands props 1`] = `
"import * as React from "react";
import type { SVGProps } from "react";
import type { ComponentProps } from "react";
import { Ref, forwardRef } from "react";
const SvgComponent = (props: SVGProps<SVGSVGElement>, ref: Ref<SVGSVGElement>) => <svg><g /></svg>;
const SvgComponent = (props: ComponentProps<'svg'>, ref: Ref<SVGSVGElement>) => <svg><g /></svg>;
const ForwardRef = forwardRef(SvgComponent);
export default ForwardRef;"
`;
Expand All @@ -428,7 +428,7 @@ export default ForwardRef;"

exports[`plugin typescript with "titleProp" "descProp" and "expandProps" adds "title", "titleId", "desc", "descId" props and expands props 1`] = `
"import * as React from "react";
import type { SVGProps } from "react";
import type { ComponentProps } from "react";
interface SVGRProps {
title?: string;
titleId?: string;
Expand All @@ -441,7 +441,7 @@ const SvgComponent = ({
desc,
descId,
...props
}: SVGProps<SVGSVGElement> & SVGRProps) => <svg><g /></svg>;
}: ComponentProps<'svg'> & SVGRProps) => <svg><g /></svg>;
export default SvgComponent;"
`;

Expand Down Expand Up @@ -477,7 +477,7 @@ export default SvgComponent;"

exports[`plugin typescript with "titleProp" and "expandProps" adds "title", "titleId" props and expands props 1`] = `
"import * as React from "react";
import type { SVGProps } from "react";
import type { ComponentProps } from "react";
interface SVGRProps {
title?: string;
titleId?: string;
Expand All @@ -486,7 +486,7 @@ const SvgComponent = ({
title,
titleId,
...props
}: SVGProps<SVGSVGElement> & SVGRProps) => <svg><g /></svg>;
}: ComponentProps<'svg'> & SVGRProps) => <svg><g /></svg>;
export default SvgComponent;"
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,13 @@ const tsTypeReferenceSVGProps = (ctx: Context) => {
)
return t.tsTypeReference(identifier)
}
const identifier = t.identifier('SVGProps')
const identifier = t.identifier('ComponentProps')
getOrCreateImport(ctx, ctx.importSource, 'type').specifiers.push(
t.importSpecifier(identifier, identifier),
)
return t.tsTypeReference(
identifier,
t.tsTypeParameterInstantiation([
t.tsTypeReference(t.identifier('SVGSVGElement')),
]),
t.tsTypeParameterInstantiation([t.tsTypeReference(t.identifier("'svg'"))]),
)
}

Expand Down