'FunctionComponent' components don't output propTypes
JasonKaz opened this issue · comments
Jason Kaczmarsky commented
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
:
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.
Miles Johnson commented
Looks like I need another check here: https://github.com/milesj/babel-plugin-typescript-to-proptypes/blob/master/src/index.ts#L269
Miles Johnson commented
Fixed here cadc168
Jason Kaczmarsky commented
Works perfectly! Thanks for the quick response!
Miles Johnson commented
Np, luckily it was an easy fix!