milesj / babel-plugin-typescript-to-proptypes

Generate React PropTypes from TypeScript interfaces or type aliases.
MIT License
367 stars 25 forks source link

Order of type declaration is significant #4

Closed thielium closed 5 years ago

thielium commented 6 years ago

Steps to reproduce

The following fixture receives no PropTypes.

import React from 'react';
export default class OutOfOrder extends React.Component<Props> {
  render() {
    return null;
  }
}
export interface Props {
  b: string;
}

Moving the Props to the top of the file does yield PropTypes.

Here's the fixture + expected snapshot; thought that might be easier than posting in the comment.

milesj commented 6 years ago

This is intentional. There were issues on generating prop types in Program:exit, so they're generated when a class is found. I'll look into this again but it may just be a caveat to deal with.

milesj commented 5 years ago

This should work now.