Add spaces around certain statements, add --write option, and more
parent
8861953e60
commit
c9e24eb477
|
@ -1,16 +1,28 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const fs = require("fs");
|
||||
const argv = require("minimist")(process.argv.slice(2));
|
||||
const minimist = require("minimist");
|
||||
const jscodefmt = require("../index");
|
||||
|
||||
const argv = minimist(process.argv.slice(2), {
|
||||
boolean: ["write", "useFlowParser"]
|
||||
});
|
||||
|
||||
const filename = argv["_"][0];
|
||||
const printWidth = argv['print-width'] || 80;
|
||||
const tabWidth = argv['tab-width'] || 2;
|
||||
const useFlowParser = argv['flow-parser'];
|
||||
const write = argv['write'];
|
||||
|
||||
console.log(jscodefmt.format(fs.readFileSync(filename, "utf8"), {
|
||||
const output = jscodefmt.format(fs.readFileSync(filename, "utf8"), {
|
||||
printWidth,
|
||||
tabWidth,
|
||||
useFlowParser
|
||||
}));
|
||||
});
|
||||
|
||||
if(write) {
|
||||
fs.writeFileSync(filename, output, "utf8");
|
||||
}
|
||||
else {
|
||||
console.log(output);
|
||||
}
|
||||
|
|
2
index.js
2
index.js
|
@ -50,6 +50,8 @@ module.exports = {
|
|||
});
|
||||
}
|
||||
|
||||
ast.tokens = [];
|
||||
|
||||
const printer = new Printer({ tabWidth, wrapColumn: printWidth });
|
||||
return printer.printGenerically(ast).code;
|
||||
}
|
||||
|
|
|
@ -59,9 +59,6 @@ function iterDoc(topDoc, func) {
|
|||
}
|
||||
}
|
||||
else if(doc.type !== "line") {
|
||||
if(doc.contents == null) {
|
||||
console.log("JWL", doc);
|
||||
}
|
||||
docs.push(doc.contents);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -233,7 +233,7 @@ function genericPrintNoParens(path, options, print) {
|
|||
// Babel 6
|
||||
if (n.directives) {
|
||||
path.each(function(childPath) {
|
||||
parts.push(print(childPath), ";", line);
|
||||
parts.push(print(childPath), ";", hardline);
|
||||
}, "directives");
|
||||
}
|
||||
|
||||
|
@ -566,6 +566,11 @@ function genericPrintNoParens(path, options, print) {
|
|||
return printStatementSequence(bodyPath, options, print);
|
||||
}, "body");
|
||||
|
||||
// If there are no contents, return a simple block
|
||||
if(!getFirstString(naked)) {
|
||||
return "{}";
|
||||
}
|
||||
|
||||
parts.push("{");
|
||||
// Babel 6
|
||||
if (n.directives) {
|
||||
|
@ -700,6 +705,10 @@ function genericPrintNoParens(path, options, print) {
|
|||
|
||||
case "ArrayExpression":
|
||||
case "ArrayPattern":
|
||||
if(n.elements.length === 0) {
|
||||
parts.push("[]");
|
||||
}
|
||||
else {
|
||||
parts.push(multilineGroup(concat([
|
||||
"[",
|
||||
indent(options.tabWidth,
|
||||
|
@ -711,6 +720,7 @@ function genericPrintNoParens(path, options, print) {
|
|||
line,
|
||||
"]"
|
||||
])));
|
||||
}
|
||||
|
||||
if (n.typeAnnotation)
|
||||
parts.push(path.call(print, "typeAnnotation"));
|
||||
|
@ -835,8 +845,9 @@ function genericPrintNoParens(path, options, print) {
|
|||
]);
|
||||
|
||||
case "IfStatement":
|
||||
var con = adjustClause(path.call(print, "consequent"), options);
|
||||
var parts = [
|
||||
const con = adjustClause(path.call(print, "consequent"), options);
|
||||
|
||||
parts = [
|
||||
"if (",
|
||||
group(concat([
|
||||
indent(options.tabWidth, concat([
|
||||
|
@ -976,7 +987,8 @@ function genericPrintNoParens(path, options, print) {
|
|||
case "LabeledStatement":
|
||||
return concat([
|
||||
path.call(print, "label"),
|
||||
":\n",
|
||||
":",
|
||||
hardline,
|
||||
path.call(print, "body")
|
||||
]);
|
||||
|
||||
|
@ -1617,7 +1629,7 @@ function printStatementSequence(path, options, print) {
|
|||
|
||||
var printed = [];
|
||||
|
||||
path.map(function(stmtPath) {
|
||||
path.map(function(stmtPath, i) {
|
||||
var stmt = stmtPath.getValue();
|
||||
|
||||
// Just in case the AST has been modified to contain falsy
|
||||
|
@ -1632,35 +1644,26 @@ function printStatementSequence(path, options, print) {
|
|||
return;
|
||||
}
|
||||
|
||||
printed.push(print(stmtPath));
|
||||
const addSpacing = shouldAddSpacing(stmt)
|
||||
const stmtPrinted = print(stmtPath);
|
||||
const parts = [];
|
||||
|
||||
if (addSpacing && !isFirstStatement(stmtPath)) {
|
||||
parts.push(hardline);
|
||||
}
|
||||
|
||||
parts.push(stmtPrinted);
|
||||
|
||||
if (addSpacing && !isLastStatement) {
|
||||
parts.push(literalline);
|
||||
}
|
||||
|
||||
printed.push(concat(parts));
|
||||
});
|
||||
|
||||
return join(hardline, printed);
|
||||
}
|
||||
|
||||
function maxSpace(s1, s2) {
|
||||
if (!s1 && !s2) {
|
||||
return fromString("");
|
||||
}
|
||||
|
||||
if (!s1) {
|
||||
return fromString(s2);
|
||||
}
|
||||
|
||||
if (!s2) {
|
||||
return fromString(s1);
|
||||
}
|
||||
|
||||
var spaceLines1 = fromString(s1);
|
||||
var spaceLines2 = fromString(s2);
|
||||
|
||||
if (spaceLines2.length > spaceLines1.length) {
|
||||
return spaceLines2;
|
||||
}
|
||||
|
||||
return spaceLines1;
|
||||
}
|
||||
|
||||
function printMethod(path, options, print) {
|
||||
var node = path.getNode();
|
||||
var kind = node.kind;
|
||||
|
@ -1935,3 +1938,26 @@ function nodeStr(str, options) {
|
|||
return JSON.stringify(str);
|
||||
}
|
||||
}
|
||||
|
||||
function shouldAddSpacing(node) {
|
||||
return node.type === "IfStatement" ||
|
||||
node.type === "ForStatement" ||
|
||||
node.type === "ForInStatement" ||
|
||||
node.type === "ForOfStatement" ||
|
||||
node.type === "ExpressionStatement" ||
|
||||
node.type === "FunctionDeclaration";
|
||||
}
|
||||
|
||||
function isFirstStatement(path) {
|
||||
const parent = path.getParentNode();
|
||||
const node = path.getValue();
|
||||
const body = parent.body;
|
||||
return body && body[0] === node;
|
||||
}
|
||||
|
||||
function isLastStatement(path) {
|
||||
const parent = path.getParentNode();
|
||||
const node = path.getValue();
|
||||
const body = parent.body;
|
||||
return body && body[body.length - 1] === node;
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ function foo() {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function bar() {
|
||||
L:
|
||||
do {
|
||||
|
@ -29,13 +30,14 @@ function foo() {
|
|||
bar(x);
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
function bar(x: number) {
|
||||
function bar(x: number) {}
|
||||
|
||||
}
|
||||
function foo() {
|
||||
var x = null;
|
||||
|
||||
if (x == null)
|
||||
return;
|
||||
|
||||
bar(x);
|
||||
}
|
||||
"
|
||||
|
|
|
@ -93,9 +93,11 @@ var array_of_tuple: [number, string][] = [ [ 0, \"foo\" ], [ 1, \"bar\" ] ];
|
|||
var array_of_tuple_parens: [number, string][] = array_of_tuple;
|
||||
type ObjType = { \"bar-foo\": string; \"foo-bar\": number };
|
||||
var test_obj: ObjType = { \"bar-foo\": \"23\" };
|
||||
|
||||
function param_anno(n: number): void {
|
||||
n = \"hey\";
|
||||
}
|
||||
|
||||
function param_anno2(
|
||||
batchRequests: Array<{ method: string; path: string; params: ?Object }>
|
||||
): void {
|
||||
|
@ -111,9 +113,11 @@ function param_anno2(
|
|||
}
|
||||
var toz: null = 3;
|
||||
var zer: null = null;
|
||||
|
||||
function foobar(n: ?number): number | null | void {
|
||||
return n;
|
||||
}
|
||||
|
||||
function barfoo(n: number | null | void): ?number {
|
||||
return n;
|
||||
}
|
||||
|
@ -142,12 +146,15 @@ function foo() {
|
|||
// ok (no confusion across scopes)
|
||||
// looked up above
|
||||
let myClassInstance: MyClass = null;
|
||||
|
||||
function bar(): MyClass {
|
||||
return null;
|
||||
}
|
||||
class MyClass {}
|
||||
|
||||
function foo() {
|
||||
let myClassInstance: MyClass = mk();
|
||||
|
||||
function mk() {
|
||||
return new MyClass();
|
||||
}
|
||||
|
@ -161,9 +168,8 @@ exports[`test issue-530.js 1`] = `
|
|||
|
||||
module.exports = foo;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
function foo(...args: any) {
|
||||
function foo(...args: any) {}
|
||||
|
||||
}
|
||||
module.exports = foo;
|
||||
"
|
||||
`;
|
||||
|
@ -204,9 +210,11 @@ function bar(y: MyObj): string {
|
|||
* leading to an error.
|
||||
*/
|
||||
type MyObj = Object;
|
||||
|
||||
function foo(x: { [key: string]: mixed }) {
|
||||
bar(x);
|
||||
}
|
||||
|
||||
function bar(y: MyObj): string {
|
||||
return y.foo;
|
||||
}
|
||||
|
@ -218,6 +226,7 @@ exports[`test other.js 1`] = `
|
|||
module.exports = (C: any);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
class C {}
|
||||
|
||||
module.exports = (C: any);
|
||||
"
|
||||
`;
|
||||
|
@ -255,6 +264,7 @@ declare class Map<K, V> {
|
|||
insertWith(fn: Merge<V>, k: K, v: V): Map<K, V>
|
||||
}
|
||||
declare function foldr<A, B>(fn: (a: A, b: B) => B, b: B, as: A[]): B;
|
||||
|
||||
function insertMany<K, V>(
|
||||
merge: Merge<V>, vs: [K, V][], m: Map<K, V>
|
||||
): Map<K, V> {
|
||||
|
@ -278,6 +288,7 @@ exports[`test test.js 1`] = `
|
|||
((0: C): string);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var C = require(\"./other\");
|
||||
|
||||
((0: C): string);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -13,9 +13,11 @@ var z:string = qux(0);
|
|||
function foo(x: any): any {
|
||||
return x;
|
||||
}
|
||||
|
||||
function bar(x: any): mixed {
|
||||
return x;
|
||||
}
|
||||
|
||||
function qux(x: mixed): any {
|
||||
return x;
|
||||
}
|
||||
|
@ -68,12 +70,15 @@ var w:string = baz(0);
|
|||
function foo(x: $FlowFixMe): $FlowFixMe {
|
||||
return x;
|
||||
}
|
||||
|
||||
function bar(x: $FlowFixMe): mixed {
|
||||
return x;
|
||||
}
|
||||
|
||||
function qux(x: $FlowFixMe<number>): $FlowFixMe<number> {
|
||||
return x;
|
||||
}
|
||||
|
||||
function baz(x: $FlowFixMe<nnumber>): $FlowFixMe<number> {
|
||||
return x;
|
||||
}
|
||||
|
@ -117,12 +122,15 @@ var w:string = baz(0);
|
|||
function foo(x: $FlowIssue): $FlowIssue {
|
||||
return x;
|
||||
}
|
||||
|
||||
function bar(x: $FlowIssue): mixed {
|
||||
return x;
|
||||
}
|
||||
|
||||
function qux(x: $FlowIssue<number>): $FlowIssue<number> {
|
||||
return x;
|
||||
}
|
||||
|
||||
function baz(x: $FlowIssue<nnumber>): $FlowIssue<number> {
|
||||
return x;
|
||||
}
|
||||
|
@ -176,17 +184,20 @@ declare class C {
|
|||
bar(n1: number, n2: number): number;
|
||||
bar(s1: string, s2: string): string
|
||||
}
|
||||
|
||||
function foo(c: C, x: any): string {
|
||||
let y = x.y;
|
||||
return c.bar(0, y);
|
||||
}
|
||||
var any_fun1 = require(\"./nonflowfile\");
|
||||
|
||||
function bar1(x: mixed) {
|
||||
if (any_fun1(x)) {
|
||||
(x: boolean);
|
||||
}
|
||||
}
|
||||
var any_fun2 = require(\"./anyexportflowfile\");
|
||||
|
||||
function bar2(x: mixed) {
|
||||
if (any_fun2(x)) {
|
||||
(x: boolean);
|
||||
|
@ -216,6 +227,7 @@ function foo(o: ?AsyncRequest) {
|
|||
* annotation - without it, the body of the if will be unreachable
|
||||
*/
|
||||
type AsyncRequest = any;
|
||||
|
||||
function foo(o: ?AsyncRequest) {
|
||||
if (o) {
|
||||
var n: number = o;
|
||||
|
|
|
@ -132,76 +132,113 @@ let tests = [
|
|||
// ok
|
||||
// error, string ~> empty
|
||||
// error, string ~> empty
|
||||
function num(x: number) {
|
||||
function num(x: number) {}
|
||||
|
||||
}
|
||||
function str(x: string) {
|
||||
function str(x: string) {}
|
||||
|
||||
}
|
||||
function foo() {
|
||||
var x = 0;
|
||||
var y = \"...\";
|
||||
var z = {};
|
||||
|
||||
num(x + x);
|
||||
|
||||
num(x + y);
|
||||
|
||||
str(x + y);
|
||||
|
||||
str(x + x);
|
||||
|
||||
str(z + y);
|
||||
}
|
||||
|
||||
function bar0(x: ?number, y: number) {
|
||||
num(x + y);
|
||||
}
|
||||
|
||||
function bar1(x: number, y: ?number) {
|
||||
num(x + y);
|
||||
}
|
||||
|
||||
function bar2(x?: number, y: number) {
|
||||
num(x + y);
|
||||
}
|
||||
|
||||
function bar3(x: number, y?: number) {
|
||||
num(x + y);
|
||||
}
|
||||
|
||||
function bar4(x?: ?number, y: number) {
|
||||
num(x + y);
|
||||
}
|
||||
|
||||
function bar5(x: number, y?: ?number) {
|
||||
num(x + y);
|
||||
}
|
||||
|
||||
num(null + null);
|
||||
|
||||
num(undefined + undefined);
|
||||
|
||||
num(null + 1);
|
||||
|
||||
num(1 + null);
|
||||
|
||||
num(undefined + 1);
|
||||
|
||||
num(1 + undefined);
|
||||
|
||||
num(null + true);
|
||||
|
||||
num(true + null);
|
||||
|
||||
num(undefined + true);
|
||||
|
||||
num(true + undefined);
|
||||
|
||||
str(\"foo\" + true);
|
||||
|
||||
str(true + \"foo\");
|
||||
|
||||
str(\"foo\" + null);
|
||||
|
||||
str(null + \"foo\");
|
||||
|
||||
str(\"foo\" + undefined);
|
||||
|
||||
str(undefined + \"foo\");
|
||||
let tests = [
|
||||
function(x: mixed, y: mixed) {
|
||||
x + y;
|
||||
|
||||
x + 0;
|
||||
|
||||
0 + x;
|
||||
|
||||
x + \"\";
|
||||
|
||||
\"\" + x;
|
||||
|
||||
x + {};
|
||||
|
||||
({}) + x;
|
||||
},
|
||||
function() {
|
||||
(1 + {}: number);
|
||||
|
||||
({} + 1: number);
|
||||
|
||||
(\"1\" + {}: string);
|
||||
|
||||
({} + \"1\": string);
|
||||
},
|
||||
function(x: any, y: number, z: string) {
|
||||
(x + y: string);
|
||||
|
||||
(y + x: string);
|
||||
|
||||
(x + z: empty);
|
||||
|
||||
(z + x: empty);
|
||||
}
|
||||
];
|
||||
|
@ -224,11 +261,16 @@ y **= 2; // error
|
|||
/* @flow */
|
||||
// error
|
||||
let x: number = 2 ** 3;
|
||||
|
||||
x **= 4;
|
||||
let y: string = \"123\";
|
||||
|
||||
y **= 2;
|
||||
|
||||
1 + 2 ** 3 + 4;
|
||||
|
||||
2 ** 2;
|
||||
|
||||
(-2) ** 2;
|
||||
"
|
||||
`;
|
||||
|
@ -251,15 +293,19 @@ function f<A,B>(a: A, b: B): B {return b + a; } // error
|
|||
function f<A>(a: A): A {
|
||||
return a + a;
|
||||
}
|
||||
|
||||
function f<A, B>(a: A, b: B): A {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
function f<A, B>(a: A, b: B): A {
|
||||
return b + a;
|
||||
}
|
||||
|
||||
function f<A, B>(a: A, b: B): B {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
function f<A, B>(a: A, b: B): B {
|
||||
return b + a;
|
||||
}
|
||||
|
@ -282,14 +328,16 @@ y *= 2; // error
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
// error
|
||||
function num(x: number) {
|
||||
function num(x: number) {}
|
||||
|
||||
}
|
||||
num(null * 1);
|
||||
|
||||
num(1 * null);
|
||||
let x: number = 2 * 3;
|
||||
|
||||
x *= 4;
|
||||
let y: string = \"123\";
|
||||
|
||||
y *= 2;
|
||||
"
|
||||
`;
|
||||
|
@ -341,27 +389,45 @@ let tests = [
|
|||
// error
|
||||
// error
|
||||
1 < 2;
|
||||
|
||||
1 < \"foo\";
|
||||
|
||||
\"foo\" < 1;
|
||||
|
||||
\"foo\" < \"bar\";
|
||||
|
||||
1 < { foo: 1 };
|
||||
|
||||
({ foo: 1 }) < 1;
|
||||
|
||||
({ foo: 1 }) < { foo: 1 };
|
||||
|
||||
\"foo\" < { foo: 1 };
|
||||
|
||||
({ foo: 1 }) < \"foo\";
|
||||
var x = (null: ?number);
|
||||
|
||||
1 < x;
|
||||
|
||||
x < 1;
|
||||
|
||||
null < null;
|
||||
|
||||
undefined < null;
|
||||
|
||||
null < undefined;
|
||||
|
||||
undefined < undefined;
|
||||
|
||||
NaN < 1;
|
||||
|
||||
1 < NaN;
|
||||
|
||||
NaN < NaN;
|
||||
let tests = [
|
||||
function(x: any, y: number, z: string) {
|
||||
x > y;
|
||||
|
||||
x > z;
|
||||
}
|
||||
];
|
||||
|
|
|
@ -13,6 +13,7 @@ function filterOutSmall (arr: Array<?number>): Array<?number> {
|
|||
function filterOutVoids<T>(arr: Array<?T>): Array<T> {
|
||||
return arr.filter(Boolean);
|
||||
}
|
||||
|
||||
function filterOutSmall(arr: Array<?number>): Array<?number> {
|
||||
return arr.filter(num => num && num > 10);
|
||||
}
|
||||
|
@ -49,6 +50,7 @@ function filterItems(items: Array<string | number>): Array<string | number> {
|
|||
).filter(Boolean);
|
||||
}
|
||||
const filteredItems = filterItems([ \"foo\", \"b\", 1, 2 ]);
|
||||
|
||||
console.log(filteredItems);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -11,7 +11,9 @@ var y: Array<string> = [\'3\', ...x];
|
|||
var A = [ 1, 2, 3 ];
|
||||
var B = [ ...A ];
|
||||
var C = [ 1, 2, 3 ];
|
||||
|
||||
B.sort((a, b) => a - b);
|
||||
|
||||
C.sort((a, b) => a - b);
|
||||
var x: Array<string> = [ \"1\", \"2\" ];
|
||||
var y: Array<string> = [ \"3\", ...x ];
|
||||
|
|
|
@ -66,9 +66,7 @@ function from_test() {
|
|||
// acc is element type of array when no init is provided
|
||||
// error, string ~> number
|
||||
// error, string ~> number
|
||||
function foo(x: string) {
|
||||
|
||||
}
|
||||
function foo(x: string) {}
|
||||
var a = [ 0 ];
|
||||
var b = a.map(
|
||||
function(x) {
|
||||
|
@ -92,12 +90,14 @@ var k: Array<number> = h.concat(h);
|
|||
var l: Array<number> = h.concat(1, 2, 3);
|
||||
var m: Array<number | string> = h.concat(\"a\", \"b\", \"c\");
|
||||
var n: Array<number> = h.concat(\"a\", \"b\", \"c\");
|
||||
|
||||
function reduce_test() {
|
||||
[ 0, 1, 2, 3, 4 ].reduce(
|
||||
function(previousValue, currentValue, index, array) {
|
||||
return previousValue + currentValue + array[index];
|
||||
}
|
||||
);
|
||||
|
||||
[ 0, 1, 2, 3, 4 ].reduce(
|
||||
function(previousValue, currentValue, index, array) {
|
||||
return previousValue + currentValue + array[index];
|
||||
|
@ -114,9 +114,12 @@ function reduce_test() {
|
|||
return a.concat(b);
|
||||
}
|
||||
);
|
||||
|
||||
[ \"\" ].reduce((acc, str) => acc * str.length);
|
||||
|
||||
[ \"\" ].reduceRight((acc, str) => acc * str.length);
|
||||
}
|
||||
|
||||
function from_test() {
|
||||
var a: Array<string> = Array.from(
|
||||
[ 1, 2, 3 ],
|
||||
|
|
|
@ -42,14 +42,16 @@ module.exports = \"arrays\";
|
|||
/* @providesModule Arrays */
|
||||
// for literals, composite element type is union of individuals
|
||||
// note: test both tuple and non-tuple inferred literals
|
||||
function foo(x: string) {
|
||||
|
||||
}
|
||||
function foo(x: string) {}
|
||||
var a = [];
|
||||
|
||||
a[0] = 1;
|
||||
|
||||
a[1] = \"...\";
|
||||
|
||||
foo(a[1]);
|
||||
var y;
|
||||
|
||||
a.forEach(x => y = x);
|
||||
var alittle: Array<?number> = [ 0, 1, 2, 3, null ];
|
||||
var abig: Array<?number> = [ 0, 1, 2, 3, 4, 5, 6, 8, null ];
|
||||
|
@ -72,6 +74,7 @@ var abig2: Array<{ x: number; y: number }> = [
|
|||
{ x: 0, y: 0, c: 1 },
|
||||
{ x: 0, y: 0, c: \"hey\" }
|
||||
];
|
||||
|
||||
module.exports = \"arrays\";
|
||||
"
|
||||
`;
|
||||
|
@ -90,7 +93,9 @@ arr[day] = 0;
|
|||
// error: number ~> string
|
||||
var arr = [];
|
||||
var day = new Date();
|
||||
|
||||
arr[day] = 0;
|
||||
|
||||
(arr[day]: string);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -19,7 +19,9 @@ var ident = <T>(x: T): T => x;
|
|||
var add = (x: number, y: number): number => x + y;
|
||||
var bad = (x: number): string => x;
|
||||
var ident = <T>(x: T): T => x;
|
||||
|
||||
(ident(1): number);
|
||||
|
||||
(ident(\"hi\"): number);
|
||||
"
|
||||
`;
|
||||
|
@ -41,6 +43,7 @@ function selectBestEffortImageForWidth(
|
|||
maxWidth: number, images: Array<Image>
|
||||
): Image {
|
||||
var maxPixelWidth = maxWidth;
|
||||
|
||||
images = images.sort((a, b) => a.width - b.width + \"\");
|
||||
return images.find(image => image.width >= maxPixelWidth) ||
|
||||
images[images.length - 1];
|
||||
|
|
|
@ -71,17 +71,21 @@ var objf : () => Promise<number> = obj.f;
|
|||
async function f0(): Promise<number> {
|
||||
return 1;
|
||||
}
|
||||
|
||||
async function f1(): Promise<boolean> {
|
||||
return 1;
|
||||
}
|
||||
|
||||
async function f2(p: Promise<number>): Promise<number> {
|
||||
var x: number = await p;
|
||||
var y: number = await 1;
|
||||
return x + y;
|
||||
}
|
||||
|
||||
async function f3(p: Promise<number>): Promise<number> {
|
||||
return await p;
|
||||
}
|
||||
|
||||
async function f4(p: Promise<number>): Promise<boolean> {
|
||||
return await p;
|
||||
}
|
||||
|
@ -131,6 +135,7 @@ var P: Promise<Class<C>> = new Promise(
|
|||
resolve(C);
|
||||
}
|
||||
);
|
||||
|
||||
async function foo() {
|
||||
class Bar extends (await P) {}
|
||||
return Bar;
|
||||
|
@ -164,51 +169,23 @@ console.log(x.async);
|
|||
var async = 3;
|
||||
var y = { async };
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
async function f() {
|
||||
async function f() {}
|
||||
|
||||
}
|
||||
async function ft<T>(a: T) {
|
||||
|
||||
}
|
||||
async function ft<T>(a: T) {}
|
||||
class C {
|
||||
async m() {
|
||||
|
||||
async m() {}
|
||||
async mt<T>(a: T) {}
|
||||
static async m(a) {}
|
||||
static async mt<T>(a: T) {}
|
||||
}
|
||||
async mt<T>(a: T) {
|
||||
|
||||
}
|
||||
static async m(a) {
|
||||
|
||||
}
|
||||
static async mt<T>(a: T) {
|
||||
|
||||
}
|
||||
}
|
||||
var e = async function() {
|
||||
|
||||
};
|
||||
var et = async function<T>(a: T) {
|
||||
|
||||
};
|
||||
var n = new async function() {
|
||||
|
||||
}();
|
||||
var o = {
|
||||
async m() {
|
||||
|
||||
}
|
||||
};
|
||||
var ot = {
|
||||
async m<T>(a: T) {
|
||||
|
||||
}
|
||||
};
|
||||
var oz = {
|
||||
async async() {
|
||||
|
||||
}
|
||||
};
|
||||
var e = async function() {};
|
||||
var et = async function<T>(a: T) {};
|
||||
var n = new async function() {}();
|
||||
var o = { async m() {} };
|
||||
var ot = { async m<T>(a: T) {} };
|
||||
var oz = { async async() {} };
|
||||
var x = { async: 5 };
|
||||
|
||||
console.log(x.async);
|
||||
var async = 3;
|
||||
var y = { async };
|
||||
|
@ -246,13 +223,13 @@ async function foo3(): Promise<string> {
|
|||
async function foo1(): Promise<string> {
|
||||
return;
|
||||
}
|
||||
|
||||
async function foo2(): Promise<string> {
|
||||
return undefined;
|
||||
}
|
||||
async function foo3(): Promise<string> {
|
||||
function bar() {
|
||||
|
||||
}
|
||||
async function foo3(): Promise<string> {
|
||||
function bar() {}
|
||||
return bar();
|
||||
}
|
||||
"
|
||||
|
@ -345,12 +322,14 @@ function test1() {
|
|||
async function foo() {
|
||||
return 42;
|
||||
}
|
||||
|
||||
async function bar() {
|
||||
var a = await foo();
|
||||
var b: number = a;
|
||||
var c: string = a;
|
||||
}
|
||||
}
|
||||
|
||||
function test2() {
|
||||
async function voidoid1() {
|
||||
console.log(\"HEY\");
|
||||
|
@ -358,16 +337,19 @@ function test2() {
|
|||
var voidoid2: () => Promise<void> = voidoid1;
|
||||
var voidoid3: () => void = voidoid1;
|
||||
}
|
||||
|
||||
function test3() {
|
||||
async function voidoid4(): Promise<void> {
|
||||
console.log(\"HEY\");
|
||||
}
|
||||
}
|
||||
|
||||
function test4() {
|
||||
async function voidoid5(): void {
|
||||
console.log(\"HEY\");
|
||||
}
|
||||
}
|
||||
|
||||
function test5() {
|
||||
async function voidoid6(): Promise<number> {
|
||||
console.log(\"HEY\");
|
||||
|
@ -427,9 +409,11 @@ async function baz() {
|
|||
async function foo() {
|
||||
return 42;
|
||||
}
|
||||
|
||||
async function bar() {
|
||||
return foo();
|
||||
}
|
||||
|
||||
async function baz() {
|
||||
var a = await bar();
|
||||
var b: number = a;
|
||||
|
@ -467,6 +451,7 @@ var y = { await };
|
|||
async function f() {
|
||||
await 1;
|
||||
}
|
||||
|
||||
async function ft<T>(a: T) {
|
||||
await 1;
|
||||
}
|
||||
|
@ -509,6 +494,7 @@ var oz = {
|
|||
}
|
||||
};
|
||||
var x = { await: 5 };
|
||||
|
||||
console.log(x.await);
|
||||
var await = 3;
|
||||
var y = { await };
|
||||
|
|
|
@ -33,20 +33,26 @@ async function* delegate_next() {
|
|||
async function* inner() {
|
||||
var x: void = yield;
|
||||
}
|
||||
|
||||
yield* inner();
|
||||
}
|
||||
|
||||
delegate_next().next(0);
|
||||
|
||||
async function* delegate_yield() {
|
||||
async function* inner() {
|
||||
yield 0;
|
||||
}
|
||||
|
||||
yield* inner();
|
||||
}
|
||||
|
||||
async () => {
|
||||
for await (const x of delegate_yield()) {
|
||||
(x: void);
|
||||
}
|
||||
};
|
||||
|
||||
async function* delegate_return() {
|
||||
async function* inner() {
|
||||
return 0;
|
||||
|
@ -86,6 +92,7 @@ async function f() {
|
|||
// error: string ~> void
|
||||
interface File { readLine(): Promise<string>; close(): void; EOF: boolean }
|
||||
declare function fileOpen(path: string): Promise<File>;
|
||||
|
||||
async function* readLines(path) {
|
||||
let file: File = await fileOpen(path);
|
||||
try {
|
||||
|
@ -96,6 +103,7 @@ async function* readLines(path) {
|
|||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
async function f() {
|
||||
for await (const line of readLines(\"/path/to/file\")) {
|
||||
(line: void);
|
||||
|
@ -135,11 +143,13 @@ refuse_return().return(\"string\").then(result => {
|
|||
// yielding or returning internally.
|
||||
// error: number | void ~> string
|
||||
declare var gen: AsyncGenerator<void, string, void>;
|
||||
|
||||
gen.return(0).then(
|
||||
result => {
|
||||
(result.value: void);
|
||||
}
|
||||
);
|
||||
|
||||
async function* refuse_return() {
|
||||
try {
|
||||
yield 1;
|
||||
|
@ -147,6 +157,7 @@ async function* refuse_return() {
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
refuse_return().return(\"string\").then(
|
||||
result => {
|
||||
if (result.done) {
|
||||
|
@ -200,6 +211,7 @@ async function* catch_return() {
|
|||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
async () => {
|
||||
catch_return().throw(\"\").then(
|
||||
({ value }) => {
|
||||
|
@ -209,6 +221,7 @@ async () => {
|
|||
}
|
||||
);
|
||||
};
|
||||
|
||||
async function* yield_return() {
|
||||
try {
|
||||
yield 0;
|
||||
|
@ -217,6 +230,7 @@ async function* yield_return() {
|
|||
yield e;
|
||||
}
|
||||
}
|
||||
|
||||
async () => {
|
||||
yield_return().throw(\"\").then(
|
||||
({ value }) => {
|
||||
|
|
|
@ -19,6 +19,7 @@ declare var mergeInto: $Facebookism$MergeInto;
|
|||
declare var mixin: $Facebookism$Mixin;
|
||||
declare var objectGetPrototypeOf: Object$GetPrototypeOf;
|
||||
declare var objectAssign: Object$Assign;
|
||||
|
||||
m;
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -78,45 +78,58 @@ let tests = [
|
|||
let tests = [
|
||||
function() {
|
||||
\"foo\" in {};
|
||||
|
||||
\"foo\" in { foo: null };
|
||||
|
||||
0 in {};
|
||||
|
||||
0 in { \"0\": null };
|
||||
},
|
||||
function() {
|
||||
\"foo\" in [];
|
||||
|
||||
0 in [];
|
||||
|
||||
\"length\" in [];
|
||||
},
|
||||
function() {
|
||||
\"foo\" in new String(\"bar\");
|
||||
|
||||
\"foo\" in new Number(123);
|
||||
},
|
||||
function() {
|
||||
\"foo\" in 123;
|
||||
|
||||
\"foo\" in \"bar\";
|
||||
|
||||
\"foo\" in void 0;
|
||||
|
||||
\"foo\" in null;
|
||||
},
|
||||
function() {
|
||||
null in {};
|
||||
|
||||
void 0 in {};
|
||||
|
||||
({}) in {};
|
||||
|
||||
[] in {};
|
||||
|
||||
false in [];
|
||||
},
|
||||
function() {
|
||||
if (\"foo\" in 123) {
|
||||
if (\"foo\" in 123)
|
||||
{}
|
||||
|
||||
}
|
||||
if (!\"foo\" in {}) {
|
||||
if (!\"foo\" in {})
|
||||
{}
|
||||
|
||||
}
|
||||
if (!(\"foo\" in {})) {
|
||||
|
||||
}
|
||||
if (!(\"foo\" in {}))
|
||||
{}
|
||||
},
|
||||
function(x: Object, y: mixed) {
|
||||
\"foo\" in x;
|
||||
|
||||
\"foo\" in y;
|
||||
}
|
||||
];
|
||||
|
|
|
@ -33,23 +33,38 @@ for (const { baz } of bazzes) {
|
|||
// error: string ~> number
|
||||
// error: string ~> number
|
||||
const x = 0;
|
||||
|
||||
x++;
|
||||
|
||||
x--;
|
||||
|
||||
x += 0;
|
||||
|
||||
x -= 0;
|
||||
|
||||
x /= 0;
|
||||
|
||||
x %= 0;
|
||||
|
||||
x <<= 0;
|
||||
|
||||
x >>= 0;
|
||||
|
||||
x >>>= 0;
|
||||
|
||||
x |= 0;
|
||||
|
||||
x ^= 0;
|
||||
|
||||
x &= 0;
|
||||
const { foo } = { foo: \"foo\" };
|
||||
const [ bar ] = [ \"bar\" ];
|
||||
|
||||
(foo: number);
|
||||
|
||||
(bar: number);
|
||||
declare var bazzes: { baz: string }[];
|
||||
|
||||
for (const { baz } of bazzes) {
|
||||
(baz: number);
|
||||
}
|
||||
|
@ -311,128 +326,153 @@ function type_type() {
|
|||
type A = number;
|
||||
type A = number;
|
||||
}
|
||||
|
||||
function type_class() {
|
||||
type A = number;
|
||||
class A {}
|
||||
}
|
||||
|
||||
function type_let() {
|
||||
type A = number;
|
||||
let A = 0;
|
||||
}
|
||||
|
||||
function type_const() {
|
||||
type A = number;
|
||||
const A = 0;
|
||||
}
|
||||
|
||||
function type_var() {
|
||||
type A = number;
|
||||
var A = 0;
|
||||
}
|
||||
|
||||
function type_reassign() {
|
||||
type A = number;
|
||||
|
||||
A = 42;
|
||||
}
|
||||
|
||||
function class_type() {
|
||||
class A {}
|
||||
type A = number;
|
||||
}
|
||||
|
||||
function class_class() {
|
||||
class A {}
|
||||
class A {}
|
||||
}
|
||||
|
||||
function class_let() {
|
||||
class A {}
|
||||
let A = 0;
|
||||
}
|
||||
|
||||
function class_const() {
|
||||
class A {}
|
||||
const A = 0;
|
||||
}
|
||||
|
||||
function class_var() {
|
||||
class A {}
|
||||
var A = 0;
|
||||
}
|
||||
|
||||
function let_type() {
|
||||
let A = 0;
|
||||
type A = number;
|
||||
}
|
||||
|
||||
function let_class() {
|
||||
let A = 0;
|
||||
class A {}
|
||||
}
|
||||
|
||||
function let_let() {
|
||||
let A = 0;
|
||||
let A = 0;
|
||||
}
|
||||
|
||||
function let_const() {
|
||||
let A = 0;
|
||||
const A = 0;
|
||||
}
|
||||
|
||||
function let_var() {
|
||||
let A = 0;
|
||||
var A = 0;
|
||||
}
|
||||
|
||||
function const_type() {
|
||||
const A = 0;
|
||||
type A = number;
|
||||
}
|
||||
|
||||
function const_class() {
|
||||
const A = 0;
|
||||
class A {}
|
||||
}
|
||||
|
||||
function const_let() {
|
||||
const A = 0;
|
||||
let A = 0;
|
||||
}
|
||||
|
||||
function const_const() {
|
||||
const A = 0;
|
||||
const A = 0;
|
||||
}
|
||||
|
||||
function const_var() {
|
||||
const A = 0;
|
||||
var A = 0;
|
||||
}
|
||||
|
||||
function const_reassign() {
|
||||
const A = 0;
|
||||
|
||||
A = 42;
|
||||
}
|
||||
|
||||
function var_type() {
|
||||
var A = 0;
|
||||
type A = number;
|
||||
}
|
||||
|
||||
function var_class() {
|
||||
var A = 0;
|
||||
class A {}
|
||||
}
|
||||
|
||||
function var_let() {
|
||||
var A = 0;
|
||||
let A = 0;
|
||||
}
|
||||
|
||||
function var_const() {
|
||||
var A = 0;
|
||||
const A = 0;
|
||||
}
|
||||
|
||||
function var_var() {
|
||||
var A = 0;
|
||||
var A = 0;
|
||||
}
|
||||
|
||||
function function_toplevel() {
|
||||
function a() {
|
||||
function a() {}
|
||||
|
||||
function a() {}
|
||||
}
|
||||
function a() {
|
||||
|
||||
}
|
||||
}
|
||||
function function_block() {
|
||||
{
|
||||
function a() {
|
||||
function a() {}
|
||||
|
||||
function a() {}
|
||||
}
|
||||
}
|
||||
function a() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
function var_shadow_nested_scope() {
|
||||
{
|
||||
let x = 0;
|
||||
|
@ -441,6 +481,7 @@ function var_shadow_nested_scope() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
function type_shadow_nested_scope() {
|
||||
{
|
||||
let x = 0;
|
||||
|
@ -449,9 +490,9 @@ function type_shadow_nested_scope() {
|
|||
}
|
||||
}
|
||||
}
|
||||
function fn_params_name_clash(x, x) {
|
||||
|
||||
}
|
||||
function fn_params_name_clash(x, x) {}
|
||||
|
||||
function fn_params_clash_fn_binding(x, y) {
|
||||
let x = 0;
|
||||
var y = 0;
|
||||
|
@ -605,6 +646,7 @@ function block_scope() {
|
|||
var b = \"\";
|
||||
}
|
||||
}
|
||||
|
||||
function switch_scope(x: string) {
|
||||
let a: number = 0;
|
||||
var b: number = 0;
|
||||
|
@ -618,9 +660,11 @@ function switch_scope(x: string) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function switch_scope2(x: number) {
|
||||
switch (x) {
|
||||
case 0:
|
||||
|
||||
a = \"\";
|
||||
break;
|
||||
case 1:
|
||||
|
@ -630,14 +674,17 @@ function switch_scope2(x: number) {
|
|||
let a = \"\";
|
||||
break;
|
||||
case 3:
|
||||
|
||||
a = \"\";
|
||||
break;
|
||||
case 4:
|
||||
var c: string = a;
|
||||
break;
|
||||
}
|
||||
|
||||
a = \"\";
|
||||
}
|
||||
|
||||
function try_scope() {
|
||||
let a: number = 0;
|
||||
try {
|
||||
|
@ -648,53 +695,63 @@ function try_scope() {
|
|||
let a = \"\";
|
||||
}
|
||||
}
|
||||
|
||||
function for_scope_let() {
|
||||
let a: number = 0;
|
||||
for (let a = \"\"; ; ) {
|
||||
|
||||
for (let a = \"\"; ; )
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
function for_scope_var() {
|
||||
var a: number = 0;
|
||||
for (var a = \"\"; ; ) {
|
||||
|
||||
for (var a = \"\"; ; )
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
function for_in_scope_let(o: Object) {
|
||||
let a: number = 0;
|
||||
for (let a in o) {
|
||||
|
||||
for (let a in o)
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
function for_in_scope_var(o: Object) {
|
||||
var a: number = 0;
|
||||
for (var a in o) {
|
||||
|
||||
for (var a in o)
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
function for_of_scope_let(xs: string[]) {
|
||||
let a: number = 0;
|
||||
for (let a of xs) {
|
||||
|
||||
for (let a of xs)
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
function for_of_scope_var(xs: string[]) {
|
||||
var a: number = 0;
|
||||
for (var a of xs) {
|
||||
|
||||
for (var a of xs)
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
function default_param_1() {
|
||||
function f(x: () => string = f): number {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function default_param_2() {
|
||||
let a = \"\";
|
||||
|
||||
function f0(x = () => a): number {
|
||||
let a = 0;
|
||||
return x();
|
||||
}
|
||||
|
||||
function f1(x = b): number {
|
||||
let b = 0;
|
||||
return x;
|
||||
|
@ -849,19 +906,23 @@ f(a); // ok, a: number (not ?number)
|
|||
// ok, a: number (not ?number)
|
||||
type T1 = T2;
|
||||
type T2 = number;
|
||||
|
||||
function f0() {
|
||||
var v = x * c;
|
||||
let x = 0;
|
||||
const c = 0;
|
||||
}
|
||||
|
||||
function f1(b) {
|
||||
x = 10;
|
||||
let x = 0;
|
||||
|
||||
if (b) {
|
||||
y = 10;
|
||||
let y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
function f2() {
|
||||
{
|
||||
var v = x * c;
|
||||
|
@ -869,19 +930,23 @@ function f2() {
|
|||
let x = 0;
|
||||
const c = 0;
|
||||
}
|
||||
|
||||
function f3() {
|
||||
var s: string = foo();
|
||||
{
|
||||
var n: number = foo();
|
||||
|
||||
function foo() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
var s2: string = foo();
|
||||
|
||||
function foo() {
|
||||
return \"\";
|
||||
}
|
||||
}
|
||||
|
||||
function f4() {
|
||||
function g() {
|
||||
return x + c;
|
||||
|
@ -889,10 +954,12 @@ function f4() {
|
|||
let x = 0;
|
||||
const c = 0;
|
||||
}
|
||||
|
||||
function f5() {
|
||||
function g() {
|
||||
return x;
|
||||
}
|
||||
|
||||
g();
|
||||
let x = 0;
|
||||
const c = 0;
|
||||
|
@ -902,11 +969,15 @@ var y = new C();
|
|||
class C {}
|
||||
var z: C = new C();
|
||||
var a: number;
|
||||
|
||||
function f(n: number) {
|
||||
return n;
|
||||
}
|
||||
|
||||
f(a);
|
||||
|
||||
a = 10;
|
||||
|
||||
f(a);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -125,69 +125,97 @@ for (let [x, y]: [number, number] of a.entries()) {} // incorrect
|
|||
// incorrect
|
||||
// incorrect
|
||||
const a: FormData = new FormData();
|
||||
|
||||
new FormData(\"\");
|
||||
|
||||
new FormData(document.createElement(\"input\"));
|
||||
|
||||
new FormData(document.createElement(\"form\"));
|
||||
const b: boolean = a.has(\"foo\");
|
||||
const c: ?(string | File) = a.get(\"foo\");
|
||||
const d: string = a.get(\"foo\");
|
||||
const e: Blob = a.get(\"foo\");
|
||||
const f: ?(string | File | Blob) = a.get(\"foo\");
|
||||
|
||||
a.get(2);
|
||||
const a1: Array<string | File> = a.getAll(\"foo\");
|
||||
const a2: Array<string | File | number> = a.getAll(\"foo\");
|
||||
const a3: Array<string | Blob | File> = a.getAll(\"foo\");
|
||||
|
||||
a.getAll(23);
|
||||
|
||||
a.set(\"foo\", \"bar\");
|
||||
|
||||
a.set(\"foo\", {});
|
||||
|
||||
a.set(2, \"bar\");
|
||||
|
||||
a.set(\"foo\", \"bar\", \"baz\");
|
||||
|
||||
a.set(\"bar\", new File([], \"q\"));
|
||||
|
||||
a.set(\"bar\", new File([], \"q\"), \"x\");
|
||||
|
||||
a.set(\"bar\", new File([], \"q\"), 2);
|
||||
|
||||
a.set(\"bar\", new Blob());
|
||||
|
||||
a.set(\"bar\", new Blob(), \"x\");
|
||||
|
||||
a.set(\"bar\", new Blob(), 2);
|
||||
|
||||
a.append(\"foo\", \"bar\");
|
||||
|
||||
a.append(\"foo\", {});
|
||||
|
||||
a.append(2, \"bar\");
|
||||
|
||||
a.append(\"foo\", \"bar\", \"baz\");
|
||||
|
||||
a.append(\"foo\", \"bar\");
|
||||
|
||||
a.append(\"bar\", new File([], \"q\"));
|
||||
|
||||
a.append(\"bar\", new File([], \"q\"), \"x\");
|
||||
|
||||
a.append(\"bar\", new File([], \"q\"), 2);
|
||||
|
||||
a.append(\"bar\", new Blob());
|
||||
|
||||
a.append(\"bar\", new Blob(), \"x\");
|
||||
|
||||
a.append(\"bar\", new Blob(), 2);
|
||||
|
||||
a.delete(\"xx\");
|
||||
|
||||
a.delete(3);
|
||||
for (let x: string of a.keys()) {
|
||||
|
||||
}
|
||||
for (let x: number of a.keys()) {
|
||||
for (let x: string of a.keys())
|
||||
{}
|
||||
|
||||
}
|
||||
for (let x: string | File of a.values()) {
|
||||
for (let x: number of a.keys())
|
||||
{}
|
||||
|
||||
}
|
||||
for (let x: string | File | Blob of a.values()) {
|
||||
for (let x: string | File of a.values())
|
||||
{}
|
||||
|
||||
}
|
||||
for (let [ x, y ]: [string, string | File] of a.entries()) {
|
||||
for (let x: string | File | Blob of a.values())
|
||||
{}
|
||||
|
||||
}
|
||||
for (let [ x, y ]: [string, string | File | Blob] of a.entries()) {
|
||||
for (let [ x, y ]: [string, string | File] of a.entries())
|
||||
{}
|
||||
|
||||
}
|
||||
for (let [ x, y ]: [number, string] of a.entries()) {
|
||||
for (let [ x, y ]: [string, string | File | Blob] of a.entries())
|
||||
{}
|
||||
|
||||
}
|
||||
for (let [ x, y ]: [string, number] of a.entries()) {
|
||||
for (let [ x, y ]: [number, string] of a.entries())
|
||||
{}
|
||||
|
||||
}
|
||||
for (let [ x, y ]: [number, number] of a.entries()) {
|
||||
for (let [ x, y ]: [string, number] of a.entries())
|
||||
{}
|
||||
|
||||
}
|
||||
for (let [ x, y ]: [number, number] of a.entries())
|
||||
{}
|
||||
"
|
||||
`;
|
||||
|
||||
|
@ -249,29 +277,36 @@ function callback(
|
|||
return;
|
||||
}
|
||||
const o: MutationObserver = new MutationObserver(callback);
|
||||
|
||||
new MutationObserver((arr: Array<MutationRecord>) => true);
|
||||
new MutationObserver(
|
||||
() => {
|
||||
|
||||
}
|
||||
);
|
||||
new MutationObserver(() => {});
|
||||
|
||||
new MutationObserver();
|
||||
new MutationObserver(42);
|
||||
new MutationObserver(
|
||||
(n: number) => {
|
||||
|
||||
}
|
||||
);
|
||||
new MutationObserver(42);
|
||||
|
||||
new MutationObserver((n: number) => {});
|
||||
const div = document.createElement(\"div\");
|
||||
|
||||
o.observe(div, { attributes: true, attributeFilter: [ \"style\" ] });
|
||||
|
||||
o.observe(div, { characterData: true, invalid: true });
|
||||
|
||||
o.observe();
|
||||
|
||||
o.observe(\"invalid\");
|
||||
|
||||
o.observe(div);
|
||||
|
||||
o.observe(div, {});
|
||||
|
||||
o.observe(div, { subtree: true });
|
||||
|
||||
o.observe(div, { attributes: true, attributeFilter: true });
|
||||
|
||||
o.takeRecords();
|
||||
|
||||
o.disconnect();
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -4,10 +4,10 @@ foo(0, \"\");
|
|||
|
||||
function bar<X:number, Y:X>(x:X, y:Y): number { return y*0; }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
function foo<X, Y: X>(x: X, y: Y): void {
|
||||
function foo<X, Y: X>(x: X, y: Y): void {}
|
||||
|
||||
}
|
||||
foo(0, \"\");
|
||||
|
||||
function bar<X: number, Y: X>(x: X, y: Y): number {
|
||||
return y * 0;
|
||||
}
|
||||
|
@ -66,6 +66,7 @@ class C<T: number> {
|
|||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
function example<T: { x: number }>(o: T): T {
|
||||
o.x = 0;
|
||||
return o;
|
||||
|
|
|
@ -93,13 +93,16 @@ function foo(b) {
|
|||
}
|
||||
var w: number = z;
|
||||
}
|
||||
|
||||
function bar(b) {
|
||||
var x = (b ? null : false);
|
||||
|
||||
if (x == null)
|
||||
return;
|
||||
switch (\"\") {
|
||||
case 0:
|
||||
var y: number = x;
|
||||
|
||||
x = \"\";
|
||||
case 1:
|
||||
var z: number = x;
|
||||
|
@ -108,14 +111,17 @@ function bar(b) {
|
|||
}
|
||||
var w: number = x;
|
||||
}
|
||||
|
||||
function bar2(b) {
|
||||
var x = (b ? null : false);
|
||||
|
||||
if (x == null)
|
||||
return;
|
||||
switch (\"\") {
|
||||
case 0:
|
||||
{
|
||||
let y: number = x;
|
||||
|
||||
x = \"\";
|
||||
}
|
||||
case 1:
|
||||
|
@ -127,25 +133,32 @@ function bar2(b) {
|
|||
}
|
||||
var w: number = x;
|
||||
}
|
||||
|
||||
function qux(b) {
|
||||
var z = 0;
|
||||
while (b) {
|
||||
var y: number = z;
|
||||
|
||||
if (b) {
|
||||
z = \"\";
|
||||
continue;
|
||||
}
|
||||
|
||||
z = 0;
|
||||
}
|
||||
var w: number = z;
|
||||
}
|
||||
|
||||
function test_const() {
|
||||
let st: string = \"abc\";
|
||||
|
||||
for (let i = 1; i < 100; i++) {
|
||||
const fooRes: ?string = \"HEY\";
|
||||
|
||||
if (!fooRes) {
|
||||
break;
|
||||
}
|
||||
|
||||
st = fooRes;
|
||||
}
|
||||
return st;
|
||||
|
|
|
@ -4,7 +4,9 @@ exports[`test test.js 1`] = `
|
|||
module.exports = o;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var o = Object.freeze({ foo: 0 });
|
||||
|
||||
(o.foo: string);
|
||||
|
||||
module.exports = o;
|
||||
"
|
||||
`;
|
||||
|
@ -14,6 +16,7 @@ exports[`test test2.js 1`] = `
|
|||
(o.foo: string);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var o = require(\"./test\");
|
||||
|
||||
(o.foo: string);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -28,6 +28,7 @@ var b = a.map(
|
|||
);
|
||||
var c: string = b[0];
|
||||
var array = [];
|
||||
|
||||
function f() {
|
||||
array = array.map(
|
||||
function() {
|
||||
|
@ -38,6 +39,7 @@ function f() {
|
|||
}
|
||||
var Foo = require(\"./genericfoo\");
|
||||
var foo = new Foo();
|
||||
|
||||
function g() {
|
||||
var foo1 = foo.map(
|
||||
function() {
|
||||
|
@ -45,6 +47,7 @@ function g() {
|
|||
}
|
||||
);
|
||||
var x: number = foo1.get();
|
||||
|
||||
foo = foo1;
|
||||
}
|
||||
"
|
||||
|
@ -69,13 +72,12 @@ class Foo<T> {
|
|||
map<U>(callbackfn: () => U): Foo<U> {
|
||||
return new Foo();
|
||||
}
|
||||
set(x: T): void {
|
||||
|
||||
}
|
||||
set(x: T): void {}
|
||||
get(): T {
|
||||
return this.x;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Foo;
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -39,18 +39,23 @@ function f(): number {
|
|||
function a(f: { (): string }, g: { (x: number): string }): string {
|
||||
return f() + g(123);
|
||||
}
|
||||
|
||||
function b(f: { (): string }): number {
|
||||
return f();
|
||||
}
|
||||
|
||||
function c(f: { (x: number): number }): number {
|
||||
return f(\"hello\");
|
||||
}
|
||||
|
||||
function d(f: { (x: number): number }): number {
|
||||
return f();
|
||||
}
|
||||
|
||||
function e(f: {}): number {
|
||||
return f();
|
||||
}
|
||||
|
||||
function f(): number {
|
||||
var x = {};
|
||||
return x();
|
||||
|
@ -101,15 +106,11 @@ var c: { (x: string): string } = function(x: number): string {
|
|||
var d: { (): string } = function(x: number): string {
|
||||
return \"hi\";
|
||||
};
|
||||
var e: { (x: any): void } = function() {
|
||||
|
||||
};
|
||||
var e: { (x: any): void } = function() {};
|
||||
var f: { (): mixed } = function(): string {
|
||||
return \"hi\";
|
||||
};
|
||||
var g: { (x: string): void } = function(x: mixed) {
|
||||
|
||||
};
|
||||
var g: { (x: string): void } = function(x: mixed) {};
|
||||
var y: {} = function(x: number): string {
|
||||
return \"hi\";
|
||||
};
|
||||
|
@ -166,21 +167,27 @@ function g(x: {}): Function {
|
|||
function a(x: { (z: number): string }): (z: number) => string {
|
||||
return x;
|
||||
}
|
||||
|
||||
function b(x: { (z: number): string }): (z: number) => number {
|
||||
return x;
|
||||
}
|
||||
|
||||
function c(x: { (z: number): string }): (z: string) => string {
|
||||
return x;
|
||||
}
|
||||
|
||||
function d(x: { (z: number): string }): () => string {
|
||||
return x;
|
||||
}
|
||||
|
||||
function e(x: {}): () => string {
|
||||
return x;
|
||||
}
|
||||
|
||||
function f(x: { (z: number): string }): Function {
|
||||
return x;
|
||||
}
|
||||
|
||||
function g(x: {}): Function {
|
||||
return x;
|
||||
}
|
||||
|
@ -225,9 +232,11 @@ var b: { (): string; (x: number): string } = function(x?: number): string {
|
|||
var c: { (): string; (x: number): string } = function(x: number): string {
|
||||
return \"hi\";
|
||||
};
|
||||
|
||||
function d(x: { (): string; (x: number): string }): () => string {
|
||||
return x;
|
||||
}
|
||||
|
||||
function e(x: { (): string; (x: number): string }): () => number {
|
||||
return x;
|
||||
}
|
||||
|
@ -249,15 +258,10 @@ var c : { myProp: number } = f;
|
|||
// Expecting properties that don\'t exist should be an error
|
||||
// Expecting properties that do exist should be fine
|
||||
// Expecting properties in the functions statics should be fine
|
||||
var a: { someProp: number } = function() {
|
||||
var a: { someProp: number } = function() {};
|
||||
var b: { apply: Function } = function() {};
|
||||
var f = function() {};
|
||||
|
||||
};
|
||||
var b: { apply: Function } = function() {
|
||||
|
||||
};
|
||||
var f = function() {
|
||||
|
||||
};
|
||||
f.myProp = 123;
|
||||
var c: { myProp: number } = f;
|
||||
"
|
||||
|
@ -299,9 +303,7 @@ var a: { (x: number): string } = x => x.toString();
|
|||
var b: { (x: number): number } = x => \"hi\";
|
||||
var c: { (x: string): string } = x => x.toFixed();
|
||||
var d: { (): string } = x => \"hi\";
|
||||
var e: { (x: any): void } = () => {
|
||||
|
||||
};
|
||||
var e: { (x: any): void } = () => {};
|
||||
var f: { (): mixed } = () => \"hi\";
|
||||
var g: { (x: Date): void } = x => {
|
||||
x * 2;
|
||||
|
|
|
@ -11,9 +11,11 @@ function f(x) {
|
|||
(f: F);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
type F = { (x: string): number; p?: string };
|
||||
|
||||
function f(x) {
|
||||
return x.length;
|
||||
}
|
||||
|
||||
(f: F);
|
||||
"
|
||||
`;
|
||||
|
@ -47,19 +49,24 @@ callable.call(null, 0); // error, number ~> string
|
|||
// error, number ~> string
|
||||
// error, number ~> string
|
||||
var x = Boolean(4);
|
||||
function foo(fn: (value: any) => boolean) {
|
||||
|
||||
}
|
||||
function foo(fn: (value: any) => boolean) {}
|
||||
|
||||
foo(Boolean);
|
||||
var dict: { [k: string]: any } = {};
|
||||
|
||||
dict();
|
||||
interface ICall { (x: string): void }
|
||||
declare var icall: ICall;
|
||||
|
||||
icall(0);
|
||||
|
||||
icall.call(null, 0);
|
||||
type Callable = { (x: string): void };
|
||||
declare var callable: Callable;
|
||||
|
||||
callable(0);
|
||||
|
||||
callable.call(null, 0);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -77,28 +77,27 @@ module.exports = {
|
|||
class A {
|
||||
static x: number;
|
||||
static y: string;
|
||||
static foo(x: number) {
|
||||
|
||||
static foo(x: number) {}
|
||||
static bar(y: string) {}
|
||||
}
|
||||
static bar(y: string) {
|
||||
|
||||
}
|
||||
}
|
||||
A.qux = function(x: string) {
|
||||
|
||||
};
|
||||
A.qux = function(x: string) {};
|
||||
class B extends A {
|
||||
static x: string;
|
||||
static foo(x: string) {
|
||||
|
||||
}
|
||||
static foo(x: string) {}
|
||||
static main() {
|
||||
B.x = 0;
|
||||
|
||||
B.x = \"\";
|
||||
|
||||
B.foo(0);
|
||||
|
||||
B.foo(\"\");
|
||||
|
||||
B.y = 0;
|
||||
|
||||
B.bar(0);
|
||||
|
||||
B.qux(0);
|
||||
}
|
||||
static create(): A {
|
||||
|
@ -110,9 +109,7 @@ class B extends A {
|
|||
}
|
||||
class C<X> {
|
||||
static x: X;
|
||||
static bar(x: X) {
|
||||
|
||||
}
|
||||
static bar(x: X) {}
|
||||
static create(): C<*> {
|
||||
return new this();
|
||||
}
|
||||
|
@ -120,11 +117,14 @@ class C<X> {
|
|||
class D extends C<string> {
|
||||
static main() {
|
||||
D.foo(0);
|
||||
|
||||
D.bar(0);
|
||||
}
|
||||
}
|
||||
var d: C<*> = D.create();
|
||||
|
||||
(new A(): typeof A);
|
||||
|
||||
(B: typeof A);
|
||||
class E {
|
||||
static x: number;
|
||||
|
@ -133,6 +133,7 @@ class E {
|
|||
return this.x;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { A: A, B: B, C: C, D: D, E: E };
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -8,6 +8,7 @@ module.exports = { A, B };
|
|||
/* @flow */
|
||||
class A {}
|
||||
class B {}
|
||||
|
||||
module.exports = { A, B };
|
||||
"
|
||||
`;
|
||||
|
@ -65,16 +66,17 @@ foo(new D, { f_: 0 });
|
|||
class C<X> {
|
||||
x: X;
|
||||
}
|
||||
function foo<X>(c: C<X>, x: X) {
|
||||
|
||||
}
|
||||
function foo<X>(c: C<X>, x: X) {}
|
||||
type O = { f: number };
|
||||
|
||||
foo((new C(): C<O>), { f_: 0 });
|
||||
class D extends C<O> {
|
||||
bar() {
|
||||
this.x;
|
||||
}
|
||||
}
|
||||
|
||||
foo(new D(), { f_: 0 });
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -14,14 +14,14 @@ function bar(x: Class<B>): B {
|
|||
// OK
|
||||
// error (too few args)
|
||||
class A {}
|
||||
|
||||
function foo(x: Class<A>): A {
|
||||
return new x();
|
||||
}
|
||||
class B {
|
||||
constructor(_: any) {
|
||||
constructor(_: any) {}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
function bar(x: Class<B>): B {
|
||||
return new x();
|
||||
}
|
||||
|
@ -51,10 +51,15 @@ declare function check<X>(cls: $Type<X>, inst: X): void;
|
|||
class A {}
|
||||
class B extends A {}
|
||||
class C {}
|
||||
|
||||
check(B, new A());
|
||||
|
||||
check(A, new B());
|
||||
|
||||
check(C, new A());
|
||||
|
||||
check(C, new B());
|
||||
|
||||
check(B, new C());
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -6,10 +6,9 @@ exports[`test A.js 1`] = `
|
|||
module.exports = A;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
class A {
|
||||
foo(x: number): void {
|
||||
foo(x: number): void {}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
module.exports = A;
|
||||
"
|
||||
`;
|
||||
|
@ -28,7 +27,9 @@ module.exports = B;
|
|||
var A = require(\"./A\");
|
||||
class B extends A {}
|
||||
let b = new B();
|
||||
|
||||
(b.foo: number);
|
||||
|
||||
module.exports = B;
|
||||
"
|
||||
`;
|
||||
|
@ -48,12 +49,12 @@ module.exports = C;
|
|||
// error, number !~> function
|
||||
var B = require(\"./B\");
|
||||
class C extends B {
|
||||
foo(x: string): void {
|
||||
|
||||
}
|
||||
foo(x: string): void {}
|
||||
}
|
||||
let c = new C();
|
||||
|
||||
(c.foo: number);
|
||||
|
||||
module.exports = C;
|
||||
"
|
||||
`;
|
||||
|
@ -65,6 +66,7 @@ new E().x
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
class D {}
|
||||
class E {}
|
||||
|
||||
new E().x;
|
||||
"
|
||||
`;
|
||||
|
@ -126,12 +128,18 @@ class TestClass {
|
|||
c: ?string;
|
||||
}
|
||||
var x = new TestClass();
|
||||
|
||||
x.a;
|
||||
|
||||
x.b;
|
||||
|
||||
x.c;
|
||||
|
||||
x.d;
|
||||
var y: Foo = x;
|
||||
|
||||
y.b;
|
||||
|
||||
y.d;
|
||||
class Test2Superclass {
|
||||
a: number;
|
||||
|
@ -249,10 +257,14 @@ declare var o: {p:number};
|
|||
class C {
|
||||
static p: string;
|
||||
}
|
||||
|
||||
C.p = \"hi\";
|
||||
|
||||
(C: { p: string });
|
||||
|
||||
(C: { p: number });
|
||||
declare var o: { p: number };
|
||||
|
||||
(o: Class<C>);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -104,63 +104,79 @@ function local_meth() {
|
|||
// ok
|
||||
// error
|
||||
// shouldn\'t pollute linear refinement
|
||||
function takes_string(_: string) {
|
||||
|
||||
}
|
||||
function takes_string(_: string) {}
|
||||
var global_x = \"hello\";
|
||||
function global_f() {
|
||||
|
||||
}
|
||||
function global_f() {}
|
||||
|
||||
function global_g() {
|
||||
global_x = 42;
|
||||
}
|
||||
|
||||
global_f();
|
||||
|
||||
takes_string(global_x);
|
||||
|
||||
global_g();
|
||||
|
||||
takes_string(global_x);
|
||||
|
||||
global_x = 42;
|
||||
|
||||
function local_func() {
|
||||
var local_x = \"hello\";
|
||||
function local_f() {
|
||||
|
||||
}
|
||||
function local_f() {}
|
||||
|
||||
function local_g() {
|
||||
local_x = 42;
|
||||
}
|
||||
|
||||
local_f();
|
||||
|
||||
takes_string(local_x);
|
||||
|
||||
local_g();
|
||||
|
||||
takes_string(local_x);
|
||||
|
||||
local_x = 42;
|
||||
}
|
||||
var global_y = \"hello\";
|
||||
var global_o = {
|
||||
f: function() {
|
||||
|
||||
},
|
||||
f: function() {},
|
||||
g: function() {
|
||||
global_y = 42;
|
||||
}
|
||||
};
|
||||
|
||||
global_o.f();
|
||||
|
||||
takes_string(global_y);
|
||||
|
||||
global_o.g();
|
||||
|
||||
takes_string(global_y);
|
||||
|
||||
global_y = 42;
|
||||
|
||||
function local_meth() {
|
||||
var local_y = \"hello\";
|
||||
var local_o = {
|
||||
f: function() {
|
||||
|
||||
},
|
||||
f: function() {},
|
||||
g: function() {
|
||||
local_y = 42;
|
||||
}
|
||||
};
|
||||
|
||||
local_o.f();
|
||||
|
||||
takes_string(local_y);
|
||||
|
||||
local_o.g();
|
||||
|
||||
takes_string(local_y);
|
||||
|
||||
local_y = 42;
|
||||
}
|
||||
"
|
||||
|
@ -188,9 +204,11 @@ function example(b: bool): number {
|
|||
// error, string ~/~> number (return type anno) TODO
|
||||
function example(b: boolean): number {
|
||||
var x = 0;
|
||||
|
||||
function f() {
|
||||
x = \"\";
|
||||
}
|
||||
|
||||
if (b) {
|
||||
f();
|
||||
}
|
||||
|
@ -263,26 +281,30 @@ call_me();
|
|||
// error
|
||||
// error
|
||||
// in a galaxy far far away
|
||||
var call_me: () => void = () => {
|
||||
var call_me: () => void = () => {};
|
||||
|
||||
};
|
||||
function g(x: ?number) {
|
||||
const const_x = x;
|
||||
|
||||
if (const_x) {
|
||||
call_me = () => {
|
||||
var y: number = const_x;
|
||||
};
|
||||
}
|
||||
var var_x = x;
|
||||
|
||||
if (var_x) {
|
||||
call_me = () => {
|
||||
var y: number = var_x;
|
||||
};
|
||||
}
|
||||
|
||||
var_x = null;
|
||||
}
|
||||
|
||||
function h(x: number | string | boolean) {
|
||||
const const_x = x;
|
||||
|
||||
if (typeof const_x == \"number\") {
|
||||
call_me = () => {
|
||||
var y: number = const_x;
|
||||
|
@ -299,6 +321,7 @@ function h(x: number | string | boolean) {
|
|||
};
|
||||
}
|
||||
var var_x = x;
|
||||
|
||||
if (typeof var_x == \"number\") {
|
||||
call_me = () => {
|
||||
var y: number = var_x;
|
||||
|
@ -315,6 +338,7 @@ function h(x: number | string | boolean) {
|
|||
};
|
||||
}
|
||||
}
|
||||
|
||||
call_me();
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -4,9 +4,8 @@ function f(x:string) { }
|
|||
|
||||
module.exports = f;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
function f(x: string) {
|
||||
function f(x: string) {}
|
||||
|
||||
}
|
||||
module.exports = f;
|
||||
"
|
||||
`;
|
||||
|
@ -18,6 +17,7 @@ var f = require(\'./Abs\');
|
|||
f(0);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var f = require(\"./Abs\");
|
||||
|
||||
f(0);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -32,8 +32,11 @@ var ColorIdToNumber = {
|
|||
[ColorId.GREEN]: ColorNumber.GREEN,
|
||||
[ColorId.BLUE]: ColorNumber.BLUE
|
||||
};
|
||||
|
||||
(ColorIdToNumber[ColorId.RED]: \"ffffff\");
|
||||
|
||||
ColorIdToNumber.XXX;
|
||||
|
||||
module.exports = { ColorId, ColorNumber };
|
||||
"
|
||||
`;
|
||||
|
@ -57,7 +60,9 @@ var ColorIdToNumber = {
|
|||
[ColorId.GREEN]: ColorNumber.GREEN,
|
||||
[ColorId.BLUE]: ColorNumber.BLUE
|
||||
};
|
||||
|
||||
(ColorIdToNumber[ColorId.GREEN]: \"ffffff\");
|
||||
|
||||
module.exports = ColorIdToNumber;
|
||||
"
|
||||
`;
|
||||
|
@ -71,6 +76,7 @@ var ColorIdToNumber = require(\'./test2\');
|
|||
// oops
|
||||
var { ColorId } = require(\"./test\");
|
||||
var ColorIdToNumber = require(\"./test2\");
|
||||
|
||||
(ColorIdToNumber[ColorId.BLUE]: \"ffffff\");
|
||||
"
|
||||
`;
|
||||
|
@ -93,6 +99,7 @@ module.exports = {
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var hello = require(\"./test4\");
|
||||
var dummy = require(\"./test\");
|
||||
|
||||
module.exports = { ...dummy, [hello]: \"world\", ...dummy };
|
||||
"
|
||||
`;
|
||||
|
@ -103,6 +110,7 @@ exports[`test test6.js 1`] = `
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// oops
|
||||
var o = require(\"./test5\");
|
||||
|
||||
(o.hello: \"nothing\");
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -32,15 +32,18 @@ function a(): number {
|
|||
var x: ?string = null;
|
||||
return (x ? 1 : 0);
|
||||
}
|
||||
|
||||
function b(): number {
|
||||
var x: ?number = null;
|
||||
return (x != null ? x : 0);
|
||||
}
|
||||
|
||||
function c(): number {
|
||||
var x = false;
|
||||
var temp = (x ? 1 : x);
|
||||
return (temp ? temp : 0);
|
||||
}
|
||||
|
||||
function d(): string {
|
||||
var x: ?number = null;
|
||||
return (x != null ? x : x != null);
|
||||
|
|
|
@ -4,6 +4,7 @@ exports[`test no_at_flow.js 1`] = `
|
|||
x.length;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var x;
|
||||
|
||||
x.length;
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -19,6 +19,7 @@ function foo(x) {
|
|||
var a: number = \"asdf\";
|
||||
return x * 10;
|
||||
}
|
||||
|
||||
foo(\"Hello, world!\");
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -9,7 +9,9 @@ import {name} from \"testproj\";
|
|||
// @flow
|
||||
// Error: Resolve from node_modules first!
|
||||
import { name } from \"testproj\";
|
||||
|
||||
(name: \"node_modules/testproj\");
|
||||
|
||||
(name: \"custom_resolve_dir/testproj\");
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -9,7 +9,9 @@ import {name} from \"testproj2\";
|
|||
// @flow
|
||||
// Error: Resolve from sibling \'custom_resolve_dir\' first!
|
||||
import { name } from \"testproj2\";
|
||||
|
||||
(name: \"node_modules/testproj2\");
|
||||
|
||||
(name: \"subdir/custom_resolve_dir/testproj2\");
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -48,12 +48,14 @@ class A {
|
|||
return \"some string\";
|
||||
}
|
||||
}
|
||||
|
||||
A._sProperty = 48;
|
||||
class B extends A {
|
||||
_property1: string;
|
||||
static _sProperty: string;
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this._property1 = \"another string\";
|
||||
}
|
||||
_method1(): string {
|
||||
|
@ -63,6 +65,7 @@ class B extends A {
|
|||
return 23;
|
||||
}
|
||||
}
|
||||
|
||||
B._sProperty = \"B._sProperty string\";
|
||||
"
|
||||
`;
|
||||
|
@ -80,6 +83,7 @@ module.exports = new C;
|
|||
class C {
|
||||
_p: string;
|
||||
}
|
||||
|
||||
module.exports = new C();
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -48,12 +48,14 @@ class A {
|
|||
return \"some string\";
|
||||
}
|
||||
}
|
||||
|
||||
A._sProperty = 48;
|
||||
class B extends A {
|
||||
_property1: string;
|
||||
static _sProperty: string;
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this._property1 = \"another string\";
|
||||
}
|
||||
_method1(): string {
|
||||
|
@ -63,6 +65,7 @@ class B extends A {
|
|||
return 23;
|
||||
}
|
||||
}
|
||||
|
||||
B._sProperty = \"B._sProperty string\";
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -52,6 +52,7 @@ function durable_refi(x: ?number) {
|
|||
function cannot_reassign(x: string) {
|
||||
x = \"hey\";
|
||||
}
|
||||
|
||||
function durable_refi(x: ?number) {
|
||||
if (x) {
|
||||
return () => {
|
||||
|
|
|
@ -10,15 +10,12 @@ class D {
|
|||
module.exports = C;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
class C {
|
||||
constructor() {
|
||||
|
||||
}
|
||||
constructor() {}
|
||||
}
|
||||
class D {
|
||||
constructor(): number {
|
||||
constructor(): number {}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
module.exports = C;
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -32,12 +32,15 @@ exports.Foo2 = (Foo: Class<IFoo>);
|
|||
function Foo() {
|
||||
this.x = 0;
|
||||
}
|
||||
|
||||
Foo.y = 0;
|
||||
|
||||
Foo.prototype = {
|
||||
m() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
exports.Foo = Foo;
|
||||
interface IFooPrototype { m(): number }
|
||||
interface IFoo extends IFooPrototype {
|
||||
|
@ -45,6 +48,7 @@ interface IFoo extends IFooPrototype {
|
|||
x: boolean;
|
||||
static y: boolean
|
||||
}
|
||||
|
||||
exports.Foo2 = (Foo: Class<IFoo>);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -11,6 +11,7 @@ xxx
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
require(\"./dummy\");
|
||||
var xxx = 0;
|
||||
|
||||
xxx;
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -11,6 +11,7 @@ xxx
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
require(\"./dummy\");
|
||||
var xxx = 0;
|
||||
|
||||
xxx;
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -51,18 +51,27 @@ let tests = [
|
|||
let tests = [
|
||||
function() {
|
||||
new Boolean();
|
||||
|
||||
new Boolean(0);
|
||||
|
||||
new Boolean(-0);
|
||||
|
||||
new Boolean(null);
|
||||
|
||||
new Boolean(false);
|
||||
|
||||
new Boolean(NaN);
|
||||
|
||||
new Boolean(undefined);
|
||||
|
||||
new Boolean(\"\");
|
||||
},
|
||||
function() {
|
||||
true.toString();
|
||||
let x: boolean = false;
|
||||
|
||||
x.toString();
|
||||
|
||||
new Boolean(true).toString();
|
||||
},
|
||||
function() {
|
||||
|
@ -70,12 +79,19 @@ let tests = [
|
|||
},
|
||||
function() {
|
||||
Boolean();
|
||||
|
||||
Boolean(0);
|
||||
|
||||
Boolean(-0);
|
||||
|
||||
Boolean(null);
|
||||
|
||||
Boolean(false);
|
||||
|
||||
Boolean(NaN);
|
||||
|
||||
Boolean(undefined);
|
||||
|
||||
Boolean(\"\");
|
||||
}
|
||||
];
|
||||
|
@ -145,6 +161,7 @@ let tests = [
|
|||
},
|
||||
function(x: Map<string, number>) {
|
||||
(x.get(\"foo\"): boolean);
|
||||
|
||||
x.get(123);
|
||||
}
|
||||
];
|
||||
|
@ -195,22 +212,33 @@ let tests = [
|
|||
let tests = [
|
||||
function() {
|
||||
new RegExp(\"foo\");
|
||||
|
||||
new RegExp(/foo/);
|
||||
|
||||
new RegExp(\"foo\", \"i\");
|
||||
|
||||
new RegExp(\"foo\", \"ig\");
|
||||
|
||||
new RegExp(/foo/, \"i\");
|
||||
|
||||
new RegExp(/foo/g, \"i\");
|
||||
},
|
||||
function() {
|
||||
RegExp(\"foo\");
|
||||
|
||||
RegExp(/foo/);
|
||||
|
||||
RegExp(\"foo\", \"i\");
|
||||
|
||||
RegExp(\"foo\", \"ig\");
|
||||
|
||||
RegExp(/foo/, \"i\");
|
||||
|
||||
RegExp(/foo/g, \"i\");
|
||||
},
|
||||
function() {
|
||||
RegExp(\"foo\", \"z\");
|
||||
|
||||
new RegExp(\"foo\", \"z\");
|
||||
}
|
||||
];
|
||||
|
@ -261,23 +289,34 @@ let ws5 = new WeakSet(numbers()); // error, must be objects
|
|||
let ws = new WeakSet();
|
||||
let obj: Object = {};
|
||||
let dict: { foo: string } = { foo: \"bar\" };
|
||||
|
||||
ws.add(window);
|
||||
|
||||
ws.add(obj);
|
||||
|
||||
ws.add(dict);
|
||||
|
||||
ws.has(window);
|
||||
|
||||
ws.has(obj);
|
||||
|
||||
ws.has(dict);
|
||||
|
||||
ws.delete(window);
|
||||
|
||||
ws.delete(obj);
|
||||
|
||||
ws.delete(dict);
|
||||
let ws2 = new WeakSet([ obj, dict ]);
|
||||
let ws3 = new WeakSet([ 1, 2, 3 ]);
|
||||
|
||||
function* generator(): Iterable<{ foo: string }> {
|
||||
while (true) {
|
||||
yield { foo: \"bar\" };
|
||||
}
|
||||
}
|
||||
let ws4 = new WeakSet(generator());
|
||||
|
||||
function* numbers(): Iterable<number> {
|
||||
let i = 0;
|
||||
while (true) {
|
||||
|
|
|
@ -89,6 +89,7 @@ n.x = [0];
|
|||
type CovArrayVerbose<X, Y: X> = Array<Y>;
|
||||
var b: CovArrayVerbose<number, *> = [];
|
||||
var y: CovArrayVerbose<mixed, *> = b;
|
||||
|
||||
y[0] = \"\";
|
||||
class NVerbose<E, I: E> {
|
||||
x: CovArrayVerbose<E, I>;
|
||||
|
@ -97,8 +98,11 @@ class NVerbose<E, I: E> {
|
|||
}
|
||||
}
|
||||
var nv: NVerbose<number, *> = new NVerbose();
|
||||
|
||||
nv.x = [ 0 ];
|
||||
|
||||
(nv.x[0]: string);
|
||||
|
||||
(nv.foo()[0]: string);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -15,12 +15,8 @@ declare module bar {
|
|||
// that we implicitly assume in type-at-pos and coverage implementations. In
|
||||
// particular, when unchecked it causes a crash with coverage --color.
|
||||
// TODO
|
||||
declare module foo {
|
||||
|
||||
}
|
||||
declare module bar {
|
||||
|
||||
}
|
||||
declare module foo {}
|
||||
declare module bar {}
|
||||
"
|
||||
`;
|
||||
|
||||
|
@ -31,9 +27,7 @@ declare module foo {
|
|||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// check coverage of declare module
|
||||
declare module foo {
|
||||
|
||||
}
|
||||
declare module foo {}
|
||||
"
|
||||
`;
|
||||
|
||||
|
@ -42,6 +36,7 @@ exports[`test no_pragma.js 1`] = `
|
|||
(x: string);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
let x = 0;
|
||||
|
||||
(x: string);
|
||||
"
|
||||
`;
|
||||
|
@ -66,12 +61,8 @@ declare class qux {
|
|||
// that we implicitly assume in type-at-pos and coverage implementations. In
|
||||
// particular, when unchecked it causes non-termination with coverage --color.
|
||||
// TODO
|
||||
declare module foo {
|
||||
|
||||
}
|
||||
declare module bar {
|
||||
|
||||
}
|
||||
declare module foo {}
|
||||
declare module bar {}
|
||||
declare class qux {}
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -7,6 +7,7 @@ module.exports = A;
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var B = require(\"./B\");
|
||||
class A extends B {}
|
||||
|
||||
module.exports = A;
|
||||
"
|
||||
`;
|
||||
|
@ -20,6 +21,7 @@ module.exports = B;
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//class B extends A { }
|
||||
var A = require(\"./A\");
|
||||
|
||||
module.exports = B;
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -34,23 +34,41 @@ new Date(2015, 6, 18, 11, 55, 42, 999, \'hahaha\');
|
|||
var d = new Date(0);
|
||||
var x: string = d.getTime();
|
||||
var y: number = d;
|
||||
|
||||
new Date();
|
||||
|
||||
new Date(1234567890);
|
||||
|
||||
new Date(\"2015/06/18\");
|
||||
|
||||
new Date(2015, 6);
|
||||
|
||||
new Date(2015, 6, 18);
|
||||
|
||||
new Date(2015, 6, 18, 11);
|
||||
|
||||
new Date(2015, 6, 18, 11, 55);
|
||||
|
||||
new Date(2015, 6, 18, 11, 55, 42);
|
||||
|
||||
new Date(2015, 6, 18, 11, 55, 42, 999);
|
||||
|
||||
new Date({});
|
||||
|
||||
new Date(2015, \"6\");
|
||||
|
||||
new Date(2015, 6, \"18\");
|
||||
|
||||
new Date(2015, 6, 18, \"11\");
|
||||
|
||||
new Date(2015, 6, 18, 11, \"55\");
|
||||
|
||||
new Date(2015, 6, 18, 11, 55, \"42\");
|
||||
|
||||
new Date(2015, 6, 18, 11, 55, 42, \"999\");
|
||||
|
||||
new Date(\"2015\", 6);
|
||||
|
||||
new Date(2015, 6, 18, 11, 55, 42, 999, \"hahaha\");
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -68,10 +68,13 @@ var ExplicitDifferentName = require(\'ExplicitProvidesModuleDifferentName\');
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
var Implicit = require(\"ImplicitProvidesModule\");
|
||||
|
||||
(Implicit.fun(): string);
|
||||
var ExplicitSameName = require(\"ExplicitProvidesModuleSameName\");
|
||||
|
||||
(ExplicitSameName.fun(): string);
|
||||
var ExplicitDifferentName = require(\"ExplicitProvidesModuleDifferentName\");
|
||||
|
||||
(ExplicitDifferentName.fun(): string);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -20,8 +20,11 @@ var docblock = require(\"qux/docblock\");
|
|||
var min = require(\"d3/min.js\");
|
||||
var corge = require(\"qux/corge\");
|
||||
var unreachable = require(\"annotation\");
|
||||
|
||||
(docblock.fun(): string);
|
||||
|
||||
(min.fun(): string);
|
||||
|
||||
(corge.fun(): string);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -25,6 +25,7 @@ module.exports.fun = (): Implementation => new Implementation;
|
|||
* @flow
|
||||
*/
|
||||
class Implementation {}
|
||||
|
||||
module.exports.fun = (): Implementation => new Implementation();
|
||||
"
|
||||
`;
|
||||
|
@ -43,6 +44,7 @@ module.exports.fun = (): Implementation => new Implementation;
|
|||
* @flow
|
||||
*/
|
||||
class Implementation {}
|
||||
|
||||
module.exports.fun = (): Implementation => new Implementation();
|
||||
"
|
||||
`;
|
||||
|
@ -61,6 +63,7 @@ module.exports.fun = (): Implementation => new Implementation;
|
|||
* @flow
|
||||
*/
|
||||
class Implementation {}
|
||||
|
||||
module.exports.fun = (): Implementation => new Implementation();
|
||||
"
|
||||
`;
|
||||
|
@ -90,10 +93,13 @@ var ExplicitDifferentName = require(\'ExplicitProvidesModuleDifferentName\');
|
|||
// Error: Either Implementation ~> boolean or Declaration ~> boolean
|
||||
// Error: Either Implementation ~> boolean or Declaration ~> boolean
|
||||
var Implicit = require(\"ImplicitProvidesModule\");
|
||||
|
||||
(Implicit.fun(): boolean);
|
||||
var ExplicitSameName = require(\"ExplicitProvidesModuleSameName\");
|
||||
|
||||
(ExplicitSameName.fun(): boolean);
|
||||
var ExplicitDifferentName = require(\"ExplicitProvidesModuleDifferentName\");
|
||||
|
||||
(ExplicitDifferentName.fun(): boolean);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -3,6 +3,7 @@ exports[`test min.js 1`] = `
|
|||
module.exports.fun = (): Implementation => new Implementation;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
class Implementation {}
|
||||
|
||||
module.exports.fun = (): Implementation => new Implementation();
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -16,8 +16,11 @@ var corge = require(\'qux/corge\');
|
|||
var docblock = require(\"qux/docblock\");
|
||||
var min = require(\"d3/min.js\");
|
||||
var corge = require(\"qux/corge\");
|
||||
|
||||
(docblock.fun(): boolean);
|
||||
|
||||
(min.fun(): boolean);
|
||||
|
||||
(corge.fun(): boolean);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -70,28 +70,40 @@ var F = require(\'package_with_dir_main\');
|
|||
// Error either Implementation ~> boolean or Declaration ~> boolean
|
||||
// Error either Implementation ~> boolean or Declaration ~> boolean
|
||||
var B1 = require(\"B\");
|
||||
|
||||
(B1.fun(): boolean);
|
||||
var B2 = require(\"B.js\");
|
||||
|
||||
(B2.fun(): boolean);
|
||||
var C = require(\"package_with_full_main\");
|
||||
|
||||
(C.fun(): boolean);
|
||||
var D = require(\"package_with_partial_main\");
|
||||
|
||||
(D.fun(): boolean);
|
||||
var E = require(\"package_with_no_package_json\");
|
||||
|
||||
(E.fun(): boolean);
|
||||
var F = require(\"package_with_dir_main\");
|
||||
|
||||
(F.fun(): boolean);
|
||||
var B1 = require(\"B\");
|
||||
|
||||
(B1.fun(): boolean);
|
||||
var B2 = require(\"B.js\");
|
||||
|
||||
(B2.fun(): boolean);
|
||||
var C = require(\"package_with_full_main\");
|
||||
|
||||
(C.fun(): boolean);
|
||||
var D = require(\"package_with_partial_main\");
|
||||
|
||||
(D.fun(): boolean);
|
||||
var E = require(\"package_with_no_package_json\");
|
||||
|
||||
(E.fun(): boolean);
|
||||
var F = require(\"package_with_dir_main\");
|
||||
|
||||
(F.fun(): boolean);
|
||||
"
|
||||
`;
|
||||
|
@ -103,6 +115,7 @@ exports[`test test_relative.js 1`] = `
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Error: either Implementation ~> boolean or Definition ~> boolean
|
||||
import { foo } from \"./A\";
|
||||
|
||||
(foo(): boolean);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -50,16 +50,22 @@ var F = require(\'package_with_dir_main\');
|
|||
// Error number ~> string
|
||||
// Error number ~> string
|
||||
var B1 = require(\"B\");
|
||||
|
||||
(B1.fun(): string);
|
||||
var B2 = require(\"B.js\");
|
||||
|
||||
(B2.fun(): string);
|
||||
var C = require(\"package_with_full_main\");
|
||||
|
||||
(C.fun(): string);
|
||||
var D = require(\"package_with_partial_main\");
|
||||
|
||||
(D.fun(): string);
|
||||
var E = require(\"package_with_no_package_json\");
|
||||
|
||||
(E.fun(): string);
|
||||
var F = require(\"package_with_dir_main\");
|
||||
|
||||
(F.fun(): string);
|
||||
"
|
||||
`;
|
||||
|
@ -86,11 +92,15 @@ var CJS = require(\'./CJS.js\');
|
|||
// Error number ~> string
|
||||
// Error: string ~> number
|
||||
var A1 = require(\"./A\");
|
||||
|
||||
(A1.fun(): string);
|
||||
var A2 = require(\"./A.js\");
|
||||
|
||||
(A2.fun(): string);
|
||||
var CJS = require(\"./CJS.js\");
|
||||
|
||||
(CJS: string);
|
||||
|
||||
(CJS: number);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -12,9 +12,13 @@ C.foo(\"\");
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// error, it\'s a string
|
||||
declare class C { static x: number; static foo(x: number): void }
|
||||
|
||||
C.x = \"\";
|
||||
|
||||
C.foo(\"\");
|
||||
|
||||
(C.name: string);
|
||||
|
||||
(C.name: number);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -64,6 +64,7 @@ class Test extends Base {
|
|||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Test;
|
||||
"
|
||||
`;
|
||||
|
@ -113,9 +114,13 @@ exports.numberValue5 = 5;
|
|||
* @flow
|
||||
*/
|
||||
exports.numberValue1 = 1;
|
||||
|
||||
exports.numberValue2 = 2;
|
||||
|
||||
exports.numberValue3 = 3;
|
||||
|
||||
exports.numberValue4 = 4;
|
||||
|
||||
exports.numberValue5 = 5;
|
||||
"
|
||||
`;
|
||||
|
@ -488,9 +493,13 @@ exports.stringValue = \"str\";
|
|||
* @flow
|
||||
*/
|
||||
exports.numberValue1 = 42;
|
||||
|
||||
exports.numberValue2 = 42;
|
||||
|
||||
exports.numberValue3 = 42;
|
||||
|
||||
exports.numberValue4 = 42;
|
||||
|
||||
exports.stringValue = \"str\";
|
||||
"
|
||||
`;
|
||||
|
@ -981,23 +990,28 @@ var d2: string = numVal1;
|
|||
import CJS_Clobb_Lit from \"CommonJS_Clobbering_Lit\";
|
||||
var e1: number = CJS_Clobb_Lit.numberValue3;
|
||||
var e2: string = CJS_Clobb_Lit.numberValue3;
|
||||
|
||||
CJS_Clobb_Lit.doesntExist;
|
||||
import * as CJS_Clobb_Lit_NS from \"CommonJS_Clobbering_Lit\";
|
||||
var f1: number = CJS_Clobb_Lit_NS.numberValue4;
|
||||
var f2: number = CJS_Clobb_Lit_NS.default.numberValue4;
|
||||
|
||||
CJS_Clobb_Lit_NS.default.default;
|
||||
var f3: string = CJS_Clobb_Lit_NS.numberValue4;
|
||||
var f4: string = CJS_Clobb_Lit_NS.default.numberValue5;
|
||||
import { doesntExist2 } from \"CommonJS_Clobbering_Class\";
|
||||
import { staticNumber1, baseProp, childProp } from \"CommonJS_Clobbering_Class\";
|
||||
import CJS_Clobb_Class from \"CommonJS_Clobbering_Class\";
|
||||
|
||||
new CJS_Clobb_Class();
|
||||
|
||||
new CJS_Clobb_Class().doesntExist;
|
||||
var h1: number = CJS_Clobb_Class.staticNumber2();
|
||||
var h2: string = CJS_Clobb_Class.staticNumber2();
|
||||
var h3: number = new CJS_Clobb_Class().instNumber1();
|
||||
var h4: string = new CJS_Clobb_Class().instNumber1();
|
||||
import * as CJS_Clobb_Class_NS from \"CommonJS_Clobbering_Class\";
|
||||
|
||||
new CJS_Clobb_Class_NS();
|
||||
var i1: number = CJS_Clobb_Class_NS.staticNumber3();
|
||||
var i2: number = new CJS_Clobb_Class_NS.default().instNumber2();
|
||||
|
@ -1012,6 +1026,7 @@ var k2: string = numVal3;
|
|||
import * as CJS_Named from \"CommonJS_Named\";
|
||||
var l1: number = CJS_Named.numberValue1;
|
||||
var l2: string = CJS_Named.numberValue1;
|
||||
|
||||
CJS_Named.doesntExist;
|
||||
import * as CJS_Named_NS from \"CommonJS_Named\";
|
||||
var m1: number = CJS_Named_NS.numberValue4;
|
||||
|
@ -1062,6 +1077,7 @@ var ab2: string = numberValue2_renamed;
|
|||
import { numberValue1 as numberValue5 } from \"ES6_ExportAllFrom_Intermediary1\";
|
||||
var ac1: number = numberValue5;
|
||||
var ac2: string = numberValue5;
|
||||
|
||||
require(\"ES6_Default_AnonFunction2\").doesntExist;
|
||||
var ES6_Def_AnonFunc2 = require(\"ES6_Default_AnonFunction2\").default;
|
||||
var ad1: number = ES6_Def_AnonFunc2();
|
||||
|
|
|
@ -13,8 +13,11 @@ declare function foo<X>(x: X): X;
|
|||
declare function foo(x: number): string;
|
||||
declare function foo(x: string): number;
|
||||
declare function foo<X>(x: X): X;
|
||||
|
||||
(foo(0): string);
|
||||
|
||||
(foo(\"hello\"): number);
|
||||
|
||||
(foo(false): void);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -36,17 +36,25 @@ import declare_m_e_with_declare_var_e from \"declare_m_e_with_declare_var_e\";
|
|||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
import declare_module_exports from \"declare_module_exports\";
|
||||
|
||||
(declare_module_exports: number);
|
||||
|
||||
(declare_module_exports: string);
|
||||
import { str } from \"declare_m_e_with_other_value_declares\";
|
||||
import type { str2 } from \"declare_m_e_with_other_type_declares\";
|
||||
|
||||
(\"asdf\": str2);
|
||||
|
||||
(42: str2);
|
||||
import DEPRECATED__declare_var_exports from \"DEPRECATED__declare_var_exports\";
|
||||
|
||||
(DEPRECATED__declare_var_exports: number);
|
||||
|
||||
(DEPRECATED__declare_var_exports: string);
|
||||
import declare_m_e_with_declare_var_e from \"declare_m_e_with_declare_var_e\";
|
||||
|
||||
(declare_m_e_with_declare_var_e: number);
|
||||
|
||||
(declare_m_e_with_declare_var_e: string);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -54,9 +54,13 @@ import type { toz } from \"ModuleAliasFoo\";
|
|||
var k4: toz = foo(k1);
|
||||
import blah from \"foo\";
|
||||
import type { Foo, Bar, Id } from \"foo\";
|
||||
|
||||
blah(0, 0);
|
||||
|
||||
({ toz: 3 }: Foo);
|
||||
|
||||
(3: Bar);
|
||||
|
||||
(\"lol\": Id<number>);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -55,8 +55,10 @@ class Variance<+Out, -In> {
|
|||
}
|
||||
class A {}
|
||||
class B extends A {}
|
||||
|
||||
function subtyping(v1: Variance<A, B>, v2: Variance<B, A>) {
|
||||
(v1: Variance<B, A>);
|
||||
|
||||
(v2: Variance<A, B>);
|
||||
}
|
||||
class PropVariance<+Out, -In> {
|
||||
|
|
|
@ -14,6 +14,7 @@ function f(x) {
|
|||
return 42 / x;
|
||||
}
|
||||
var x = null;
|
||||
|
||||
f(x);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -33,11 +33,14 @@ class A {
|
|||
return callback(this.getX());
|
||||
}
|
||||
}
|
||||
|
||||
function callback(x: string) {
|
||||
return x.length;
|
||||
}
|
||||
var a = new A(42);
|
||||
|
||||
a.onLoad(callback);
|
||||
|
||||
module.exports = A;
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -19,8 +19,11 @@ require(\'./F\');
|
|||
require(\'./G\');
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
require(\"./D\");
|
||||
|
||||
require(\"./E\");
|
||||
|
||||
require(\"./F\");
|
||||
|
||||
require(\"./G\");
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -23,9 +23,13 @@ let [ a, ...ys ] = xs;
|
|||
let [ b, ...zs ] = ys;
|
||||
let c = zs[0];
|
||||
let d = zs[1];
|
||||
|
||||
(a: void);
|
||||
|
||||
(b: void);
|
||||
|
||||
(c: void);
|
||||
|
||||
(d: void);
|
||||
let [ ...e ] = 0;
|
||||
"
|
||||
|
@ -46,11 +50,14 @@ var { [\"key\"]: val3, ...spread } = { key: \"val\" };
|
|||
// ok (gasp!) by existing StrT -> ElemT rule
|
||||
// error (gasp!) in general we don\'t know if a computed prop should be excluded from spread
|
||||
var { [\"key\"]: val1 } = { key: \"val\" };
|
||||
|
||||
(val1: void);
|
||||
var key: string = \"key\";
|
||||
var { [key]: val2 } = { key: \"val\" };
|
||||
|
||||
(val2: void);
|
||||
var { [\"key\"]: val3, ...spread } = { key: \"val\" };
|
||||
|
||||
(spread.key: void);
|
||||
"
|
||||
`;
|
||||
|
@ -183,64 +190,75 @@ function default_expr_scope({a, b = a}) {}
|
|||
function obj_prop_fun({ p: { q = 0 } = { q: true } } = { p: { q: \"\" } }) {
|
||||
(q: void);
|
||||
}
|
||||
|
||||
obj_prop_fun();
|
||||
|
||||
obj_prop_fun({});
|
||||
|
||||
obj_prop_fun({ p: {} });
|
||||
|
||||
obj_prop_fun({ p: { q: null } });
|
||||
|
||||
function obj_prop_var(o = { p: { q: \"\" } }) {
|
||||
var { p: { q = 0 } = { q: true } } = o;
|
||||
|
||||
(q: void);
|
||||
}
|
||||
|
||||
obj_prop_var();
|
||||
|
||||
obj_prop_var({});
|
||||
|
||||
obj_prop_var({ p: {} });
|
||||
|
||||
obj_prop_var({ p: { q: null } });
|
||||
|
||||
function obj_rest(
|
||||
{ p: { q, ...o } = { q: 0, r: 0 } } = { p: { q: 0, r: \"\" } }
|
||||
) {
|
||||
(o.r: void);
|
||||
}
|
||||
|
||||
obj_rest();
|
||||
|
||||
obj_rest({});
|
||||
|
||||
obj_rest({ p: {} });
|
||||
|
||||
obj_rest({ p: { q: 0, r: null } });
|
||||
|
||||
function obj_prop_annot({ p = true }: { p: string } = { p: 0 }) {
|
||||
(p: void);
|
||||
}
|
||||
var { p = true }: { p: string } = { p: 0 };
|
||||
|
||||
(p: void);
|
||||
function obj_prop_err({ x: { y } } = null) {
|
||||
|
||||
}
|
||||
function obj_rest_err({ ...o } = 0) {
|
||||
function obj_prop_err({ x: { y } } = null) {}
|
||||
|
||||
}
|
||||
function arr_elem_err([ x ] = null) {
|
||||
function obj_rest_err({ ...o } = 0) {}
|
||||
|
||||
}
|
||||
function arr_rest_err([ ...a ] = null) {
|
||||
function arr_elem_err([ x ] = null) {}
|
||||
|
||||
function arr_rest_err([ ...a ] = null) {}
|
||||
|
||||
}
|
||||
function gen<T>(x: T, { p = x }: { p: T }): T {
|
||||
return p;
|
||||
}
|
||||
|
||||
obj_prop_fun(({}: { p?: { q?: null } }));
|
||||
|
||||
obj_prop_var(({}: { p?: { q?: null } }));
|
||||
function obj_prop_opt({ p }: { p?: string } = { p: 0 }) {
|
||||
|
||||
}
|
||||
function obj_prop_maybe({ p }: { p: ?string } = { p: 0 }) {
|
||||
function obj_prop_opt({ p }: { p?: string } = { p: 0 }) {}
|
||||
|
||||
}
|
||||
function obj_prop_union({ p }: { p: number | string } = { p: true }) {
|
||||
function obj_prop_maybe({ p }: { p: ?string } = { p: 0 }) {}
|
||||
|
||||
}
|
||||
function obj_prop_union2({ p }: { p: number } | { p: string } = { p: true }) {
|
||||
function obj_prop_union({ p }: { p: number | string } = { p: true }) {}
|
||||
|
||||
}
|
||||
function default_expr_scope({ a, b = a }) {
|
||||
function obj_prop_union2({ p }: { p: number } | { p: string } = { p: true }) {}
|
||||
|
||||
}
|
||||
function default_expr_scope({ a, b = a }) {}
|
||||
"
|
||||
`;
|
||||
|
||||
|
@ -328,44 +346,60 @@ var cp2_err: string = others.childprop2; // Error: number ~> string
|
|||
declare var a: string;
|
||||
declare var b: string;
|
||||
declare var c: string;
|
||||
|
||||
[ { a1: a, b }, c ] = [ { a1: 0, b: 1 }, 2 ];
|
||||
var { m } = { m: 0 };
|
||||
|
||||
({ m } = { m: m });
|
||||
var obj;
|
||||
|
||||
({ n: obj.x } = { n: 3 });
|
||||
|
||||
[ obj.x ] = [ \"foo\" ];
|
||||
|
||||
function foo({ p, z: [ r ] }) {
|
||||
a = p;
|
||||
|
||||
b = z;
|
||||
|
||||
c = r;
|
||||
}
|
||||
|
||||
foo({ p: 0, z: [ 1, 2 ] });
|
||||
|
||||
[ a, , b, ...c ] = [ 0, 1, true, 3 ];
|
||||
|
||||
function bar({ x, ...z }) {
|
||||
var o: { x: string; y: number } = z;
|
||||
}
|
||||
|
||||
bar({ x: \"\", y: 0 });
|
||||
var spread = { y: \"\" };
|
||||
var extend: { x: number; y: string; z: boolean } = { x: 0, ...spread };
|
||||
function qux(_: { a: number }) {
|
||||
|
||||
}
|
||||
function qux(_: { a: number }) {}
|
||||
|
||||
qux({ a: \"\" });
|
||||
function corge({ b }: { b: string }) {
|
||||
|
||||
}
|
||||
function corge({ b }: { b: string }) {}
|
||||
|
||||
corge({ b: 0 });
|
||||
var { n }: { n: number } = { n: \"\" };
|
||||
|
||||
function test() {
|
||||
var { foo } = { bar: 123 };
|
||||
var { bar, baz } = { bar: 123 };
|
||||
}
|
||||
|
||||
function test() {
|
||||
var x = { foo: \"abc\", bar: 123 };
|
||||
var { foo, ...rest } = x;
|
||||
|
||||
(x.baz: string);
|
||||
|
||||
(rest.baz: string);
|
||||
}
|
||||
|
||||
module.exports = corge;
|
||||
class Base {
|
||||
baseprop1: number;
|
||||
|
@ -420,6 +454,7 @@ exports[`test eager.js 1`] = `
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// error, property \`x\` can not be accessed on \`null\`
|
||||
var x;
|
||||
|
||||
({ x } = null);
|
||||
"
|
||||
`;
|
||||
|
@ -471,44 +506,39 @@ function arr_rest_pattern<X>([ _, ...a ] : ArrRest<X>) { // a: [X]
|
|||
// o: { x: X }
|
||||
// a: [X]
|
||||
// a: [X]
|
||||
function obj_pattern<X>({ prop }: { prop: X }) {
|
||||
|
||||
}
|
||||
function obj_pattern<X>({ prop }: { prop: X }) {}
|
||||
type Prop<X> = { prop: X };
|
||||
function obj_pattern2<X>({ prop }: Prop<X>) {
|
||||
|
||||
}
|
||||
function arr_pattern<X>([ elem ]: X[]) {
|
||||
function obj_pattern2<X>({ prop }: Prop<X>) {}
|
||||
|
||||
}
|
||||
function arr_pattern<X>([ elem ]: X[]) {}
|
||||
type Elem<X> = X[];
|
||||
function arr_pattern2<X>([ elem ]: Elem<X>) {
|
||||
|
||||
}
|
||||
function tup_pattern<X>([ proj ]: [X]) {
|
||||
function arr_pattern2<X>([ elem ]: Elem<X>) {}
|
||||
|
||||
}
|
||||
function tup_pattern<X>([ proj ]: [X]) {}
|
||||
type Proj<X> = [X];
|
||||
function tup_pattern2<X>([ proj ]: Proj<X>) {
|
||||
|
||||
}
|
||||
function rest_antipattern<T>(...t: T) {
|
||||
function tup_pattern2<X>([ proj ]: Proj<X>) {}
|
||||
|
||||
}
|
||||
function rest_pattern<X>(...r: X[]) {
|
||||
function rest_antipattern<T>(...t: T) {}
|
||||
|
||||
function rest_pattern<X>(...r: X[]) {}
|
||||
|
||||
}
|
||||
function obj_rest_pattern<X>({ _, ...o }: { _: any; x: X }) {
|
||||
o.x;
|
||||
}
|
||||
type ObjRest<X> = { _: any; x: X };
|
||||
|
||||
function obj_rest_pattern<X>({ _, ...o }: ObjRest<X>) {
|
||||
o.x;
|
||||
}
|
||||
|
||||
function arr_rest_pattern<X>([ _, ...a ]: [any, X]) {
|
||||
a[0];
|
||||
}
|
||||
type ArrRest<X> = [any, X];
|
||||
|
||||
function arr_rest_pattern<X>([ _, ...a ]: ArrRest<X>) {
|
||||
a[0];
|
||||
}
|
||||
|
@ -546,6 +576,7 @@ const bar = (i: number) => {
|
|||
[ i ] = foo(i);
|
||||
return [ i ];
|
||||
};
|
||||
|
||||
foo = (i: number) => {
|
||||
return bar(i);
|
||||
};
|
||||
|
@ -564,8 +595,10 @@ var { \"with-dash\": with_dash } = { \"with-dash\": \"motivating example\" };
|
|||
// error: string ~> void
|
||||
// ok
|
||||
var { \"key\": val } = { key: \"val\" };
|
||||
|
||||
(val: void);
|
||||
var { \"with-dash\": with_dash } = { \"with-dash\": \"motivating example\" };
|
||||
|
||||
(with_dash: \"motivating example\");
|
||||
"
|
||||
`;
|
||||
|
@ -583,6 +616,7 @@ function bar() {
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
var { x } = { x: { foo: \"foo\" } };
|
||||
|
||||
function bar() {
|
||||
x.bar;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ function foo0(x: Array<{ [key: string]: mixed }>): Array<{
|
|||
x[0].fooBar = \"foobar\";
|
||||
return x;
|
||||
}
|
||||
|
||||
function foo2(x: { [key: string]: number }): {
|
||||
[key: string]: number;
|
||||
+toString: () => string
|
||||
|
@ -503,35 +504,51 @@ class B extends A {}
|
|||
class C extends B {}
|
||||
class X {}
|
||||
class Y {}
|
||||
|
||||
function set_prop_to_string_key(o: { [k: string]: any }) {
|
||||
o.prop = \"ok\";
|
||||
}
|
||||
|
||||
function unsound_dict_has_every_key(o: { [k: string]: X }) {
|
||||
(o.p: X);
|
||||
|
||||
(o[\"p\"]: X);
|
||||
}
|
||||
|
||||
function set_prop_covariant(o: { [k: string]: B }) {
|
||||
o.p = new A();
|
||||
|
||||
o.p = new B();
|
||||
|
||||
o.p = new C();
|
||||
}
|
||||
|
||||
function get_prop_contravariant(o: { [k: string]: B }) {
|
||||
(o.p: A);
|
||||
|
||||
(o.p: B);
|
||||
|
||||
(o.p: C);
|
||||
}
|
||||
|
||||
function add_prop_to_nonstring_key_dot(o: { [k: number]: any }) {
|
||||
o.prop = \"err\";
|
||||
}
|
||||
|
||||
function add_prop_to_nonstring_key_bracket(o: { [k: number]: any }) {
|
||||
o[0] = \"ok\";
|
||||
}
|
||||
|
||||
function mix_with_declared_props(o: { [k: number]: X; p: Y }, x: X, y: Y) {
|
||||
(o[0]: X);
|
||||
|
||||
(o.p: Y);
|
||||
|
||||
o[0] = x;
|
||||
|
||||
o.p = y;
|
||||
}
|
||||
|
||||
function object_prototype(o: { [k: string]: number }): {
|
||||
[k: string]: number;
|
||||
+toString: () => string
|
||||
|
@ -539,132 +556,171 @@ function object_prototype(o: { [k: string]: number }): {
|
|||
(o.toString(): boolean);
|
||||
return o;
|
||||
}
|
||||
|
||||
function unsound_string_conversion_alias_declared_prop(
|
||||
o: { [k: number]: any; \"0\": X }
|
||||
) {
|
||||
o[0] = \"not-x\";
|
||||
}
|
||||
|
||||
function unification_dict_values_invariant(x: Array<{ [k: string]: B }>) {
|
||||
let a: Array<{ [k: string]: A }> = x;
|
||||
|
||||
a[0].p = new A();
|
||||
let b: Array<{ [k: string]: B }> = x;
|
||||
let c: Array<{ [k: string]: C }> = x;
|
||||
|
||||
(x[0].p: C);
|
||||
}
|
||||
|
||||
function subtype_dict_values_invariant(x: { [k: string]: B }) {
|
||||
let a: { [k: string]: A } = x;
|
||||
|
||||
a.p = new A();
|
||||
let b: { [k: string]: B } = x;
|
||||
let c: { [k: string]: C } = x;
|
||||
|
||||
(x.p: C);
|
||||
}
|
||||
|
||||
function subtype_dict_values_fresh_exception() {
|
||||
let a: { [k: string]: A } = { a: new A(), b: new B(), c: new C() };
|
||||
let b: { [k: string]: B } = { a: new A(), b: new B(), c: new C() };
|
||||
let c: { [k: string]: C } = { a: new A(), b: new B(), c: new C() };
|
||||
}
|
||||
|
||||
function unification_dict_keys_invariant(x: Array<{ [k: B]: any }>) {
|
||||
let a: Array<{ [k: A]: any }> = x;
|
||||
let b: Array<{ [k: B]: any }> = x;
|
||||
let c: Array<{ [k: C]: any }> = x;
|
||||
}
|
||||
|
||||
function subtype_dict_keys_invariant(x: { [k: B]: any }) {
|
||||
let a: { [k: A]: any } = x;
|
||||
let b: { [k: B]: any } = x;
|
||||
let c: { [k: C]: any } = x;
|
||||
}
|
||||
|
||||
function unification_mix_with_declared_props_invariant_l(
|
||||
x: Array<{ [k: string]: B }>
|
||||
) {
|
||||
let a: Array<{ [k: string]: B; p: A }> = x;
|
||||
|
||||
a[0].p = new A();
|
||||
let b: Array<{ [k: string]: B; p: B }> = x;
|
||||
let c: Array<{ [k: string]: B; p: C }> = x;
|
||||
|
||||
(x[0].p: C);
|
||||
}
|
||||
|
||||
function unification_mix_with_declared_props_invariant_r(
|
||||
xa: Array<{ [k: string]: A; p: B }>,
|
||||
xb: Array<{ [k: string]: B; p: B }>,
|
||||
xc: Array<{ [k: string]: C; p: B }>
|
||||
) {
|
||||
let a: Array<{ [k: string]: A }> = xa;
|
||||
|
||||
a[0].p = new A();
|
||||
let b: Array<{ [k: string]: B }> = xb;
|
||||
let c: Array<{ [k: string]: C }> = xc;
|
||||
|
||||
(xc[0].p: C);
|
||||
}
|
||||
|
||||
function subtype_mix_with_declared_props_invariant_l(x: { [k: string]: B }) {
|
||||
let a: { [k: string]: B; p: A } = x;
|
||||
|
||||
a.p = new A();
|
||||
let b: { [k: string]: B; p: B } = x;
|
||||
let c: { [k: string]: B; p: C } = x;
|
||||
|
||||
(x.p: C);
|
||||
}
|
||||
|
||||
function subtype_mix_with_declared_props_invariant_r(
|
||||
xa: { [k: string]: A; p: B },
|
||||
xb: { [k: string]: B; p: B },
|
||||
xc: { [k: string]: C; p: B }
|
||||
) {
|
||||
let a: { [k: string]: A } = xa;
|
||||
|
||||
a.p = new A();
|
||||
let b: { [k: string]: B } = xb;
|
||||
let c: { [k: string]: C } = xc;
|
||||
|
||||
(xc.p: C);
|
||||
}
|
||||
|
||||
function unification_dict_to_obj(x: Array<{ [k: string]: X }>): Array<{
|
||||
p: X
|
||||
}> {
|
||||
return x;
|
||||
}
|
||||
|
||||
function unification_obj_to_dict(x: Array<{ p: X }>): Array<{
|
||||
[k: string]: X
|
||||
}> {
|
||||
return x;
|
||||
}
|
||||
|
||||
function subtype_dict_to_obj(x: { [k: string]: B }) {
|
||||
let a: { p: A } = x;
|
||||
|
||||
a.p = new A();
|
||||
let b: { p: B } = x;
|
||||
let c: { p: C } = x;
|
||||
|
||||
(x.p: C);
|
||||
}
|
||||
|
||||
function subtype_obj_to_dict(x: { p: B }) {
|
||||
let a: { [k: string]: A } = x;
|
||||
|
||||
a.p = new A();
|
||||
let b: { [k: string]: B } = x;
|
||||
let c: { [k: string]: C } = x;
|
||||
|
||||
(x.p: C);
|
||||
}
|
||||
|
||||
function subtype_obj_to_mixed(x: { p: B; x: X }) {
|
||||
let a: { [k: string]: A; x: X } = x;
|
||||
let b: { [k: string]: B; x: X } = x;
|
||||
let c: { [k: string]: C; x: X } = x;
|
||||
}
|
||||
|
||||
function unification_dict_to_mixed(x: Array<{ [k: string]: B }>) {
|
||||
let a: Array<{ [k: string]: B; p: A }> = x;
|
||||
let b: Array<{ [k: string]: B; p: B }> = x;
|
||||
let c: Array<{ [k: string]: B; p: C }> = x;
|
||||
}
|
||||
|
||||
function subtype_dict_to_mixed(x: { [k: string]: B }) {
|
||||
let a: { [k: string]: B; p: A } = x;
|
||||
let b: { [k: string]: B; p: B } = x;
|
||||
let c: { [k: string]: B; p: C } = x;
|
||||
}
|
||||
|
||||
function subtype_dict_to_optional_a(x: { [k: string]: B }) {
|
||||
let a: { p?: A } = x;
|
||||
}
|
||||
|
||||
function subtype_dict_to_optional_b(x: { [k: string]: B }) {
|
||||
let b: { p?: B } = x;
|
||||
}
|
||||
|
||||
function subtype_dict_to_optional_c(x: { [k: string]: B }) {
|
||||
let c: { p?: C } = x;
|
||||
}
|
||||
|
||||
function subtype_optional_a_to_dict(x: { p?: A }): { [k: string]: B } {
|
||||
return x;
|
||||
}
|
||||
|
||||
function subtype_optional_b_to_dict(x: { p?: B }): { [k: string]: B } {
|
||||
return x;
|
||||
}
|
||||
|
||||
function subtype_optional_c_to_dict(x: { p?: C }): { [k: string]: B } {
|
||||
return x;
|
||||
}
|
||||
|
@ -750,17 +806,20 @@ var z: { [key: number]: string } = x;
|
|||
var a: { [key: string]: ?string } = {};
|
||||
var b: { [key: string]: string } = a;
|
||||
var c: { [key: string]: ?string } = b;
|
||||
|
||||
function foo0(x: Array<{ [key: string]: number }>): Array<{
|
||||
[key: string]: string
|
||||
}> {
|
||||
return x;
|
||||
}
|
||||
|
||||
function foo1(x: Array<{ [key: string]: number }>): Array<{
|
||||
[key: string]: number;
|
||||
fooBar: string
|
||||
}> {
|
||||
return x;
|
||||
}
|
||||
|
||||
function foo2(x: Array<{ [key: string]: mixed }>): Array<{
|
||||
[key: string]: mixed;
|
||||
fooBar: string
|
||||
|
@ -768,26 +827,33 @@ function foo2(x: Array<{ [key: string]: mixed }>): Array<{
|
|||
x[0].fooBar = 123;
|
||||
return x;
|
||||
}
|
||||
|
||||
function foo3(x: { [key: string]: number }): { foo: number } {
|
||||
return x;
|
||||
}
|
||||
|
||||
function foo4(x: { [key: string]: number }): {
|
||||
[key: string]: number;
|
||||
foo: string
|
||||
} {
|
||||
return x;
|
||||
}
|
||||
|
||||
function foo5(x: Array<{ [key: string]: number }>): Array<{ foo: number }> {
|
||||
return x;
|
||||
}
|
||||
|
||||
function foo6(x: Array<{ foo: number }>): Array<{ [key: string]: number }> {
|
||||
return x;
|
||||
}
|
||||
|
||||
function foo7(x: { [key: string]: number; bar: string }) {
|
||||
(x.bar: string);
|
||||
}
|
||||
|
||||
function foo8(x: { [key: string]: number }) {
|
||||
(x.foo: string);
|
||||
|
||||
(x.foo: number);
|
||||
}
|
||||
"
|
||||
|
@ -866,6 +932,7 @@ var o: { foo: QueryFunction } = {
|
|||
return params.count;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = o;
|
||||
"
|
||||
`;
|
||||
|
@ -879,6 +946,7 @@ o.foo = function (params) {
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// error, number ~/~ string
|
||||
var o = require(\"./test\");
|
||||
|
||||
o.foo = function(params) {
|
||||
return params.count;
|
||||
};
|
||||
|
|
|
@ -213,6 +213,7 @@ export function emitExpression(node: TypedNode) : t.Expression {
|
|||
import * as t from \"./jsAst\";
|
||||
const b = t.builders;
|
||||
import type { TypedNode } from \"./ast\";
|
||||
|
||||
function getBinaryOp(
|
||||
op: \"plus\" | \"minus\" | \"divide\" | \"multiply\"
|
||||
): \"+\" | \"-\" | \"*\" | \"/\" {
|
||||
|
|
|
@ -102,6 +102,7 @@ exports[`test use_strict_with_flow.js 1`] = `
|
|||
/* @flow */
|
||||
// error
|
||||
\"use strict\";
|
||||
|
||||
(\"\": void);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -44,6 +44,7 @@ let tests = [
|
|||
let tests = [
|
||||
function(document: Document) {
|
||||
const event = document.createEvent(\"CustomEvent\");
|
||||
|
||||
event.initCustomEvent(\"butts\", true, false, { nice: 42 });
|
||||
}
|
||||
];
|
||||
|
@ -68,8 +69,11 @@ let tests = [
|
|||
let tests = [
|
||||
function(document: Document) {
|
||||
(document.createElement(\"canvas\"): HTMLCanvasElement);
|
||||
|
||||
(document.createElement(\"link\"): HTMLLinkElement);
|
||||
|
||||
(document.createElement(\"option\"): HTMLOptionElement);
|
||||
|
||||
(document.createElement(\"select\"): HTMLSelectElement);
|
||||
}
|
||||
];
|
||||
|
@ -102,13 +106,21 @@ let tests = [
|
|||
let tests = [
|
||||
function(element: Element) {
|
||||
element.scrollIntoView();
|
||||
|
||||
element.scrollIntoView(false);
|
||||
|
||||
element.scrollIntoView({});
|
||||
|
||||
element.scrollIntoView({ behavior: \"smooth\", block: \"end\" });
|
||||
|
||||
element.scrollIntoView({ block: \"end\" });
|
||||
|
||||
element.scrollIntoView({ behavior: \"smooth\" });
|
||||
|
||||
element.scrollIntoView({ behavior: \"invalid\" });
|
||||
|
||||
element.scrollIntoView({ block: \"invalid\" });
|
||||
|
||||
element.scrollIntoView(1);
|
||||
}
|
||||
];
|
||||
|
@ -161,13 +173,21 @@ let tests = [
|
|||
let tests = [
|
||||
function(element: HTMLElement) {
|
||||
element.scrollIntoView();
|
||||
|
||||
element.scrollIntoView(false);
|
||||
|
||||
element.scrollIntoView({});
|
||||
|
||||
element.scrollIntoView({ behavior: \"smooth\", block: \"end\" });
|
||||
|
||||
element.scrollIntoView({ block: \"end\" });
|
||||
|
||||
element.scrollIntoView({ behavior: \"smooth\" });
|
||||
|
||||
element.scrollIntoView({ behavior: \"invalid\" });
|
||||
|
||||
element.scrollIntoView({ block: \"invalid\" });
|
||||
|
||||
element.scrollIntoView(1);
|
||||
}
|
||||
];
|
||||
|
@ -195,9 +215,13 @@ let tests = [
|
|||
let tests = [
|
||||
function(el: HTMLInputElement) {
|
||||
el.setRangeText(\"foo\");
|
||||
|
||||
el.setRangeText(\"foo\", 123);
|
||||
|
||||
el.setRangeText(\"foo\", 123, 234);
|
||||
|
||||
el.setRangeText(\"foo\", 123, 234, \"select\");
|
||||
|
||||
el.setRangeText(\"foo\", 123, 234, \"bogus\");
|
||||
}
|
||||
];
|
||||
|
@ -298,18 +322,20 @@ let tests = [
|
|||
// detachEvent
|
||||
// invalid, may be undefined
|
||||
// valid
|
||||
let listener: EventListener = function(event: Event): void {
|
||||
|
||||
};
|
||||
let listener: EventListener = function(event: Event): void {};
|
||||
let tests = [
|
||||
function() {
|
||||
let target = new EventTarget();
|
||||
|
||||
(target.attachEvent(\"foo\", listener): void);
|
||||
|
||||
(target.attachEvent && target.attachEvent(\"foo\", listener): void);
|
||||
},
|
||||
function() {
|
||||
let target = new EventTarget();
|
||||
|
||||
(target.detachEvent(\"foo\", listener): void);
|
||||
|
||||
(target.detachEvent && target.detachEvent(\"foo\", listener): void);
|
||||
},
|
||||
function() {
|
||||
|
@ -342,8 +368,11 @@ let tests = [
|
|||
let tests = [
|
||||
function() {
|
||||
let path = new Path2D();
|
||||
|
||||
(path.arcTo(0, 0, 0, 0, 10): void);
|
||||
|
||||
(path.arcTo(0, 0, 0, 0, 10, 20, 5): void);
|
||||
|
||||
(path.arcTo(0, 0, 0, 0, 10, \"20\", 5): void);
|
||||
}
|
||||
];
|
||||
|
@ -424,30 +453,16 @@ let tests = [
|
|||
prototype: Object.create(
|
||||
HTMLElement.prototype,
|
||||
{
|
||||
createdCallback: {
|
||||
value: function createdCallback() {
|
||||
|
||||
}
|
||||
},
|
||||
attachedCallback: {
|
||||
value: function attachedCallback() {
|
||||
|
||||
}
|
||||
},
|
||||
detachedCallback: {
|
||||
value: function detachedCallback() {
|
||||
|
||||
}
|
||||
},
|
||||
createdCallback: { value: function createdCallback() {} },
|
||||
attachedCallback: { value: function attachedCallback() {} },
|
||||
detachedCallback: { value: function detachedCallback() {} },
|
||||
attributeChangedCallback: {
|
||||
value: function attributeChangedCallback(
|
||||
attributeLocalName,
|
||||
oldAttributeValue,
|
||||
newAttributeValue,
|
||||
attributeNamespace
|
||||
) {
|
||||
|
||||
}
|
||||
) {}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@ -461,21 +476,13 @@ let tests = [
|
|||
prototype: Object.assign(
|
||||
Object.create(HTMLElement.prototype),
|
||||
{
|
||||
createdCallback() {
|
||||
|
||||
},
|
||||
attachedCallback() {
|
||||
|
||||
},
|
||||
detachedCallback() {
|
||||
|
||||
},
|
||||
createdCallback() {},
|
||||
attachedCallback() {},
|
||||
detachedCallback() {},
|
||||
attributeChangedCallback(attributeLocalName,
|
||||
oldAttributeValue,
|
||||
newAttributeValue,
|
||||
attributeNamespace) {
|
||||
|
||||
}
|
||||
attributeNamespace) {}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -489,9 +496,7 @@ let tests = [
|
|||
attributeChangedCallback(localName: string,
|
||||
oldVal: string,
|
||||
newVal: string,
|
||||
namespace: string) {
|
||||
|
||||
}
|
||||
namespace: string) {}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -732,10 +737,12 @@ let tests = [
|
|||
},
|
||||
function() {
|
||||
document.createNodeIterator(document.body);
|
||||
|
||||
document.createNodeIterator({});
|
||||
},
|
||||
function() {
|
||||
document.createTreeWalker(document.body);
|
||||
|
||||
document.createTreeWalker({});
|
||||
},
|
||||
function() {
|
||||
|
@ -897,17 +904,21 @@ let tests = [
|
|||
-1,
|
||||
node => NodeFilter.FILTER_ACCEPT
|
||||
);
|
||||
|
||||
document.createNodeIterator(document.body, -1, node => \"accept\");
|
||||
|
||||
document.createNodeIterator(
|
||||
document.body,
|
||||
-1,
|
||||
{ accept: node => NodeFilter.FILTER_ACCEPT }
|
||||
);
|
||||
|
||||
document.createNodeIterator(
|
||||
document.body,
|
||||
-1,
|
||||
{ accept: node => \"accept\" }
|
||||
);
|
||||
|
||||
document.createNodeIterator(document.body, -1, {});
|
||||
},
|
||||
function() {
|
||||
|
@ -916,13 +927,17 @@ let tests = [
|
|||
-1,
|
||||
node => NodeFilter.FILTER_ACCEPT
|
||||
);
|
||||
|
||||
document.createTreeWalker(document.body, -1, node => \"accept\");
|
||||
|
||||
document.createTreeWalker(
|
||||
document.body,
|
||||
-1,
|
||||
{ accept: node => NodeFilter.FILTER_ACCEPT }
|
||||
);
|
||||
|
||||
document.createTreeWalker(document.body, -1, { accept: node => \"accept\" });
|
||||
|
||||
document.createTreeWalker(document.body, -1, {});
|
||||
}
|
||||
];
|
||||
|
|
|
@ -7,10 +7,11 @@ module.exports = num;
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
var num = 42;
|
||||
function bar() {
|
||||
|
||||
}
|
||||
function bar() {}
|
||||
|
||||
bar();
|
||||
|
||||
module.exports = num;
|
||||
"
|
||||
`;
|
||||
|
@ -41,24 +42,29 @@ const idxResult = idx(obj, obj => obj.a.b.c.d);
|
|||
// @flow
|
||||
// test deduping of inferred types
|
||||
var num = require(\"./import\");
|
||||
function foo(x) {
|
||||
|
||||
}
|
||||
function foo(x) {}
|
||||
|
||||
foo(0);
|
||||
var a: string = num;
|
||||
|
||||
function unannotated(x) {
|
||||
return x;
|
||||
}
|
||||
const nullToUndefined = val => (val === null ? undefined : val);
|
||||
|
||||
function f0(x: ?Object) {
|
||||
return nullToUndefined(x);
|
||||
}
|
||||
|
||||
function f1(x: ?Object) {
|
||||
return nullToUndefined(x);
|
||||
}
|
||||
|
||||
function f2(x: ?string) {
|
||||
return nullToUndefined(x);
|
||||
}
|
||||
|
||||
function f3(x: ?string) {
|
||||
return nullToUndefined(x);
|
||||
}
|
||||
|
|
|
@ -36,52 +36,41 @@ class C5 {
|
|||
new C5().m = new C5().m - 42;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
class C1 {
|
||||
m() {
|
||||
m() {}
|
||||
m() {}
|
||||
}
|
||||
|
||||
}
|
||||
m() {
|
||||
|
||||
}
|
||||
}
|
||||
new C1().m();
|
||||
class C2 {
|
||||
get m() {
|
||||
return 42;
|
||||
}
|
||||
m() {
|
||||
m() {}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
new C2().m();
|
||||
class C3 {
|
||||
set m(x) {
|
||||
set m(x) {}
|
||||
m() {}
|
||||
}
|
||||
|
||||
}
|
||||
m() {
|
||||
|
||||
}
|
||||
}
|
||||
new C3().m();
|
||||
class C4 {
|
||||
get m() {
|
||||
return 42;
|
||||
}
|
||||
set m(x: number) {
|
||||
set m(x: number) {}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
new C4().m = new C4().m - 42;
|
||||
class C5 {
|
||||
m() {
|
||||
|
||||
}
|
||||
m() {}
|
||||
get m() {
|
||||
return 42;
|
||||
}
|
||||
set m(x: number) {
|
||||
set m(x: number) {}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
new C5().m = new C5().m - 42;
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -23,15 +23,18 @@ var s3 = tag2 \`la la la\`;
|
|||
class A {}
|
||||
var a = new A();
|
||||
var s1 = \`l\${a.x}r\`;
|
||||
|
||||
function tag(strings, ...values) {
|
||||
var x: number = strings[0];
|
||||
return x;
|
||||
}
|
||||
var s2 = tag\`l\${42}r\`;
|
||||
|
||||
function tag2(strings, ...values) {
|
||||
return { foo: \"\" };
|
||||
}
|
||||
var s3 = tag2\`la la la\`;
|
||||
|
||||
(s3.foo: number);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -34,17 +34,22 @@ function isActive(
|
|||
): boolean {
|
||||
return ad.state === \"ACTIVE\";
|
||||
}
|
||||
|
||||
isActive({ state: \"PAUSE\" });
|
||||
var MyStates = { PAUSED: \"PAUSED\", ACTIVE: \"ACTIVE\", DELETED: \"DELETED\" };
|
||||
|
||||
function isActive2(ad: { state: $Keys<typeof MyStates> }): boolean {
|
||||
return ad.state === MyStates.ACTIVE;
|
||||
}
|
||||
|
||||
isActive2({ state: \"PAUSE\" });
|
||||
type Keys = $Keys<{ x: any; y: any }>;
|
||||
type Union = \"x\" | \"y\";
|
||||
|
||||
function keys2union(s: Keys): Union {
|
||||
return s;
|
||||
}
|
||||
|
||||
function union2keys(s: Union): Keys {
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -16,13 +16,20 @@ var x = (null : ?number);
|
|||
// error
|
||||
// error
|
||||
1 == 1;
|
||||
|
||||
\"foo\" == \"bar\";
|
||||
|
||||
1 == null;
|
||||
|
||||
null == 1;
|
||||
|
||||
1 == \"\";
|
||||
|
||||
\"\" == 1;
|
||||
var x = (null: ?number);
|
||||
|
||||
x == 1;
|
||||
|
||||
1 == x;
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
exports[`test errors.js 1`] = `
|
||||
"if (typeof define === \'function\' && define.amd) { }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
if (typeof define === \"function\" && define.amd) {
|
||||
|
||||
}
|
||||
if (typeof define === \"function\" && define.amd)
|
||||
{}
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -64,6 +64,7 @@ class Test extends Base {
|
|||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Test;
|
||||
"
|
||||
`;
|
||||
|
@ -131,9 +132,13 @@ exports.numberValue5 = 5;
|
|||
* @flow
|
||||
*/
|
||||
exports.numberValue1 = 1;
|
||||
|
||||
exports.numberValue2 = 2;
|
||||
|
||||
exports.numberValue3 = 3;
|
||||
|
||||
exports.numberValue4 = 4;
|
||||
|
||||
exports.numberValue5 = 5;
|
||||
"
|
||||
`;
|
||||
|
@ -239,6 +244,7 @@ export default class Foo {
|
|||
return 42;
|
||||
}
|
||||
}
|
||||
|
||||
new Foo();
|
||||
"
|
||||
`;
|
||||
|
@ -582,9 +588,13 @@ exports.stringValue = \"str\";
|
|||
* @flow
|
||||
*/
|
||||
exports.numberValue1 = 42;
|
||||
|
||||
exports.numberValue2 = 42;
|
||||
|
||||
exports.numberValue3 = 42;
|
||||
|
||||
exports.numberValue4 = 42;
|
||||
|
||||
exports.stringValue = \"str\";
|
||||
"
|
||||
`;
|
||||
|
@ -1090,23 +1100,28 @@ var d2: string = numVal1;
|
|||
import CJS_Clobb_Lit from \"CommonJS_Clobbering_Lit\";
|
||||
var e1: number = CJS_Clobb_Lit.numberValue3;
|
||||
var e2: string = CJS_Clobb_Lit.numberValue3;
|
||||
|
||||
CJS_Clobb_Lit.doesntExist;
|
||||
import * as CJS_Clobb_Lit_NS from \"CommonJS_Clobbering_Lit\";
|
||||
var f1: number = CJS_Clobb_Lit_NS.numberValue4;
|
||||
var f2: number = CJS_Clobb_Lit_NS.default.numberValue4;
|
||||
|
||||
CJS_Clobb_Lit_NS.default.default;
|
||||
var f3: string = CJS_Clobb_Lit_NS.numberValue4;
|
||||
var f4: string = CJS_Clobb_Lit_NS.default.numberValue5;
|
||||
import { doesntExist2 } from \"CommonJS_Clobbering_Class\";
|
||||
import { staticNumber1, baseProp, childProp } from \"CommonJS_Clobbering_Class\";
|
||||
import CJS_Clobb_Class from \"CommonJS_Clobbering_Class\";
|
||||
|
||||
new CJS_Clobb_Class();
|
||||
|
||||
new CJS_Clobb_Class().doesntExist;
|
||||
var h1: number = CJS_Clobb_Class.staticNumber2();
|
||||
var h2: string = CJS_Clobb_Class.staticNumber2();
|
||||
var h3: number = new CJS_Clobb_Class().instNumber1();
|
||||
var h4: string = new CJS_Clobb_Class().instNumber1();
|
||||
import * as CJS_Clobb_Class_NS from \"CommonJS_Clobbering_Class\";
|
||||
|
||||
new CJS_Clobb_Class_NS();
|
||||
var i1: number = CJS_Clobb_Class_NS.staticNumber3();
|
||||
var i2: number = new CJS_Clobb_Class_NS.default().instNumber2();
|
||||
|
@ -1121,6 +1136,7 @@ var k2: string = numVal3;
|
|||
import * as CJS_Named from \"CommonJS_Named\";
|
||||
var l1: number = CJS_Named.numberValue1;
|
||||
var l2: string = CJS_Named.numberValue1;
|
||||
|
||||
CJS_Named.doesntExist;
|
||||
import * as CJS_Named_NS from \"CommonJS_Named\";
|
||||
var m1: number = CJS_Named_NS.numberValue4;
|
||||
|
@ -1180,6 +1196,7 @@ var ab2: string = numberValue2_renamed;
|
|||
import { numberValue1 as numberValue5 } from \"ES6_ExportAllFrom_Intermediary1\";
|
||||
var ac1: number = numberValue5;
|
||||
var ac2: string = numberValue5;
|
||||
|
||||
require(\"ES6_Default_AnonFunction2\").doesntExist;
|
||||
var ES6_Def_AnonFunc2 = require(\"ES6_Default_AnonFunction2\").default;
|
||||
var ad1: number = ES6_Def_AnonFunc2();
|
||||
|
@ -1333,27 +1350,40 @@ function testRequires() {
|
|||
// CommonJS module that clobbers module.exports with a frozen object
|
||||
// Error: frozen
|
||||
import * as DefaultA from \"A\";
|
||||
|
||||
DefaultA.numberValue1 = 123;
|
||||
import * as ES6_Named1 from \"ES6_Named1\";
|
||||
|
||||
ES6_Named1.varDeclNumber1 = 123;
|
||||
import * as CommonJS_Star from \"CommonJS_Clobbering_Lit\";
|
||||
|
||||
CommonJS_Star.numberValue1 = 123;
|
||||
|
||||
CommonJS_Star.default.numberValue1 = 123;
|
||||
import CommonJS_Clobbering_Lit from \"CommonJS_Clobbering_Lit\";
|
||||
|
||||
CommonJS_Clobbering_Lit.numberValue1 = 123;
|
||||
import * as CommonJS_Frozen_Star from \"CommonJS_Clobbering_Frozen\";
|
||||
|
||||
CommonJS_Frozen_Star.numberValue1 = 123;
|
||||
|
||||
CommonJS_Frozen_Star.default.numberValue1 = 123;
|
||||
import CommonJS_Clobbering_Frozen from \"CommonJS_Clobbering_Frozen\";
|
||||
|
||||
CommonJS_Clobbering_Frozen.numberValue1 = 123;
|
||||
|
||||
function testRequires() {
|
||||
var DefaultA = require(\"A\");
|
||||
|
||||
DefaultA.numberValue1 = 123;
|
||||
var ES6_Named1 = require(\"ES6_Named1\");
|
||||
|
||||
ES6_Named1.numberValue = 123;
|
||||
var CommonJS_Star = require(\"CommonJS_Clobbering_Lit\");
|
||||
|
||||
CommonJS_Star.numberValue1 = 123;
|
||||
var CommonJS_Frozen_Star = require(\"CommonJS_Clobbering_Frozen\");
|
||||
|
||||
CommonJS_Frozen_Star.numberValue1 = 123;
|
||||
}
|
||||
"
|
||||
|
|
|
@ -58,35 +58,55 @@ import {exports as nope} from \"ES\"; // Error: Not an export
|
|||
// Error: Not an export
|
||||
import { num1, str1 } from \"CJS_Named\";
|
||||
import CJS_Named from \"CJS_Named\";
|
||||
|
||||
(num1: number);
|
||||
|
||||
(num1: string);
|
||||
|
||||
(str1: string);
|
||||
|
||||
(str1: number);
|
||||
|
||||
(CJS_Named: { num1: number; str1: string });
|
||||
|
||||
(CJS_Named: number);
|
||||
import { num2 } from \"CJS_Clobbered\";
|
||||
import { numExport } from \"CJS_Clobbered\";
|
||||
|
||||
(numExport: number);
|
||||
|
||||
(numExport: string);
|
||||
import type { numType } from \"CJS_Clobbered\";
|
||||
|
||||
(42: numType);
|
||||
|
||||
(\"asdf\": numType);
|
||||
import { strHidden } from \"ES\";
|
||||
import { str3 } from \"ES\";
|
||||
|
||||
(str3: string);
|
||||
|
||||
(str3: number);
|
||||
import { num3 } from \"ES\";
|
||||
|
||||
(num3: number);
|
||||
|
||||
(num3: string);
|
||||
import { C } from \"ES\";
|
||||
import type { C as CType } from \"ES\";
|
||||
|
||||
(new C(): C);
|
||||
|
||||
(42: C);
|
||||
|
||||
(new C(): CType);
|
||||
|
||||
(42: CType);
|
||||
import { T } from \"ES\";
|
||||
import type { T as T2 } from \"ES\";
|
||||
|
||||
(42: T2);
|
||||
|
||||
(\"asdf\": T2);
|
||||
import { exports as nope } from \"ES\";
|
||||
"
|
||||
|
|
|
@ -18,10 +18,13 @@ N.z = Q(N.z);
|
|||
// declaration of Q redirects to module M
|
||||
var M = require(\"M\");
|
||||
var N = require(\"N\");
|
||||
|
||||
N.x = M(N.x);
|
||||
var P = require(\"./P\");
|
||||
|
||||
N.y = P(N.y);
|
||||
var Q = require(\"Q\");
|
||||
|
||||
N.z = Q(N.z);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -9,6 +9,7 @@ module.exports = {}
|
|||
/* @flow */
|
||||
export type talias4 = number;
|
||||
export interface IFoo { prop: number }
|
||||
|
||||
module.exports = {};
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -3,6 +3,7 @@ exports[`test foo.js 1`] = `
|
|||
imp(1337);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var imp = require(\"./bar\");
|
||||
|
||||
imp(1337);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -7,7 +7,9 @@ var React = require(\'react\');
|
|||
// @flow
|
||||
// Error: ReactElement ~> number
|
||||
var React = require(\"react\");
|
||||
|
||||
(<fbt/>: React.Element<*>);
|
||||
|
||||
(<fbt/>: number);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -7,6 +7,7 @@ exports[`test main.js 1`] = `
|
|||
// @flow
|
||||
// Error (the libdef in this test marks fbt as number)
|
||||
(<fbt/>: number);
|
||||
|
||||
(<fbt/>: string);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -3,6 +3,7 @@ exports[`test Bar.js 1`] = `
|
|||
module.exports = Bar;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var Bar = { x: 0 };
|
||||
|
||||
module.exports = Bar;
|
||||
"
|
||||
`;
|
||||
|
@ -62,7 +63,9 @@ let tests = [
|
|||
},
|
||||
function(copyProperties: Object$Assign) {
|
||||
let result = {};
|
||||
|
||||
result.baz = false;
|
||||
|
||||
(copyProperties(result, { foo: \"a\" }, { bar: 123 }): {
|
||||
foo: string;
|
||||
bar: number;
|
||||
|
@ -73,16 +76,17 @@ let tests = [
|
|||
const copyProperties = require(\"copyProperties\");
|
||||
let x = { foo: \"a\" };
|
||||
let y = { bar: 123 };
|
||||
|
||||
(copyProperties({}, x, y): { foo: string; bar: number });
|
||||
},
|
||||
function(copyProperties: Object$Assign) {
|
||||
copyProperties();
|
||||
|
||||
(copyProperties({ foo: \"a\" }): { foo: number });
|
||||
},
|
||||
function(copyProperties: Object$Assign) {
|
||||
function x(cb: Function) {
|
||||
function x(cb: Function) {}
|
||||
|
||||
}
|
||||
x(copyProperties);
|
||||
}
|
||||
];
|
||||
|
@ -110,11 +114,14 @@ let tests = [
|
|||
let tests = [
|
||||
function() {
|
||||
let x: ?string = null;
|
||||
|
||||
invariant(x, \"truthy only\");
|
||||
},
|
||||
function(invariant: Function) {
|
||||
let x: ?string = null;
|
||||
|
||||
invariant(x);
|
||||
|
||||
(x: string);
|
||||
}
|
||||
];
|
||||
|
@ -195,22 +202,25 @@ let tests = [
|
|||
},
|
||||
function(mergeInto: $Facebookism$MergeInto) {
|
||||
let result = {};
|
||||
|
||||
result.baz = false;
|
||||
|
||||
(mergeInto(result, { foo: \"a\" }, { bar: 123 }): void);
|
||||
|
||||
(result: { foo: string; bar: number; baz: boolean });
|
||||
},
|
||||
function() {
|
||||
const mergeInto = require(\"mergeInto\");
|
||||
let result: { foo?: string; bar?: number; baz: boolean } = { baz: false };
|
||||
|
||||
(mergeInto(result, { foo: \"a\" }, { bar: 123 }): void);
|
||||
},
|
||||
function(mergeInto: $Facebookism$MergeInto) {
|
||||
mergeInto();
|
||||
},
|
||||
function(mergeInto: $Facebookism$MergeInto) {
|
||||
function x(cb: Function) {
|
||||
function x(cb: Function) {}
|
||||
|
||||
}
|
||||
x(mergeInto);
|
||||
}
|
||||
];
|
||||
|
@ -233,6 +243,7 @@ var mixin = require(\"mixin\");
|
|||
class Foo extends mixin(Bar) {
|
||||
m() {
|
||||
var x: string = this.x;
|
||||
|
||||
this.y = \"\";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,26 +98,31 @@ const b = new Headers([ \"Content-Type\", \"image/jpeg\" ]);
|
|||
const c = new Headers({ \"Content-Type\", \"image/jpeg\" });
|
||||
const d = new Headers(c);
|
||||
const e: Headers = new Headers();
|
||||
|
||||
e.append(\"Content-Type\", \"image/jpeg\");
|
||||
|
||||
e.append(\"Content-Type\");
|
||||
|
||||
e.append({ \"Content-Type\", \"image/jpeg\" });
|
||||
|
||||
e.set(\"Content-Type\", \"image/jpeg\");
|
||||
|
||||
e.set(\"Content-Type\");
|
||||
|
||||
e.set({ \"Content-Type\", \"image/jpeg\" });
|
||||
const f: Headers = e.append(\"Content-Type\", \"image/jpeg\");
|
||||
const g: string = e.get(\"Content-Type\");
|
||||
const h: number = e.get(\"Content-Type\");
|
||||
|
||||
for (let v of e) {
|
||||
const [ i, j ]: [string, string] = v;
|
||||
}
|
||||
|
||||
for (let v of e.entries()) {
|
||||
const [ i, j ]: [string, string] = v;
|
||||
}
|
||||
e.getAll(\"content-type\").forEach(
|
||||
(v: string) => {
|
||||
|
||||
}
|
||||
);
|
||||
e.getAll(\"content-type\").forEach((v: string) => {});
|
||||
"
|
||||
`;
|
||||
|
||||
|
@ -235,9 +240,13 @@ const k: Request = new Request(
|
|||
}
|
||||
);
|
||||
var l: boolean = h.bodyUsed;
|
||||
|
||||
h.text().then((t: string) => t);
|
||||
|
||||
h.text().then((t: Buffer) => t);
|
||||
|
||||
h.arrayBuffer().then((ab: ArrayBuffer) => ab);
|
||||
|
||||
h.arrayBuffer().then((ab: Buffer) => ab);
|
||||
"
|
||||
`;
|
||||
|
@ -327,9 +336,13 @@ const i: Response = new Response({
|
|||
});
|
||||
const ok: boolean = h.ok;
|
||||
const status: number = h.status;
|
||||
|
||||
h.text().then((t: string) => t);
|
||||
|
||||
h.text().then((t: Buffer) => t);
|
||||
|
||||
h.arrayBuffer().then((ab: ArrayBuffer) => ab);
|
||||
|
||||
h.arrayBuffer().then((ab: Buffer) => ab);
|
||||
"
|
||||
`;
|
||||
|
@ -387,25 +400,30 @@ const b = new URLSearchParams([ \"key1\", \"value1\" ]);
|
|||
const c = new URLSearchParams({ \"key1\", \"value1\" });
|
||||
const d = new URLSearchParams(c);
|
||||
const e: URLSearchParams = new URLSearchParams();
|
||||
|
||||
e.append(\"key1\", \"value1\");
|
||||
|
||||
e.append(\"key1\");
|
||||
|
||||
e.append({ \"key1\", \"value1\" });
|
||||
|
||||
e.set(\"key1\", \"value1\");
|
||||
|
||||
e.set(\"key1\");
|
||||
|
||||
e.set({ \"key1\", \"value1\" });
|
||||
const f: URLSearchParams = e.append(\"key1\", \"value1\");
|
||||
const g: string = e.get(\"key1\");
|
||||
const h: number = e.get(\"key1\");
|
||||
|
||||
for (let v of e) {
|
||||
const [ i, j ]: [string, string] = v;
|
||||
}
|
||||
|
||||
for (let v of e.entries()) {
|
||||
const [ i, j ]: [string, string] = v;
|
||||
}
|
||||
e.getAll(\"key1\").forEach(
|
||||
(v: string) => {
|
||||
|
||||
}
|
||||
);
|
||||
e.getAll(\"key1\").forEach((v: string) => {});
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -12,6 +12,7 @@ exports[`test test.js 1`] = `
|
|||
import x from \'./req\';
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var x = require(\"./req\");
|
||||
|
||||
(x: string);
|
||||
import x from \"./req\";
|
||||
"
|
||||
|
|
|
@ -34,12 +34,15 @@ module.exports = {fn: fix};
|
|||
function eq(x: number, y: number) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function sub(x: number, y: number) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function mul(x: number, y: number) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function fix(fold) {
|
||||
var delta = function(delta) {
|
||||
return fold(
|
||||
|
@ -51,6 +54,7 @@ function fix(fold) {
|
|||
};
|
||||
return delta(delta);
|
||||
}
|
||||
|
||||
function mk_factorial() {
|
||||
return fix(
|
||||
function(factorial) {
|
||||
|
@ -64,7 +68,9 @@ function mk_factorial() {
|
|||
);
|
||||
}
|
||||
var factorial = mk_factorial();
|
||||
|
||||
factorial(\"...\");
|
||||
|
||||
module.exports = { fn: fix };
|
||||
"
|
||||
`;
|
||||
|
@ -97,22 +103,28 @@ function Y(f) {
|
|||
function g(x) {
|
||||
return f(x(x));
|
||||
}
|
||||
|
||||
g(g);
|
||||
}
|
||||
|
||||
function func1(f) {
|
||||
function fix_f(x: number): number {
|
||||
return f(x);
|
||||
}
|
||||
return fix_f;
|
||||
}
|
||||
|
||||
function func2(f) {
|
||||
function fix_f(x: string): string {
|
||||
return f(x);
|
||||
}
|
||||
return fix_f;
|
||||
}
|
||||
|
||||
Y(func1);
|
||||
|
||||
Y(func2);
|
||||
|
||||
module.exports = Y;
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -50,28 +50,37 @@ function corge(x: boolean) {
|
|||
/* @flow */
|
||||
function foo(x: boolean) {
|
||||
var max = 10;
|
||||
|
||||
for (var ii = 0; ii < max; ii++) {
|
||||
if (x) {
|
||||
continue;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
function bar(x: boolean) {
|
||||
var max = 0;
|
||||
|
||||
for (var ii = 0; ii < max; ii++) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
function baz(x: boolean) {
|
||||
var max = 0;
|
||||
|
||||
for (var ii = 0; ii < max; ii++) {
|
||||
continue;
|
||||
}
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
function bliffl(x: boolean) {
|
||||
var max = 10;
|
||||
loop1:
|
||||
|
@ -80,15 +89,20 @@ for (var ii = 0; ii < max; ii++) {
|
|||
for (var jj = 0; jj < max; jj++) {
|
||||
break loop1;
|
||||
}
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
function corge(x: boolean) {
|
||||
var max = 0;
|
||||
|
||||
for (var ii = 0; ii < max; ii++) {
|
||||
break;
|
||||
}
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
"
|
||||
|
@ -140,26 +154,33 @@ function corge(x: boolean) {
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
function foo(x: boolean) {
|
||||
var obj = { a: 1, b: 2 };
|
||||
|
||||
for (var prop in obj) {
|
||||
if (x) {
|
||||
continue;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
function bar(x: boolean) {
|
||||
for (var prop in {}) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
function baz(x: boolean) {
|
||||
for (var prop in {}) {
|
||||
continue;
|
||||
}
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
function bliffl(x: boolean) {
|
||||
var obj = { a: 1, b: 2 };
|
||||
loop1:
|
||||
|
@ -168,14 +189,18 @@ for (var prop1 in obj) {
|
|||
for (var prop2 in obj) {
|
||||
break loop1;
|
||||
}
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
function corge(x: boolean) {
|
||||
for (var prop in {}) {
|
||||
break;
|
||||
}
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
"
|
||||
|
@ -227,26 +252,33 @@ function corge(x: boolean) {
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
function foo(x: boolean) {
|
||||
var arr = [ 1, 2, 3 ];
|
||||
|
||||
for (var elem of arr) {
|
||||
if (x) {
|
||||
continue;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
function bar(x: boolean) {
|
||||
for (var elem of []) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
function baz(x: boolean) {
|
||||
for (var elem of []) {
|
||||
continue;
|
||||
}
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
function bliffl(x: boolean) {
|
||||
var arr = [ 1, 2, 3 ];
|
||||
loop1:
|
||||
|
@ -255,14 +287,18 @@ for (var elem of arr) {
|
|||
for (var elem of arr) {
|
||||
break loop1;
|
||||
}
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
function corge(x: boolean) {
|
||||
for (var elem of []) {
|
||||
break;
|
||||
}
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
"
|
||||
|
|
|
@ -69,38 +69,47 @@ function testArray(arr: Array<number>): void {
|
|||
(x: string);
|
||||
}
|
||||
}
|
||||
|
||||
function testIterable1(iterable: Iterable<number>): void {
|
||||
for (var x of iterable) {
|
||||
(x: string);
|
||||
}
|
||||
}
|
||||
|
||||
function testIterable2(iterable: Iterable<*>): void {
|
||||
for (var x of iterable) {
|
||||
(x: string);
|
||||
}
|
||||
}
|
||||
|
||||
function testString(str: string): void {
|
||||
for (var x of str) {
|
||||
(x: number);
|
||||
}
|
||||
}
|
||||
|
||||
function testMap1(map: Map<string, number>): void {
|
||||
for (var elem of map) {
|
||||
(elem: [string, number]);
|
||||
|
||||
(elem: number);
|
||||
}
|
||||
}
|
||||
|
||||
function testMap2(map: Map<*, *>): void {
|
||||
for (var elem of map) {
|
||||
(elem: [number, string]);
|
||||
|
||||
(elem: number);
|
||||
}
|
||||
}
|
||||
|
||||
function testSet1(set: Set<string>): void {
|
||||
for (var x of set) {
|
||||
(x: number);
|
||||
}
|
||||
}
|
||||
|
||||
function testSet2(set: Set<*>): void {
|
||||
for (var x of set) {
|
||||
(x: number);
|
||||
|
|
|
@ -69,24 +69,39 @@ function test2(): number { return 0; }
|
|||
function test(a: string, b: number): number {
|
||||
return this.length;
|
||||
}
|
||||
|
||||
test.apply(\"\", [ \"\", 0 ]);
|
||||
|
||||
test.apply(0, [ \"\", 0 ]);
|
||||
|
||||
test.apply(\"\", [ \"\" ]);
|
||||
|
||||
test.apply(\"\", [ \"\", \"\" ]);
|
||||
|
||||
test.apply(\"\", [ 0, 0 ]);
|
||||
|
||||
function f(args) {
|
||||
test.apply(\"\", args);
|
||||
}
|
||||
|
||||
f([ \"\", 0 ]);
|
||||
|
||||
f([ \"\", \"\" ]);
|
||||
|
||||
f([ 0, 0 ]);
|
||||
|
||||
test.apply(\"\", \"not array\");
|
||||
|
||||
(test.call.apply(test, [ 0, 123, \"foo\" ]): void);
|
||||
|
||||
(test.bind.apply(test, [ 0, 123 ]): (b: number) => number);
|
||||
|
||||
function test2(): number {
|
||||
return 0;
|
||||
}
|
||||
|
||||
(test2.apply(): number);
|
||||
|
||||
(test2.apply(\"\"): number);
|
||||
"
|
||||
`;
|
||||
|
@ -108,7 +123,9 @@ let tests = [
|
|||
let tests = [
|
||||
function(x: (a: string, b: string) => void) {
|
||||
let y = x.bind(x, \"foo\");
|
||||
|
||||
y(\"bar\");
|
||||
|
||||
y(123);
|
||||
}
|
||||
];
|
||||
|
@ -174,22 +191,35 @@ function test2(): number { return 0; }
|
|||
function test(a: string, b: number): number {
|
||||
return this.length;
|
||||
}
|
||||
|
||||
test.call(\"\", \"\", 0);
|
||||
|
||||
test.call(0, \"\", 0);
|
||||
|
||||
test.call(\"\", \"\");
|
||||
|
||||
test.call(\"\", \"\", \"\");
|
||||
|
||||
test.call(\"\", 0, 0);
|
||||
|
||||
function f(args) {
|
||||
test.call(\"\", args[0], args[1]);
|
||||
}
|
||||
|
||||
f([ \"\", 0 ]);
|
||||
|
||||
f([ \"\", \"\" ]);
|
||||
|
||||
f([ 0, 0 ]);
|
||||
|
||||
(test.apply.call(test, 0, [ 0, \"foo\" ]): number);
|
||||
|
||||
function test2(): number {
|
||||
return 0;
|
||||
}
|
||||
|
||||
(test2.call(): number);
|
||||
|
||||
(test2.call(\"\"): number);
|
||||
"
|
||||
`;
|
||||
|
@ -292,17 +322,25 @@ var b: Function = function(a: number, b: number): number {
|
|||
};
|
||||
class C {}
|
||||
var c: Function = C;
|
||||
|
||||
function good(x: Function, MyThing: Function): number {
|
||||
var o: Object = x;
|
||||
|
||||
x.foo = 123;
|
||||
|
||||
x[\"foo\"] = 456;
|
||||
|
||||
x();
|
||||
|
||||
<MyThing/>;
|
||||
var { ...something } = x;
|
||||
|
||||
Object.assign(x, { hi: \"there\" });
|
||||
|
||||
Object.keys(x);
|
||||
return x.bar + x[\"bar\"] + x.lala();
|
||||
}
|
||||
|
||||
function bad(x: Function, y: Object): void {
|
||||
var a: number = x;
|
||||
var b: string = x;
|
||||
|
@ -310,33 +348,45 @@ function bad(x: Function, y: Object): void {
|
|||
}
|
||||
let tests = [
|
||||
function(y: () => void, z: Function) {
|
||||
function x() {
|
||||
function x() {}
|
||||
|
||||
}
|
||||
(x.length: void);
|
||||
|
||||
(y.length: void);
|
||||
|
||||
(z.length: void);
|
||||
|
||||
(x.name: void);
|
||||
|
||||
(y.name: void);
|
||||
|
||||
(z.name: void);
|
||||
},
|
||||
function(y: () => void, z: Function) {
|
||||
function x() {
|
||||
function x() {}
|
||||
|
||||
}
|
||||
x.length = \"foo\";
|
||||
|
||||
y.length = \"foo\";
|
||||
|
||||
z.length = \"foo\";
|
||||
|
||||
x.name = 123;
|
||||
|
||||
y.name = 123;
|
||||
|
||||
z.name = 123;
|
||||
|
||||
(z.foo: number);
|
||||
|
||||
(z.foo: string);
|
||||
}
|
||||
];
|
||||
var d: Function = () => 1;
|
||||
var e = (d.bind(1): Function)();
|
||||
|
||||
(e: number);
|
||||
|
||||
(e: string);
|
||||
"
|
||||
`;
|
||||
|
@ -368,12 +418,15 @@ function rest_t<U, T: Array<U>>(...xs: T): U {
|
|||
function rest_array<T>(...xs: Array<T>): T {
|
||||
return xs[0];
|
||||
}
|
||||
|
||||
function rest_tuple<T>(...xs: [T]): T {
|
||||
return xs[0];
|
||||
}
|
||||
|
||||
function rest_any(...xs: any): any {
|
||||
return xs[0];
|
||||
}
|
||||
|
||||
function rest_t<U, T: Array<U>>(...xs: T): U {
|
||||
return xs[0];
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ function foo() {
|
|||
function bar(x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
function foo() {
|
||||
return function bound() {
|
||||
return bar(bound);
|
||||
|
|
|
@ -151,14 +151,17 @@ for (var x of examples.delegate_yield_iterable([])) {
|
|||
class GeneratorExamples {
|
||||
*stmt_yield(): Generator<number, void, void> {
|
||||
yield 0;
|
||||
|
||||
yield \"\";
|
||||
}
|
||||
*stmt_next(): Generator<void, void, number> {
|
||||
var a = yield;
|
||||
|
||||
if (a) {
|
||||
(a: number);
|
||||
}
|
||||
var b = yield;
|
||||
|
||||
if (b) {
|
||||
(b: string);
|
||||
}
|
||||
|
@ -175,30 +178,35 @@ class GeneratorExamples {
|
|||
}
|
||||
*widen_next() {
|
||||
var x = yield 0;
|
||||
if (typeof x === \"number\") {
|
||||
|
||||
} else
|
||||
if (typeof x === \"boolean\") {
|
||||
|
||||
} else {
|
||||
if (typeof x === \"number\")
|
||||
{}
|
||||
else
|
||||
if (typeof x === \"boolean\")
|
||||
{}
|
||||
else {
|
||||
(x: string);
|
||||
}
|
||||
}
|
||||
*widen_yield() {
|
||||
yield 0;
|
||||
|
||||
yield \"\";
|
||||
|
||||
yield true;
|
||||
}
|
||||
*delegate_next_generator() {
|
||||
function* inner() {
|
||||
var x: number = yield;
|
||||
}
|
||||
|
||||
yield* inner();
|
||||
}
|
||||
*delegate_yield_generator() {
|
||||
function* inner() {
|
||||
yield \"\";
|
||||
}
|
||||
|
||||
yield* inner();
|
||||
}
|
||||
*delegate_return_generator() {
|
||||
|
@ -227,36 +235,46 @@ class GeneratorExamples {
|
|||
}
|
||||
}
|
||||
var examples = new GeneratorExamples();
|
||||
|
||||
for (var x of examples.infer_stmt()) {
|
||||
(x: string);
|
||||
}
|
||||
var infer_stmt_next = examples.infer_stmt().next(0).value;
|
||||
if (typeof infer_stmt_next === \"undefined\") {
|
||||
|
||||
} else
|
||||
if (typeof infer_stmt_next === \"number\") {
|
||||
|
||||
} else {
|
||||
if (typeof infer_stmt_next === \"undefined\")
|
||||
{}
|
||||
else
|
||||
if (typeof infer_stmt_next === \"number\")
|
||||
{}
|
||||
else {
|
||||
(infer_stmt_next: boolean);
|
||||
}
|
||||
|
||||
examples.widen_next().next(0);
|
||||
|
||||
examples.widen_next().next(\"\");
|
||||
|
||||
examples.widen_next().next(true);
|
||||
|
||||
for (var x of examples.widen_yield()) {
|
||||
if (typeof x === \"number\") {
|
||||
|
||||
} else
|
||||
if (typeof x === \"boolean\") {
|
||||
|
||||
} else {
|
||||
if (typeof x === \"number\")
|
||||
{}
|
||||
else
|
||||
if (typeof x === \"boolean\")
|
||||
{}
|
||||
else {
|
||||
(x: string);
|
||||
}
|
||||
}
|
||||
|
||||
examples.delegate_next_generator().next(\"\");
|
||||
|
||||
for (var x of examples.delegate_yield_generator()) {
|
||||
(x: number);
|
||||
}
|
||||
|
||||
examples.delegate_next_iterable([]).next(\"\");
|
||||
|
||||
for (var x of examples.delegate_yield_iterable([])) {
|
||||
(x: string);
|
||||
}
|
||||
|
@ -297,16 +315,18 @@ class GeneratorExamples<X> {
|
|||
}
|
||||
}
|
||||
var examples = new GeneratorExamples();
|
||||
|
||||
for (var x of examples.infer_stmt()) {
|
||||
(x: string);
|
||||
}
|
||||
var infer_stmt_next = examples.infer_stmt().next(0).value;
|
||||
if (typeof infer_stmt_next === \"undefined\") {
|
||||
|
||||
} else
|
||||
if (typeof infer_stmt_next === \"number\") {
|
||||
|
||||
} else {
|
||||
if (typeof infer_stmt_next === \"undefined\")
|
||||
{}
|
||||
else
|
||||
if (typeof infer_stmt_next === \"number\")
|
||||
{}
|
||||
else {
|
||||
(infer_stmt_next: boolean);
|
||||
}
|
||||
"
|
||||
|
@ -464,113 +484,147 @@ if (multiple_return_result.done) {
|
|||
// error: number|string ~> void
|
||||
function* stmt_yield(): Generator<number, void, void> {
|
||||
yield 0;
|
||||
|
||||
yield \"\";
|
||||
}
|
||||
|
||||
function* stmt_next(): Generator<void, void, number> {
|
||||
var a = yield;
|
||||
|
||||
if (a) {
|
||||
(a: number);
|
||||
}
|
||||
var b = yield;
|
||||
|
||||
if (b) {
|
||||
(b: string);
|
||||
}
|
||||
}
|
||||
|
||||
function* stmt_return_ok(): Generator<void, number, void> {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function* stmt_return_err(): Generator<void, number, void> {
|
||||
return \"\";
|
||||
}
|
||||
|
||||
function* infer_stmt() {
|
||||
var x: boolean = yield 0;
|
||||
return \"\";
|
||||
}
|
||||
|
||||
for (var x of infer_stmt()) {
|
||||
(x: string);
|
||||
}
|
||||
var infer_stmt_next = infer_stmt().next(0).value;
|
||||
if (typeof infer_stmt_next === \"undefined\") {
|
||||
|
||||
} else
|
||||
if (typeof infer_stmt_next === \"number\") {
|
||||
|
||||
} else {
|
||||
if (typeof infer_stmt_next === \"undefined\")
|
||||
{}
|
||||
else
|
||||
if (typeof infer_stmt_next === \"number\")
|
||||
{}
|
||||
else {
|
||||
(infer_stmt_next: boolean);
|
||||
}
|
||||
|
||||
function* widen_next() {
|
||||
var x = yield 0;
|
||||
if (typeof x === \"number\") {
|
||||
|
||||
} else
|
||||
if (typeof x === \"boolean\") {
|
||||
|
||||
} else {
|
||||
if (typeof x === \"number\")
|
||||
{}
|
||||
else
|
||||
if (typeof x === \"boolean\")
|
||||
{}
|
||||
else {
|
||||
(x: string);
|
||||
}
|
||||
}
|
||||
|
||||
widen_next().next(0);
|
||||
|
||||
widen_next().next(\"\");
|
||||
|
||||
widen_next().next(true);
|
||||
|
||||
function* widen_yield() {
|
||||
yield 0;
|
||||
|
||||
yield \"\";
|
||||
|
||||
yield true;
|
||||
}
|
||||
|
||||
for (var x of widen_yield()) {
|
||||
if (typeof x === \"number\") {
|
||||
|
||||
} else
|
||||
if (typeof x === \"boolean\") {
|
||||
|
||||
} else {
|
||||
if (typeof x === \"number\")
|
||||
{}
|
||||
else
|
||||
if (typeof x === \"boolean\")
|
||||
{}
|
||||
else {
|
||||
(x: string);
|
||||
}
|
||||
}
|
||||
|
||||
function* delegate_next_generator() {
|
||||
function* inner() {
|
||||
var x: number = yield;
|
||||
}
|
||||
|
||||
yield* inner();
|
||||
}
|
||||
|
||||
delegate_next_generator().next(\"\");
|
||||
|
||||
function* delegate_yield_generator() {
|
||||
function* inner() {
|
||||
yield \"\";
|
||||
}
|
||||
|
||||
yield* inner();
|
||||
}
|
||||
|
||||
for (var x of delegate_yield_generator()) {
|
||||
(x: number);
|
||||
}
|
||||
|
||||
function* delegate_return_generator() {
|
||||
function* inner() {
|
||||
return \"\";
|
||||
}
|
||||
var x: number = yield* inner();
|
||||
}
|
||||
|
||||
function* delegate_next_iterable(xs: Array<number>) {
|
||||
yield* xs;
|
||||
}
|
||||
|
||||
delegate_next_iterable([]).next(\"\");
|
||||
|
||||
function* delegate_yield_iterable(xs: Array<number>) {
|
||||
yield* xs;
|
||||
}
|
||||
|
||||
for (var x of delegate_yield_iterable([])) {
|
||||
(x: string);
|
||||
}
|
||||
|
||||
function* delegate_return_iterable(xs: Array<number>) {
|
||||
var x: void = yield* xs;
|
||||
}
|
||||
|
||||
function* generic_yield<Y>(y: Y): Generator<Y, void, void> {
|
||||
yield y;
|
||||
}
|
||||
|
||||
function* generic_return<R>(r: R): Generator<void, R, void> {
|
||||
return r;
|
||||
}
|
||||
|
||||
function* generic_next<N>(): Generator<void, N, N> {
|
||||
return yield undefined;
|
||||
}
|
||||
|
||||
function* multiple_return(b) {
|
||||
if (b) {
|
||||
return 0;
|
||||
|
@ -579,6 +633,7 @@ function* multiple_return(b) {
|
|||
}
|
||||
}
|
||||
let multiple_return_result = multiple_return().next();
|
||||
|
||||
if (multiple_return_result.done) {
|
||||
(multiple_return_result.value: void);
|
||||
}
|
||||
|
@ -616,8 +671,10 @@ if (refuse_return_result.done) {
|
|||
// error: number | void ~> string
|
||||
function test1(gen: Generator<void, string, void>) {
|
||||
var ret = gen.return(0);
|
||||
|
||||
(ret.value: void);
|
||||
}
|
||||
|
||||
function* refuse_return() {
|
||||
try {
|
||||
yield 1;
|
||||
|
@ -627,6 +684,7 @@ function* refuse_return() {
|
|||
}
|
||||
var refuse_return_gen = refuse_return();
|
||||
var refuse_return_result = refuse_return_gen.return(\"string\");
|
||||
|
||||
if (refuse_return_result.done) {
|
||||
(refuse_return_result.value: string);
|
||||
}
|
||||
|
@ -670,9 +728,11 @@ function* catch_return() {
|
|||
}
|
||||
}
|
||||
var catch_return_value = catch_return().throw(\"\").value;
|
||||
|
||||
if (catch_return_value !== undefined) {
|
||||
(catch_return_value: string);
|
||||
}
|
||||
|
||||
function* yield_return() {
|
||||
try {
|
||||
yield 0;
|
||||
|
@ -682,6 +742,7 @@ function* yield_return() {
|
|||
}
|
||||
}
|
||||
var yield_return_value = yield_return().throw(\"\").value;
|
||||
|
||||
if (yield_return_value !== undefined) {
|
||||
(yield_return_value: string);
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ class D<T> {
|
|||
x: T;
|
||||
m<S>(z: S, u: T, v): S {
|
||||
this.x = u;
|
||||
|
||||
v.u = u;
|
||||
return z;
|
||||
}
|
||||
|
@ -89,6 +90,7 @@ class H<Z> extends G<Array<Z>> {
|
|||
}
|
||||
}
|
||||
var h1 = new H();
|
||||
|
||||
h1.foo([ \"...\" ]);
|
||||
var h2: F<Array<Array<Array<number>>>> = h1;
|
||||
var obj: Object<string, string> = {};
|
||||
|
|
|
@ -38,6 +38,7 @@ var id = geolocation.watchPosition(
|
|||
}
|
||||
}
|
||||
);
|
||||
|
||||
geolocation.clearWatch(id);
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -19,11 +19,14 @@ lib.bar();
|
|||
// t123456
|
||||
// D123456
|
||||
var lib = require(\"./library\");
|
||||
|
||||
function add(a: number, b: number): number {
|
||||
return a + b;
|
||||
}
|
||||
var re = /^keynote (talk){2} (lightning){3,5} (talk){2} closing partytime!!!/;
|
||||
|
||||
add(lib.iTakeAString(42), 7);
|
||||
|
||||
lib.bar();
|
||||
"
|
||||
`;
|
||||
|
@ -43,11 +46,15 @@ things;
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
import thing from \"./helpers/exports_default.js\";
|
||||
|
||||
thing;
|
||||
import { foo, bar as baz } from \"./helpers/exports_named.js\";
|
||||
|
||||
foo;
|
||||
|
||||
baz;
|
||||
import * as things from \"./helpers/exports_named.js\";
|
||||
|
||||
things;
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -6,6 +6,7 @@ module.exports = {ParentFoo};
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
var ParentFoo = { foo: \"bar\" };
|
||||
|
||||
module.exports = { ParentFoo };
|
||||
"
|
||||
`;
|
||||
|
@ -45,14 +46,20 @@ import type {Foo} from \'./types\';
|
|||
// Follows non-destructured property access of \`require(\'Parent\')\`
|
||||
var Parent = require(\"./Parent\");
|
||||
let ParentFoo;
|
||||
|
||||
({ ParentFoo } = Parent);
|
||||
|
||||
ParentFoo;
|
||||
let ParentFoo2;
|
||||
|
||||
ParentFoo2 = Parent;
|
||||
|
||||
ParentFoo2;
|
||||
let ParentFoo3 = Parent;
|
||||
|
||||
ParentFoo3;
|
||||
let foo = require(\"./Parent\").ParentFoo.foo;
|
||||
|
||||
foo;
|
||||
import type { Foo } from \"./types\";
|
||||
"
|
||||
|
@ -73,9 +80,7 @@ class D extends C {
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
class C {
|
||||
override() {
|
||||
|
||||
}
|
||||
override() {}
|
||||
}
|
||||
class D extends C {
|
||||
foo() {
|
||||
|
@ -84,9 +89,7 @@ class D extends C {
|
|||
bar() {
|
||||
this.override;
|
||||
}
|
||||
override() {
|
||||
|
||||
}
|
||||
override() {}
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
@ -109,7 +112,9 @@ class C extends React.Component {
|
|||
props: { x: string };
|
||||
}
|
||||
let msg = \"hello\";
|
||||
|
||||
<C x={msg}/>;
|
||||
|
||||
<div id={msg}/>;
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -28,6 +28,7 @@ require(\'b\');
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
require(\"./a.js\");
|
||||
|
||||
require(\"b\");
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -88,47 +88,42 @@ class Foo {
|
|||
get propWithMatchingGetterAndSetter(): number {
|
||||
return 4;
|
||||
}
|
||||
set propWithMatchingGetterAndSetter(x: number) {
|
||||
|
||||
}
|
||||
set propWithMatchingGetterAndSetter(x: number) {}
|
||||
get propWithSubtypingGetterAndSetter(): ?number {
|
||||
return 4;
|
||||
}
|
||||
set propWithSubtypingGetterAndSetter(x: number) {
|
||||
|
||||
}
|
||||
set propWithSubtypingGetterAndSetterReordered(x: number) {
|
||||
|
||||
}
|
||||
set propWithSubtypingGetterAndSetter(x: number) {}
|
||||
set propWithSubtypingGetterAndSetterReordered(x: number) {}
|
||||
get propWithSubtypingGetterAndSetterReordered(): ?number {
|
||||
return 4;
|
||||
}
|
||||
get propWithMismatchingGetterAndSetter(): number {
|
||||
return 4;
|
||||
}
|
||||
set propWithMismatchingGetterAndSetter(x: string) {
|
||||
|
||||
}
|
||||
set propWithMismatchingGetterAndSetter(x: string) {}
|
||||
propOverriddenWithGetter: number;
|
||||
get propOverriddenWithGetter() {
|
||||
return \"hello\";
|
||||
}
|
||||
propOverriddenWithSetter: number;
|
||||
set propOverriddenWithSetter(x: string) {
|
||||
|
||||
}
|
||||
set propOverriddenWithSetter(x: string) {}
|
||||
}
|
||||
var foo = new Foo();
|
||||
var testGetterNoError1: number = foo.goodGetterNoAnnotation;
|
||||
var testGetterNoError2: number = foo.goodGetterWithAnnotation;
|
||||
var testGetterWithError1: string = foo.goodGetterNoAnnotation;
|
||||
var testGetterWithError2: string = foo.goodGetterWithAnnotation;
|
||||
|
||||
foo.goodSetterNoAnnotation = 123;
|
||||
|
||||
foo.goodSetterWithAnnotation = 123;
|
||||
|
||||
foo.goodSetterNoAnnotation = \"hello\";
|
||||
|
||||
foo.goodSetterWithAnnotation = \"hello\";
|
||||
var testSubtypingGetterAndSetter: number = foo.propWithSubtypingGetterAndSetter;
|
||||
var testPropOverridenWithGetter: number = foo.propOverriddenWithGetter;
|
||||
|
||||
foo.propOverriddenWithSetter = 123;
|
||||
"
|
||||
`;
|
||||
|
@ -234,30 +229,20 @@ var obj = {
|
|||
get propWithMatchingGetterAndSetter(): number {
|
||||
return 4;
|
||||
},
|
||||
set propWithMatchingGetterAndSetter(x: number) {
|
||||
|
||||
},
|
||||
set propWithMatchingGetterAndSetter(x: number) {},
|
||||
get propWithSubtypingGetterAndSetter(): ?number {
|
||||
return 4;
|
||||
},
|
||||
set propWithSubtypingGetterAndSetter(x: number) {
|
||||
|
||||
},
|
||||
set propWithSubtypingGetterAndSetterReordered(x: number) {
|
||||
|
||||
},
|
||||
set propWithSubtypingGetterAndSetter(x: number) {},
|
||||
set propWithSubtypingGetterAndSetterReordered(x: number) {},
|
||||
get propWithSubtypingGetterAndSetterReordered(): ?number {
|
||||
return 4;
|
||||
},
|
||||
get exampleOfOrderOfGetterAndSetter(): A {
|
||||
return new A();
|
||||
},
|
||||
set exampleOfOrderOfGetterAndSetter(x: B) {
|
||||
|
||||
},
|
||||
set exampleOfOrderOfGetterAndSetterReordered(x: B) {
|
||||
|
||||
},
|
||||
set exampleOfOrderOfGetterAndSetter(x: B) {},
|
||||
set exampleOfOrderOfGetterAndSetterReordered(x: B) {},
|
||||
get exampleOfOrderOfGetterAndSetterReordered(): A {
|
||||
return new A();
|
||||
}
|
||||
|
@ -266,11 +251,16 @@ var testGetterNoError1: number = obj.goodGetterNoAnnotation;
|
|||
var testGetterNoError2: number = obj.goodGetterWithAnnotation;
|
||||
var testGetterWithError1: string = obj.goodGetterNoAnnotation;
|
||||
var testGetterWithError2: string = obj.goodGetterWithAnnotation;
|
||||
|
||||
obj.goodSetterNoAnnotation = 123;
|
||||
|
||||
obj.goodSetterWithAnnotation = 123;
|
||||
|
||||
obj.goodSetterNoAnnotation = \"hello\";
|
||||
|
||||
obj.goodSetterWithAnnotation = \"hello\";
|
||||
var testSubtypingGetterAndSetter: number = obj.propWithSubtypingGetterAndSetter;
|
||||
|
||||
obj.exampleOfOrderOfGetterAndSetter = new C();
|
||||
var testExampleOrOrderOfGetterAndSetterReordered: number = obj.exampleOfOrderOfGetterAndSetterReordered;
|
||||
"
|
||||
|
@ -412,50 +402,52 @@ class Base {
|
|||
this.x = value;
|
||||
}
|
||||
}
|
||||
|
||||
(class extends Base {
|
||||
get x(): B {
|
||||
return b;
|
||||
}
|
||||
});
|
||||
(class extends Base {
|
||||
set x(value: B): void {
|
||||
|
||||
}
|
||||
(class extends Base {
|
||||
set x(value: B): void {}
|
||||
});
|
||||
|
||||
(class extends Base {
|
||||
get x(): C {
|
||||
return c;
|
||||
}
|
||||
set x(value: A): void {
|
||||
|
||||
}
|
||||
set x(value: A): void {}
|
||||
});
|
||||
|
||||
(class extends Base {
|
||||
set pos(value: B): void {
|
||||
|
||||
}
|
||||
set pos(value: B): void {}
|
||||
});
|
||||
|
||||
(class extends Base {
|
||||
get pos(): C {
|
||||
return c;
|
||||
}
|
||||
});
|
||||
|
||||
(class extends Base {
|
||||
get neg(): B {
|
||||
return b;
|
||||
}
|
||||
});
|
||||
(class extends Base {
|
||||
set neg(value: A): void {
|
||||
|
||||
}
|
||||
(class extends Base {
|
||||
set neg(value: A): void {}
|
||||
});
|
||||
|
||||
(class extends Base {
|
||||
get: C;
|
||||
});
|
||||
|
||||
(class extends Base {
|
||||
set: A;
|
||||
});
|
||||
|
||||
(class extends Base {
|
||||
getset: B;
|
||||
});
|
||||
|
|
|
@ -22,9 +22,11 @@ module.exports = foo;
|
|||
\'Required module not found\'.
|
||||
*/
|
||||
var _ = require(\"underscore\");
|
||||
|
||||
function foo(): string {
|
||||
return _.foo();
|
||||
}
|
||||
|
||||
module.exports = foo;
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -21,6 +21,7 @@ class B extends A {
|
|||
}
|
||||
class C extends A {}
|
||||
var a: A = new B();
|
||||
|
||||
a.foo = function(): C {
|
||||
return new C();
|
||||
};
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue