- 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.
21 lines
900 B
JavaScript
21 lines
900 B
JavaScript
// You should be able to use a function as an object with a call property
|
|
var a: { (x: number): string } = function (x: number): string { return "hi"; };
|
|
|
|
// ...and it should notice when the return type is wrong
|
|
var b: { (x: number): number } = function (x: number): string { return "hi"; };
|
|
|
|
// ...or if the param type is wrong
|
|
var c: { (x: string): string } = function (x: number): string { return "hi"; };
|
|
|
|
// ...or if the arity is wrong
|
|
var d: { (): string } = function (x: number): string { return "hi"; };
|
|
|
|
// ...but subtyping rules still apply
|
|
var e: { (x: any): void } = function() { } // arity
|
|
var f: { (): mixed } = function(): string { return "hi" } // return type
|
|
var g: { (x: string): void } = function(x: mixed) { } // param type
|
|
|
|
// A function can be an object
|
|
var y : {} = function (x: number): string { return "hi"; };
|
|
var z : Object = function (x: number): string { return "hi"; };
|