- This brings in the flow test suite that contains a ton of JavaScript parsing edge cases - This creates snapshot tests using the pretty printer for all of them - If uncomment `RUN_AST_TESTS` line in `tests/run_specs.js`, it checks ast(pretty_print(x)) == ast(x). Right now, "178 failed, 197 passed, 375 of 377 total". So half of the tests are not passing, most of them are crashes and many of the rest are subtle issues.
84 lines
1.3 KiB
JavaScript
84 lines
1.3 KiB
JavaScript
var React = require('React');
|
|
|
|
type DefaultProps = { };
|
|
type Props = { x: number };
|
|
type State = { y: number };
|
|
|
|
class Foo extends React.Component {
|
|
props: Props;
|
|
state: State;
|
|
static defaultProps: DefaultProps;
|
|
|
|
is_mounted: boolean;
|
|
|
|
static bar(): void {}
|
|
|
|
qux(): void {
|
|
var _: string = this.props.x;
|
|
}
|
|
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = { y: "" };
|
|
}
|
|
|
|
setState(o: { y_: string }): void { }
|
|
|
|
componentDidMount(): void {
|
|
this.is_mounted = true;
|
|
}
|
|
|
|
componentWillReceiveProps(
|
|
nextProps: Object,
|
|
nextContext: any
|
|
): void {
|
|
this.qux();
|
|
}
|
|
|
|
}
|
|
|
|
Foo.defaultProps = 0;
|
|
var foo: $jsx<number> = <Foo/>;
|
|
|
|
Foo.bar();
|
|
|
|
var FooLegacy = React.createClass({
|
|
is_mounted: (undefined: ?boolean),
|
|
|
|
propTypes: {
|
|
x: React.PropTypes.number.isRequired
|
|
},
|
|
|
|
getDefaultProps(): DefaultProps { return {} },
|
|
|
|
statics: {
|
|
bar(): void {}
|
|
},
|
|
|
|
qux(): void {
|
|
var _: string = this.props.x;
|
|
},
|
|
|
|
getInitialState(): { y: string } {
|
|
return { y: "" };
|
|
},
|
|
|
|
setState(o: { y_: string }): void { },
|
|
|
|
componentDidMount(): void {
|
|
this.is_mounted = true;
|
|
},
|
|
|
|
componentWillReceiveProps(
|
|
nextProps: Object,
|
|
nextContext: any
|
|
): void {
|
|
this.qux();
|
|
},
|
|
});
|
|
|
|
FooLegacy.defaultProps = 0; // TODO: should be error
|
|
var foo_legacy: $jsx<number> = <FooLegacy/>;
|
|
|
|
FooLegacy.bar();
|