Is there an existing issue for this?
Description Overview
In TypeScript, when defining the props with an intersection from an imported type, the default props will get marked as mismatched.
In types.ts:
export type SVGDefaultProps = {
size: string | number;
}
In a component:
import type { SVGDefaultProps } from './types';
type ArrowProps = SVGDefaultProps & {
direction: 'up' | 'down'
};
const defaultProps = {
size: 16, // will get reported as failing react/default-props-match-prop-types
direction: 'up',
};
But this will work if it's all in one file:
type SVGDefaultProps = {
size: string | number;
}
type ArrowProps = SVGDefaultProps & {
direction: 'up' | 'down'
};
const defaultProps = {
size: 16,
direction: 'up',
};
Expected Behavior
Importing a type and using it in an intersection will be behave the same as if the type is fully defined within a file.
eslint-plugin-react version
7.33.2
eslint version
v8.53
node version
v18.13