milesj / babel-plugin-typescript-to-proptypes

Generate React PropTypes from TypeScript interfaces or type aliases.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'FunctionComponent' components don't output propTypes

JasonKaz opened this issue · comments

It seems like only React.SFC components are outputting propTypes and not React.FunctionComponent components. The reason I'm using FunctionComponent is because the TS types say that React.SFC is deprecated and instructs you to use FunctionComponent:
image

Input:

interface Props {
  test: string;
}

export const FunctionComponent: React.FunctionComponent<Props> = () => <div />;

export const SFCComponent: React.SFC<Props> = () => <div />;

Output:

var FunctionComponent = function FunctionComponent() {
  return React.createElement("div", null);
};

exports.FunctionComponent = FunctionComponent;

var SFCComponent = function SFCComponent() {
  return React.createElement("div", null);
};

exports.SFCComponent = SFCComponent;
SFCComponent.propTypes = {
  test: _propTypes.default.string.isRequired
};

I expect using both React.SFC and React.FunctionComponent to output propTypes.

Fixed here cadc168

Works perfectly! Thanks for the quick response!

Np, luckily it was an easy fix!