Skip to content

Conversation

iamakulov
Copy link

The codemod now generates type & { ref?: RefType } instead of type & { ref: RefType } to correctly reflect that refs are optional.

Otherwise, code like this:

const VolumeIcon = React.forwardRef<
    React.ElementRef<typeof Svg>,
    React.ComponentPropsWithRef<typeof Svg>
>(({ width = "20", height = "20", ...props }, ref) => { ... }

<VolumeIcon /> // ← works

gets code-modded into code like this:

const VolumeIcon = ({
    ref,
    width = "20",
    height = "20",
    ...props
}: React.ComponentPropsWithRef<typeof Svg> & {
    ref: React.RefObject<React.ElementRef<typeof Svg>>;
}) => { ... }

<VolumeIcon /> // ← fails with `Property 'ref' is missing in type '{}' but required in type '{ ref: RefObject<SVGSVGElement>; }'`

and requires manual fixing.

The codemod now generates `type & { ref?: RefType }` instead of
`type & { ref: RefType }` to correctly reflect that ref is optional
in the transformed components.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant