eslint-plugin-react icon indicating copy to clipboard operation
eslint-plugin-react copied to clipboard

No corresponding propTypes declaration when export type with typescript.

Open xyy94813 opened this issue 2 years ago • 2 comments

// Will get error: defaultProp "data" has no corresponding propTypes declaration
// from react/default-props-match-prop-types
export type TableProps = {
  data?: any;
};

const defaultProps = {
  data: null,
};

const Table: FC<TableProps> = ({ data }) => null;
// working well
type TableProps = {
  data?: any;
};

const defaultProps = {
  data: null,
};

const Table: FC<TableProps> = ({ data }) => null;

xyy94813 avatar Mar 22 '22 08:03 xyy94813

I assume the second example has a type keyword? TableProps = just makes a global variable of a JS object.

ljharb avatar Mar 22 '22 17:03 ljharb

Yes, it has a type keyword

xyy94813 avatar Mar 23 '22 02:03 xyy94813