codemod-proptypes-to-flow icon indicating copy to clipboard operation
codemod-proptypes-to-flow copied to clipboard

Flow props are now a generic type

Open iainbeeston opened this issue 7 years ago • 1 comments

In the latest versions of flow, proptypes are no longer a class property when using es6 classes, eg.

export type Props = {
  foo: number
}

class MyComponent extends React.Component {
  props: Props
}

Instead React.Component is a generic type, and it expects the props to be passed into that instead:

export type Props = {
  foo: number
}

class MyComponent extends React.Component<Props> {
}

The codemod is currently doing the former, but I suspect it should be either updated to do the latter, or have a flag that lets it do either depending on the flow version(?).

iainbeeston avatar Feb 26 '18 07:02 iainbeeston

Added https://github.com/billyvg/codemod-proptypes-to-flow/pull/23 that fixes it

kangax avatar Sep 06 '18 21:09 kangax