- 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.
31 lines
640 B
JavaScript
31 lines
640 B
JavaScript
var React = require('React');
|
|
|
|
type T1 = { }
|
|
type T2 = { x: number }
|
|
type T3 = { x: number, y: number }
|
|
|
|
class C1 extends React.Component<T1, T2, any> { // error
|
|
}
|
|
|
|
class C2 extends React.Component<void, T2, any> { // OK
|
|
}
|
|
|
|
// no need to add type arguments to React.Component
|
|
class C3 extends React.Component { // OK
|
|
static defaultProps: T1;
|
|
props: T2;
|
|
}
|
|
|
|
class C4 extends React.Component { // OK, recommended
|
|
// no need to declare defaultProps unless necessary
|
|
props: T2;
|
|
}
|
|
|
|
class C5 extends React.Component<T2, T3, any> { // error
|
|
}
|
|
|
|
class C6 extends React.Component { // OK, recommended
|
|
static defaultProps: T2;
|
|
props: T3;
|
|
}
|