-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
Description
prop type checking seems to broken inside forwardRef with version 7.27.0, 7.26.1 still worked fine.
The error only happens for type intersection hierarchies (I didn't test interface extensions).
When you have types like this:
type ControlProps = {
className?: string | undefined;
};
type NamedProps = {
name: string;
};
type ControlPropsWithChildren = ControlProps & {
children?: ReactNode;
};
type BaseButtonProps = ControlPropsWithChildren &
NamedProps & {
onClick?: (() => void) | undefined;
onMouseDown?: (() => void) | undefined;
onMouseUp?: (() => void) | undefined;
disabled?: boolean | undefined;
width?: number;
type?: 'submit' | 'reset' | 'button' | undefined;
};
The plugin will now falsely flag all properties in nested type intersections as missing in props validation, in this case name, className and children (see screenshot wiggly lines).
The problem does not happen when the component is not wrapped in forwardRef.
It also didn't happen with version 7.26.1
D:\...\BaseButton.tsx
23:7 error 'name' is missing in props validation react/prop-types
24:7 error 'className' is missing in props validation react/prop-types
28:7 error 'children' is missing in props validation react/prop-types
Its likely that this commit: 4bc3499 triggered the problem
yanskun, vaniyokk, henrikgundersen, MartijnHols, anark and 18 more
