Add spaces around certain statements, add --write option, and more
parent
8861953e60
commit
c9e24eb477
|
@ -1,16 +1,28 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const argv = require("minimist")(process.argv.slice(2));
|
const minimist = require("minimist");
|
||||||
const jscodefmt = require("../index");
|
const jscodefmt = require("../index");
|
||||||
|
|
||||||
|
const argv = minimist(process.argv.slice(2), {
|
||||||
|
boolean: ["write", "useFlowParser"]
|
||||||
|
});
|
||||||
|
|
||||||
const filename = argv["_"][0];
|
const filename = argv["_"][0];
|
||||||
const printWidth = argv['print-width'] || 80;
|
const printWidth = argv['print-width'] || 80;
|
||||||
const tabWidth = argv['tab-width'] || 2;
|
const tabWidth = argv['tab-width'] || 2;
|
||||||
const useFlowParser = argv['flow-parser'];
|
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,
|
printWidth,
|
||||||
tabWidth,
|
tabWidth,
|
||||||
useFlowParser
|
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 });
|
const printer = new Printer({ tabWidth, wrapColumn: printWidth });
|
||||||
return printer.printGenerically(ast).code;
|
return printer.printGenerically(ast).code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,9 +59,6 @@ function iterDoc(topDoc, func) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(doc.type !== "line") {
|
else if(doc.type !== "line") {
|
||||||
if(doc.contents == null) {
|
|
||||||
console.log("JWL", doc);
|
|
||||||
}
|
|
||||||
docs.push(doc.contents);
|
docs.push(doc.contents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,7 +233,7 @@ function genericPrintNoParens(path, options, print) {
|
||||||
// Babel 6
|
// Babel 6
|
||||||
if (n.directives) {
|
if (n.directives) {
|
||||||
path.each(function(childPath) {
|
path.each(function(childPath) {
|
||||||
parts.push(print(childPath), ";", line);
|
parts.push(print(childPath), ";", hardline);
|
||||||
}, "directives");
|
}, "directives");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -566,6 +566,11 @@ function genericPrintNoParens(path, options, print) {
|
||||||
return printStatementSequence(bodyPath, options, print);
|
return printStatementSequence(bodyPath, options, print);
|
||||||
}, "body");
|
}, "body");
|
||||||
|
|
||||||
|
// If there are no contents, return a simple block
|
||||||
|
if(!getFirstString(naked)) {
|
||||||
|
return "{}";
|
||||||
|
}
|
||||||
|
|
||||||
parts.push("{");
|
parts.push("{");
|
||||||
// Babel 6
|
// Babel 6
|
||||||
if (n.directives) {
|
if (n.directives) {
|
||||||
|
@ -700,6 +705,10 @@ function genericPrintNoParens(path, options, print) {
|
||||||
|
|
||||||
case "ArrayExpression":
|
case "ArrayExpression":
|
||||||
case "ArrayPattern":
|
case "ArrayPattern":
|
||||||
|
if(n.elements.length === 0) {
|
||||||
|
parts.push("[]");
|
||||||
|
}
|
||||||
|
else {
|
||||||
parts.push(multilineGroup(concat([
|
parts.push(multilineGroup(concat([
|
||||||
"[",
|
"[",
|
||||||
indent(options.tabWidth,
|
indent(options.tabWidth,
|
||||||
|
@ -711,6 +720,7 @@ function genericPrintNoParens(path, options, print) {
|
||||||
line,
|
line,
|
||||||
"]"
|
"]"
|
||||||
])));
|
])));
|
||||||
|
}
|
||||||
|
|
||||||
if (n.typeAnnotation)
|
if (n.typeAnnotation)
|
||||||
parts.push(path.call(print, "typeAnnotation"));
|
parts.push(path.call(print, "typeAnnotation"));
|
||||||
|
@ -835,8 +845,9 @@ function genericPrintNoParens(path, options, print) {
|
||||||
]);
|
]);
|
||||||
|
|
||||||
case "IfStatement":
|
case "IfStatement":
|
||||||
var con = adjustClause(path.call(print, "consequent"), options);
|
const con = adjustClause(path.call(print, "consequent"), options);
|
||||||
var parts = [
|
|
||||||
|
parts = [
|
||||||
"if (",
|
"if (",
|
||||||
group(concat([
|
group(concat([
|
||||||
indent(options.tabWidth, concat([
|
indent(options.tabWidth, concat([
|
||||||
|
@ -976,7 +987,8 @@ function genericPrintNoParens(path, options, print) {
|
||||||
case "LabeledStatement":
|
case "LabeledStatement":
|
||||||
return concat([
|
return concat([
|
||||||
path.call(print, "label"),
|
path.call(print, "label"),
|
||||||
":\n",
|
":",
|
||||||
|
hardline,
|
||||||
path.call(print, "body")
|
path.call(print, "body")
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -1617,7 +1629,7 @@ function printStatementSequence(path, options, print) {
|
||||||
|
|
||||||
var printed = [];
|
var printed = [];
|
||||||
|
|
||||||
path.map(function(stmtPath) {
|
path.map(function(stmtPath, i) {
|
||||||
var stmt = stmtPath.getValue();
|
var stmt = stmtPath.getValue();
|
||||||
|
|
||||||
// Just in case the AST has been modified to contain falsy
|
// Just in case the AST has been modified to contain falsy
|
||||||
|
@ -1632,35 +1644,26 @@ function printStatementSequence(path, options, print) {
|
||||||
return;
|
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);
|
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) {
|
function printMethod(path, options, print) {
|
||||||
var node = path.getNode();
|
var node = path.getNode();
|
||||||
var kind = node.kind;
|
var kind = node.kind;
|
||||||
|
@ -1935,3 +1938,26 @@ function nodeStr(str, options) {
|
||||||
return JSON.stringify(str);
|
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,9 +12,10 @@ function foo() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function bar() {
|
function bar() {
|
||||||
L:
|
L:
|
||||||
do {
|
do {
|
||||||
continue L;
|
continue L;
|
||||||
} while (false);
|
} while (false);
|
||||||
}
|
}
|
||||||
|
@ -29,13 +30,14 @@ function foo() {
|
||||||
bar(x);
|
bar(x);
|
||||||
}
|
}
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
function bar(x: number) {
|
function bar(x: number) {}
|
||||||
|
|
||||||
}
|
|
||||||
function foo() {
|
function foo() {
|
||||||
var x = null;
|
var x = null;
|
||||||
|
|
||||||
if (x == null)
|
if (x == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bar(x);
|
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;
|
var array_of_tuple_parens: [number, string][] = array_of_tuple;
|
||||||
type ObjType = { \"bar-foo\": string; \"foo-bar\": number };
|
type ObjType = { \"bar-foo\": string; \"foo-bar\": number };
|
||||||
var test_obj: ObjType = { \"bar-foo\": \"23\" };
|
var test_obj: ObjType = { \"bar-foo\": \"23\" };
|
||||||
|
|
||||||
function param_anno(n: number): void {
|
function param_anno(n: number): void {
|
||||||
n = \"hey\";
|
n = \"hey\";
|
||||||
}
|
}
|
||||||
|
|
||||||
function param_anno2(
|
function param_anno2(
|
||||||
batchRequests: Array<{ method: string; path: string; params: ?Object }>
|
batchRequests: Array<{ method: string; path: string; params: ?Object }>
|
||||||
): void {
|
): void {
|
||||||
|
@ -111,9 +113,11 @@ function param_anno2(
|
||||||
}
|
}
|
||||||
var toz: null = 3;
|
var toz: null = 3;
|
||||||
var zer: null = null;
|
var zer: null = null;
|
||||||
|
|
||||||
function foobar(n: ?number): number | null | void {
|
function foobar(n: ?number): number | null | void {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
function barfoo(n: number | null | void): ?number {
|
function barfoo(n: number | null | void): ?number {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
@ -142,12 +146,15 @@ function foo() {
|
||||||
// ok (no confusion across scopes)
|
// ok (no confusion across scopes)
|
||||||
// looked up above
|
// looked up above
|
||||||
let myClassInstance: MyClass = null;
|
let myClassInstance: MyClass = null;
|
||||||
|
|
||||||
function bar(): MyClass {
|
function bar(): MyClass {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
class MyClass {}
|
class MyClass {}
|
||||||
|
|
||||||
function foo() {
|
function foo() {
|
||||||
let myClassInstance: MyClass = mk();
|
let myClassInstance: MyClass = mk();
|
||||||
|
|
||||||
function mk() {
|
function mk() {
|
||||||
return new MyClass();
|
return new MyClass();
|
||||||
}
|
}
|
||||||
|
@ -161,9 +168,8 @@ exports[`test issue-530.js 1`] = `
|
||||||
|
|
||||||
module.exports = foo;
|
module.exports = foo;
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
function foo(...args: any) {
|
function foo(...args: any) {}
|
||||||
|
|
||||||
}
|
|
||||||
module.exports = foo;
|
module.exports = foo;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -204,9 +210,11 @@ function bar(y: MyObj): string {
|
||||||
* leading to an error.
|
* leading to an error.
|
||||||
*/
|
*/
|
||||||
type MyObj = Object;
|
type MyObj = Object;
|
||||||
|
|
||||||
function foo(x: { [key: string]: mixed }) {
|
function foo(x: { [key: string]: mixed }) {
|
||||||
bar(x);
|
bar(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bar(y: MyObj): string {
|
function bar(y: MyObj): string {
|
||||||
return y.foo;
|
return y.foo;
|
||||||
}
|
}
|
||||||
|
@ -218,6 +226,7 @@ exports[`test other.js 1`] = `
|
||||||
module.exports = (C: any);
|
module.exports = (C: any);
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
class C {}
|
class C {}
|
||||||
|
|
||||||
module.exports = (C: any);
|
module.exports = (C: any);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -255,6 +264,7 @@ declare class Map<K, V> {
|
||||||
insertWith(fn: Merge<V>, k: K, v: V): 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;
|
declare function foldr<A, B>(fn: (a: A, b: B) => B, b: B, as: A[]): B;
|
||||||
|
|
||||||
function insertMany<K, V>(
|
function insertMany<K, V>(
|
||||||
merge: Merge<V>, vs: [K, V][], m: Map<K, V>
|
merge: Merge<V>, vs: [K, V][], m: Map<K, V>
|
||||||
): Map<K, V> {
|
): Map<K, V> {
|
||||||
|
@ -278,6 +288,7 @@ exports[`test test.js 1`] = `
|
||||||
((0: C): string);
|
((0: C): string);
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
var C = require(\"./other\");
|
var C = require(\"./other\");
|
||||||
|
|
||||||
((0: C): string);
|
((0: C): string);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -13,9 +13,11 @@ var z:string = qux(0);
|
||||||
function foo(x: any): any {
|
function foo(x: any): any {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function bar(x: any): mixed {
|
function bar(x: any): mixed {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function qux(x: mixed): any {
|
function qux(x: mixed): any {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
@ -68,12 +70,15 @@ var w:string = baz(0);
|
||||||
function foo(x: $FlowFixMe): $FlowFixMe {
|
function foo(x: $FlowFixMe): $FlowFixMe {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function bar(x: $FlowFixMe): mixed {
|
function bar(x: $FlowFixMe): mixed {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function qux(x: $FlowFixMe<number>): $FlowFixMe<number> {
|
function qux(x: $FlowFixMe<number>): $FlowFixMe<number> {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function baz(x: $FlowFixMe<nnumber>): $FlowFixMe<number> {
|
function baz(x: $FlowFixMe<nnumber>): $FlowFixMe<number> {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
@ -117,12 +122,15 @@ var w:string = baz(0);
|
||||||
function foo(x: $FlowIssue): $FlowIssue {
|
function foo(x: $FlowIssue): $FlowIssue {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function bar(x: $FlowIssue): mixed {
|
function bar(x: $FlowIssue): mixed {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function qux(x: $FlowIssue<number>): $FlowIssue<number> {
|
function qux(x: $FlowIssue<number>): $FlowIssue<number> {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function baz(x: $FlowIssue<nnumber>): $FlowIssue<number> {
|
function baz(x: $FlowIssue<nnumber>): $FlowIssue<number> {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
@ -176,17 +184,20 @@ declare class C {
|
||||||
bar(n1: number, n2: number): number;
|
bar(n1: number, n2: number): number;
|
||||||
bar(s1: string, s2: string): string
|
bar(s1: string, s2: string): string
|
||||||
}
|
}
|
||||||
|
|
||||||
function foo(c: C, x: any): string {
|
function foo(c: C, x: any): string {
|
||||||
let y = x.y;
|
let y = x.y;
|
||||||
return c.bar(0, y);
|
return c.bar(0, y);
|
||||||
}
|
}
|
||||||
var any_fun1 = require(\"./nonflowfile\");
|
var any_fun1 = require(\"./nonflowfile\");
|
||||||
|
|
||||||
function bar1(x: mixed) {
|
function bar1(x: mixed) {
|
||||||
if (any_fun1(x)) {
|
if (any_fun1(x)) {
|
||||||
(x: boolean);
|
(x: boolean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var any_fun2 = require(\"./anyexportflowfile\");
|
var any_fun2 = require(\"./anyexportflowfile\");
|
||||||
|
|
||||||
function bar2(x: mixed) {
|
function bar2(x: mixed) {
|
||||||
if (any_fun2(x)) {
|
if (any_fun2(x)) {
|
||||||
(x: boolean);
|
(x: boolean);
|
||||||
|
@ -216,6 +227,7 @@ function foo(o: ?AsyncRequest) {
|
||||||
* annotation - without it, the body of the if will be unreachable
|
* annotation - without it, the body of the if will be unreachable
|
||||||
*/
|
*/
|
||||||
type AsyncRequest = any;
|
type AsyncRequest = any;
|
||||||
|
|
||||||
function foo(o: ?AsyncRequest) {
|
function foo(o: ?AsyncRequest) {
|
||||||
if (o) {
|
if (o) {
|
||||||
var n: number = o;
|
var n: number = o;
|
||||||
|
|
|
@ -132,76 +132,113 @@ let tests = [
|
||||||
// ok
|
// ok
|
||||||
// error, string ~> empty
|
// error, string ~> empty
|
||||||
// error, string ~> empty
|
// error, string ~> empty
|
||||||
function num(x: number) {
|
function num(x: number) {}
|
||||||
|
|
||||||
}
|
function str(x: string) {}
|
||||||
function str(x: string) {
|
|
||||||
|
|
||||||
}
|
|
||||||
function foo() {
|
function foo() {
|
||||||
var x = 0;
|
var x = 0;
|
||||||
var y = \"...\";
|
var y = \"...\";
|
||||||
var z = {};
|
var z = {};
|
||||||
|
|
||||||
num(x + x);
|
num(x + x);
|
||||||
|
|
||||||
num(x + y);
|
num(x + y);
|
||||||
|
|
||||||
str(x + y);
|
str(x + y);
|
||||||
|
|
||||||
str(x + x);
|
str(x + x);
|
||||||
|
|
||||||
str(z + y);
|
str(z + y);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bar0(x: ?number, y: number) {
|
function bar0(x: ?number, y: number) {
|
||||||
num(x + y);
|
num(x + y);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bar1(x: number, y: ?number) {
|
function bar1(x: number, y: ?number) {
|
||||||
num(x + y);
|
num(x + y);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bar2(x?: number, y: number) {
|
function bar2(x?: number, y: number) {
|
||||||
num(x + y);
|
num(x + y);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bar3(x: number, y?: number) {
|
function bar3(x: number, y?: number) {
|
||||||
num(x + y);
|
num(x + y);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bar4(x?: ?number, y: number) {
|
function bar4(x?: ?number, y: number) {
|
||||||
num(x + y);
|
num(x + y);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bar5(x: number, y?: ?number) {
|
function bar5(x: number, y?: ?number) {
|
||||||
num(x + y);
|
num(x + y);
|
||||||
}
|
}
|
||||||
|
|
||||||
num(null + null);
|
num(null + null);
|
||||||
|
|
||||||
num(undefined + undefined);
|
num(undefined + undefined);
|
||||||
|
|
||||||
num(null + 1);
|
num(null + 1);
|
||||||
|
|
||||||
num(1 + null);
|
num(1 + null);
|
||||||
|
|
||||||
num(undefined + 1);
|
num(undefined + 1);
|
||||||
|
|
||||||
num(1 + undefined);
|
num(1 + undefined);
|
||||||
|
|
||||||
num(null + true);
|
num(null + true);
|
||||||
|
|
||||||
num(true + null);
|
num(true + null);
|
||||||
|
|
||||||
num(undefined + true);
|
num(undefined + true);
|
||||||
|
|
||||||
num(true + undefined);
|
num(true + undefined);
|
||||||
|
|
||||||
str(\"foo\" + true);
|
str(\"foo\" + true);
|
||||||
|
|
||||||
str(true + \"foo\");
|
str(true + \"foo\");
|
||||||
|
|
||||||
str(\"foo\" + null);
|
str(\"foo\" + null);
|
||||||
|
|
||||||
str(null + \"foo\");
|
str(null + \"foo\");
|
||||||
|
|
||||||
str(\"foo\" + undefined);
|
str(\"foo\" + undefined);
|
||||||
|
|
||||||
str(undefined + \"foo\");
|
str(undefined + \"foo\");
|
||||||
let tests = [
|
let tests = [
|
||||||
function(x: mixed, y: mixed) {
|
function(x: mixed, y: mixed) {
|
||||||
x + y;
|
x + y;
|
||||||
|
|
||||||
x + 0;
|
x + 0;
|
||||||
|
|
||||||
0 + x;
|
0 + x;
|
||||||
|
|
||||||
x + \"\";
|
x + \"\";
|
||||||
|
|
||||||
\"\" + x;
|
\"\" + x;
|
||||||
|
|
||||||
x + {};
|
x + {};
|
||||||
|
|
||||||
({}) + x;
|
({}) + x;
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
(1 + {}: number);
|
(1 + {}: number);
|
||||||
|
|
||||||
({} + 1: number);
|
({} + 1: number);
|
||||||
|
|
||||||
(\"1\" + {}: string);
|
(\"1\" + {}: string);
|
||||||
|
|
||||||
({} + \"1\": string);
|
({} + \"1\": string);
|
||||||
},
|
},
|
||||||
function(x: any, y: number, z: string) {
|
function(x: any, y: number, z: string) {
|
||||||
(x + y: string);
|
(x + y: string);
|
||||||
|
|
||||||
(y + x: string);
|
(y + x: string);
|
||||||
|
|
||||||
(x + z: empty);
|
(x + z: empty);
|
||||||
|
|
||||||
(z + x: empty);
|
(z + x: empty);
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -224,11 +261,16 @@ y **= 2; // error
|
||||||
/* @flow */
|
/* @flow */
|
||||||
// error
|
// error
|
||||||
let x: number = 2 ** 3;
|
let x: number = 2 ** 3;
|
||||||
|
|
||||||
x **= 4;
|
x **= 4;
|
||||||
let y: string = \"123\";
|
let y: string = \"123\";
|
||||||
|
|
||||||
y **= 2;
|
y **= 2;
|
||||||
|
|
||||||
1 + 2 ** 3 + 4;
|
1 + 2 ** 3 + 4;
|
||||||
|
|
||||||
2 ** 2;
|
2 ** 2;
|
||||||
|
|
||||||
(-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 {
|
function f<A>(a: A): A {
|
||||||
return a + a;
|
return a + a;
|
||||||
}
|
}
|
||||||
|
|
||||||
function f<A, B>(a: A, b: B): A {
|
function f<A, B>(a: A, b: B): A {
|
||||||
return a + b;
|
return a + b;
|
||||||
}
|
}
|
||||||
|
|
||||||
function f<A, B>(a: A, b: B): A {
|
function f<A, B>(a: A, b: B): A {
|
||||||
return b + a;
|
return b + a;
|
||||||
}
|
}
|
||||||
|
|
||||||
function f<A, B>(a: A, b: B): B {
|
function f<A, B>(a: A, b: B): B {
|
||||||
return a + b;
|
return a + b;
|
||||||
}
|
}
|
||||||
|
|
||||||
function f<A, B>(a: A, b: B): B {
|
function f<A, B>(a: A, b: B): B {
|
||||||
return b + a;
|
return b + a;
|
||||||
}
|
}
|
||||||
|
@ -282,14 +328,16 @@ y *= 2; // error
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
/* @flow */
|
/* @flow */
|
||||||
// error
|
// error
|
||||||
function num(x: number) {
|
function num(x: number) {}
|
||||||
|
|
||||||
}
|
|
||||||
num(null * 1);
|
num(null * 1);
|
||||||
|
|
||||||
num(1 * null);
|
num(1 * null);
|
||||||
let x: number = 2 * 3;
|
let x: number = 2 * 3;
|
||||||
|
|
||||||
x *= 4;
|
x *= 4;
|
||||||
let y: string = \"123\";
|
let y: string = \"123\";
|
||||||
|
|
||||||
y *= 2;
|
y *= 2;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -341,27 +389,45 @@ let tests = [
|
||||||
// error
|
// error
|
||||||
// error
|
// error
|
||||||
1 < 2;
|
1 < 2;
|
||||||
|
|
||||||
1 < \"foo\";
|
1 < \"foo\";
|
||||||
|
|
||||||
\"foo\" < 1;
|
\"foo\" < 1;
|
||||||
|
|
||||||
\"foo\" < \"bar\";
|
\"foo\" < \"bar\";
|
||||||
|
|
||||||
1 < { foo: 1 };
|
1 < { foo: 1 };
|
||||||
|
|
||||||
({ foo: 1 }) < 1;
|
({ foo: 1 }) < 1;
|
||||||
|
|
||||||
({ foo: 1 }) < { foo: 1 };
|
({ foo: 1 }) < { foo: 1 };
|
||||||
|
|
||||||
\"foo\" < { foo: 1 };
|
\"foo\" < { foo: 1 };
|
||||||
|
|
||||||
({ foo: 1 }) < \"foo\";
|
({ foo: 1 }) < \"foo\";
|
||||||
var x = (null: ?number);
|
var x = (null: ?number);
|
||||||
|
|
||||||
1 < x;
|
1 < x;
|
||||||
|
|
||||||
x < 1;
|
x < 1;
|
||||||
|
|
||||||
null < null;
|
null < null;
|
||||||
|
|
||||||
undefined < null;
|
undefined < null;
|
||||||
|
|
||||||
null < undefined;
|
null < undefined;
|
||||||
|
|
||||||
undefined < undefined;
|
undefined < undefined;
|
||||||
|
|
||||||
NaN < 1;
|
NaN < 1;
|
||||||
|
|
||||||
1 < NaN;
|
1 < NaN;
|
||||||
|
|
||||||
NaN < NaN;
|
NaN < NaN;
|
||||||
let tests = [
|
let tests = [
|
||||||
function(x: any, y: number, z: string) {
|
function(x: any, y: number, z: string) {
|
||||||
x > y;
|
x > y;
|
||||||
|
|
||||||
x > z;
|
x > z;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
@ -13,6 +13,7 @@ function filterOutSmall (arr: Array<?number>): Array<?number> {
|
||||||
function filterOutVoids<T>(arr: Array<?T>): Array<T> {
|
function filterOutVoids<T>(arr: Array<?T>): Array<T> {
|
||||||
return arr.filter(Boolean);
|
return arr.filter(Boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterOutSmall(arr: Array<?number>): Array<?number> {
|
function filterOutSmall(arr: Array<?number>): Array<?number> {
|
||||||
return arr.filter(num => num && num > 10);
|
return arr.filter(num => num && num > 10);
|
||||||
}
|
}
|
||||||
|
@ -49,6 +50,7 @@ function filterItems(items: Array<string | number>): Array<string | number> {
|
||||||
).filter(Boolean);
|
).filter(Boolean);
|
||||||
}
|
}
|
||||||
const filteredItems = filterItems([ \"foo\", \"b\", 1, 2 ]);
|
const filteredItems = filterItems([ \"foo\", \"b\", 1, 2 ]);
|
||||||
|
|
||||||
console.log(filteredItems);
|
console.log(filteredItems);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -11,7 +11,9 @@ var y: Array<string> = [\'3\', ...x];
|
||||||
var A = [ 1, 2, 3 ];
|
var A = [ 1, 2, 3 ];
|
||||||
var B = [ ...A ];
|
var B = [ ...A ];
|
||||||
var C = [ 1, 2, 3 ];
|
var C = [ 1, 2, 3 ];
|
||||||
|
|
||||||
B.sort((a, b) => a - b);
|
B.sort((a, b) => a - b);
|
||||||
|
|
||||||
C.sort((a, b) => a - b);
|
C.sort((a, b) => a - b);
|
||||||
var x: Array<string> = [ \"1\", \"2\" ];
|
var x: Array<string> = [ \"1\", \"2\" ];
|
||||||
var y: Array<string> = [ \"3\", ...x ];
|
var y: Array<string> = [ \"3\", ...x ];
|
||||||
|
|
|
@ -66,9 +66,7 @@ function from_test() {
|
||||||
// acc is element type of array when no init is provided
|
// acc is element type of array when no init is provided
|
||||||
// error, string ~> number
|
// error, string ~> number
|
||||||
// error, string ~> number
|
// error, string ~> number
|
||||||
function foo(x: string) {
|
function foo(x: string) {}
|
||||||
|
|
||||||
}
|
|
||||||
var a = [ 0 ];
|
var a = [ 0 ];
|
||||||
var b = a.map(
|
var b = a.map(
|
||||||
function(x) {
|
function(x) {
|
||||||
|
@ -92,12 +90,14 @@ var k: Array<number> = h.concat(h);
|
||||||
var l: Array<number> = h.concat(1, 2, 3);
|
var l: Array<number> = h.concat(1, 2, 3);
|
||||||
var m: Array<number | string> = h.concat(\"a\", \"b\", \"c\");
|
var m: Array<number | string> = h.concat(\"a\", \"b\", \"c\");
|
||||||
var n: Array<number> = h.concat(\"a\", \"b\", \"c\");
|
var n: Array<number> = h.concat(\"a\", \"b\", \"c\");
|
||||||
|
|
||||||
function reduce_test() {
|
function reduce_test() {
|
||||||
[ 0, 1, 2, 3, 4 ].reduce(
|
[ 0, 1, 2, 3, 4 ].reduce(
|
||||||
function(previousValue, currentValue, index, array) {
|
function(previousValue, currentValue, index, array) {
|
||||||
return previousValue + currentValue + array[index];
|
return previousValue + currentValue + array[index];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
[ 0, 1, 2, 3, 4 ].reduce(
|
[ 0, 1, 2, 3, 4 ].reduce(
|
||||||
function(previousValue, currentValue, index, array) {
|
function(previousValue, currentValue, index, array) {
|
||||||
return previousValue + currentValue + array[index];
|
return previousValue + currentValue + array[index];
|
||||||
|
@ -114,9 +114,12 @@ function reduce_test() {
|
||||||
return a.concat(b);
|
return a.concat(b);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
[ \"\" ].reduce((acc, str) => acc * str.length);
|
[ \"\" ].reduce((acc, str) => acc * str.length);
|
||||||
|
|
||||||
[ \"\" ].reduceRight((acc, str) => acc * str.length);
|
[ \"\" ].reduceRight((acc, str) => acc * str.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
function from_test() {
|
function from_test() {
|
||||||
var a: Array<string> = Array.from(
|
var a: Array<string> = Array.from(
|
||||||
[ 1, 2, 3 ],
|
[ 1, 2, 3 ],
|
||||||
|
|
|
@ -42,14 +42,16 @@ module.exports = \"arrays\";
|
||||||
/* @providesModule Arrays */
|
/* @providesModule Arrays */
|
||||||
// for literals, composite element type is union of individuals
|
// for literals, composite element type is union of individuals
|
||||||
// note: test both tuple and non-tuple inferred literals
|
// note: test both tuple and non-tuple inferred literals
|
||||||
function foo(x: string) {
|
function foo(x: string) {}
|
||||||
|
var a = [];
|
||||||
|
|
||||||
}
|
|
||||||
var a = [ ];
|
|
||||||
a[0] = 1;
|
a[0] = 1;
|
||||||
|
|
||||||
a[1] = \"...\";
|
a[1] = \"...\";
|
||||||
|
|
||||||
foo(a[1]);
|
foo(a[1]);
|
||||||
var y;
|
var y;
|
||||||
|
|
||||||
a.forEach(x => y = x);
|
a.forEach(x => y = x);
|
||||||
var alittle: Array<?number> = [ 0, 1, 2, 3, null ];
|
var alittle: Array<?number> = [ 0, 1, 2, 3, null ];
|
||||||
var abig: Array<?number> = [ 0, 1, 2, 3, 4, 5, 6, 8, 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: 1 },
|
||||||
{ x: 0, y: 0, c: \"hey\" }
|
{ x: 0, y: 0, c: \"hey\" }
|
||||||
];
|
];
|
||||||
|
|
||||||
module.exports = \"arrays\";
|
module.exports = \"arrays\";
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -88,9 +91,11 @@ arr[day] = 0;
|
||||||
// Date instances are numeric (see Flow_js.numeric) and thus can index into
|
// Date instances are numeric (see Flow_js.numeric) and thus can index into
|
||||||
// arrays.
|
// arrays.
|
||||||
// error: number ~> string
|
// error: number ~> string
|
||||||
var arr = [ ];
|
var arr = [];
|
||||||
var day = new Date();
|
var day = new Date();
|
||||||
|
|
||||||
arr[day] = 0;
|
arr[day] = 0;
|
||||||
|
|
||||||
(arr[day]: string);
|
(arr[day]: string);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -19,7 +19,9 @@ var ident = <T>(x: T): T => x;
|
||||||
var add = (x: number, y: number): number => x + y;
|
var add = (x: number, y: number): number => x + y;
|
||||||
var bad = (x: number): string => x;
|
var bad = (x: number): string => x;
|
||||||
var ident = <T>(x: T): T => x;
|
var ident = <T>(x: T): T => x;
|
||||||
|
|
||||||
(ident(1): number);
|
(ident(1): number);
|
||||||
|
|
||||||
(ident(\"hi\"): number);
|
(ident(\"hi\"): number);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -41,6 +43,7 @@ function selectBestEffortImageForWidth(
|
||||||
maxWidth: number, images: Array<Image>
|
maxWidth: number, images: Array<Image>
|
||||||
): Image {
|
): Image {
|
||||||
var maxPixelWidth = maxWidth;
|
var maxPixelWidth = maxWidth;
|
||||||
|
|
||||||
images = images.sort((a, b) => a.width - b.width + \"\");
|
images = images.sort((a, b) => a.width - b.width + \"\");
|
||||||
return images.find(image => image.width >= maxPixelWidth) ||
|
return images.find(image => image.width >= maxPixelWidth) ||
|
||||||
images[images.length - 1];
|
images[images.length - 1];
|
||||||
|
|
|
@ -71,17 +71,21 @@ var objf : () => Promise<number> = obj.f;
|
||||||
async function f0(): Promise<number> {
|
async function f0(): Promise<number> {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function f1(): Promise<boolean> {
|
async function f1(): Promise<boolean> {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function f2(p: Promise<number>): Promise<number> {
|
async function f2(p: Promise<number>): Promise<number> {
|
||||||
var x: number = await p;
|
var x: number = await p;
|
||||||
var y: number = await 1;
|
var y: number = await 1;
|
||||||
return x + y;
|
return x + y;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function f3(p: Promise<number>): Promise<number> {
|
async function f3(p: Promise<number>): Promise<number> {
|
||||||
return await p;
|
return await p;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function f4(p: Promise<number>): Promise<boolean> {
|
async function f4(p: Promise<number>): Promise<boolean> {
|
||||||
return await p;
|
return await p;
|
||||||
}
|
}
|
||||||
|
@ -131,6 +135,7 @@ var P: Promise<Class<C>> = new Promise(
|
||||||
resolve(C);
|
resolve(C);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
async function foo() {
|
async function foo() {
|
||||||
class Bar extends (await P) {}
|
class Bar extends (await P) {}
|
||||||
return Bar;
|
return Bar;
|
||||||
|
@ -164,51 +169,23 @@ console.log(x.async);
|
||||||
var async = 3;
|
var async = 3;
|
||||||
var y = { async };
|
var y = { async };
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
async function f() {
|
async function f() {}
|
||||||
|
|
||||||
}
|
async function ft<T>(a: T) {}
|
||||||
async function ft<T>(a: T) {
|
|
||||||
|
|
||||||
}
|
|
||||||
class C {
|
class C {
|
||||||
async m() {
|
async m() {}
|
||||||
|
async mt<T>(a: T) {}
|
||||||
}
|
static async m(a) {}
|
||||||
async mt<T>(a: T) {
|
static async mt<T>(a: T) {}
|
||||||
|
|
||||||
}
|
|
||||||
static async m(a) {
|
|
||||||
|
|
||||||
}
|
|
||||||
static async mt<T>(a: T) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var e = async function() {
|
var e = async function() {};
|
||||||
|
var et = async function<T>(a: T) {};
|
||||||
};
|
var n = new async function() {}();
|
||||||
var et = async function<T>(a: T) {
|
var o = { async m() {} };
|
||||||
|
var ot = { async m<T>(a: T) {} };
|
||||||
};
|
var oz = { async async() {} };
|
||||||
var n = new async function() {
|
|
||||||
|
|
||||||
}();
|
|
||||||
var o = {
|
|
||||||
async m() {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var ot = {
|
|
||||||
async m<T>(a: T) {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var oz = {
|
|
||||||
async async() {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var x = { async: 5 };
|
var x = { async: 5 };
|
||||||
|
|
||||||
console.log(x.async);
|
console.log(x.async);
|
||||||
var async = 3;
|
var async = 3;
|
||||||
var y = { async };
|
var y = { async };
|
||||||
|
@ -246,13 +223,13 @@ async function foo3(): Promise<string> {
|
||||||
async function foo1(): Promise<string> {
|
async function foo1(): Promise<string> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function foo2(): Promise<string> {
|
async function foo2(): Promise<string> {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
async function foo3(): Promise<string> {
|
|
||||||
function bar() {
|
|
||||||
|
|
||||||
}
|
async function foo3(): Promise<string> {
|
||||||
|
function bar() {}
|
||||||
return bar();
|
return bar();
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
@ -345,12 +322,14 @@ function test1() {
|
||||||
async function foo() {
|
async function foo() {
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function bar() {
|
async function bar() {
|
||||||
var a = await foo();
|
var a = await foo();
|
||||||
var b: number = a;
|
var b: number = a;
|
||||||
var c: string = a;
|
var c: string = a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function test2() {
|
function test2() {
|
||||||
async function voidoid1() {
|
async function voidoid1() {
|
||||||
console.log(\"HEY\");
|
console.log(\"HEY\");
|
||||||
|
@ -358,16 +337,19 @@ function test2() {
|
||||||
var voidoid2: () => Promise<void> = voidoid1;
|
var voidoid2: () => Promise<void> = voidoid1;
|
||||||
var voidoid3: () => void = voidoid1;
|
var voidoid3: () => void = voidoid1;
|
||||||
}
|
}
|
||||||
|
|
||||||
function test3() {
|
function test3() {
|
||||||
async function voidoid4(): Promise<void> {
|
async function voidoid4(): Promise<void> {
|
||||||
console.log(\"HEY\");
|
console.log(\"HEY\");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function test4() {
|
function test4() {
|
||||||
async function voidoid5(): void {
|
async function voidoid5(): void {
|
||||||
console.log(\"HEY\");
|
console.log(\"HEY\");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function test5() {
|
function test5() {
|
||||||
async function voidoid6(): Promise<number> {
|
async function voidoid6(): Promise<number> {
|
||||||
console.log(\"HEY\");
|
console.log(\"HEY\");
|
||||||
|
@ -427,9 +409,11 @@ async function baz() {
|
||||||
async function foo() {
|
async function foo() {
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function bar() {
|
async function bar() {
|
||||||
return foo();
|
return foo();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function baz() {
|
async function baz() {
|
||||||
var a = await bar();
|
var a = await bar();
|
||||||
var b: number = a;
|
var b: number = a;
|
||||||
|
@ -467,6 +451,7 @@ var y = { await };
|
||||||
async function f() {
|
async function f() {
|
||||||
await 1;
|
await 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function ft<T>(a: T) {
|
async function ft<T>(a: T) {
|
||||||
await 1;
|
await 1;
|
||||||
}
|
}
|
||||||
|
@ -509,6 +494,7 @@ var oz = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var x = { await: 5 };
|
var x = { await: 5 };
|
||||||
|
|
||||||
console.log(x.await);
|
console.log(x.await);
|
||||||
var await = 3;
|
var await = 3;
|
||||||
var y = { await };
|
var y = { await };
|
||||||
|
|
|
@ -33,20 +33,26 @@ async function* delegate_next() {
|
||||||
async function* inner() {
|
async function* inner() {
|
||||||
var x: void = yield;
|
var x: void = yield;
|
||||||
}
|
}
|
||||||
|
|
||||||
yield* inner();
|
yield* inner();
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate_next().next(0);
|
delegate_next().next(0);
|
||||||
|
|
||||||
async function* delegate_yield() {
|
async function* delegate_yield() {
|
||||||
async function* inner() {
|
async function* inner() {
|
||||||
yield 0;
|
yield 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
yield* inner();
|
yield* inner();
|
||||||
}
|
}
|
||||||
|
|
||||||
async () => {
|
async () => {
|
||||||
for await (const x of delegate_yield()) {
|
for await (const x of delegate_yield()) {
|
||||||
(x: void);
|
(x: void);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
async function* delegate_return() {
|
async function* delegate_return() {
|
||||||
async function* inner() {
|
async function* inner() {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -86,6 +92,7 @@ async function f() {
|
||||||
// error: string ~> void
|
// error: string ~> void
|
||||||
interface File { readLine(): Promise<string>; close(): void; EOF: boolean }
|
interface File { readLine(): Promise<string>; close(): void; EOF: boolean }
|
||||||
declare function fileOpen(path: string): Promise<File>;
|
declare function fileOpen(path: string): Promise<File>;
|
||||||
|
|
||||||
async function* readLines(path) {
|
async function* readLines(path) {
|
||||||
let file: File = await fileOpen(path);
|
let file: File = await fileOpen(path);
|
||||||
try {
|
try {
|
||||||
|
@ -96,6 +103,7 @@ async function* readLines(path) {
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function f() {
|
async function f() {
|
||||||
for await (const line of readLines(\"/path/to/file\")) {
|
for await (const line of readLines(\"/path/to/file\")) {
|
||||||
(line: void);
|
(line: void);
|
||||||
|
@ -135,11 +143,13 @@ refuse_return().return(\"string\").then(result => {
|
||||||
// yielding or returning internally.
|
// yielding or returning internally.
|
||||||
// error: number | void ~> string
|
// error: number | void ~> string
|
||||||
declare var gen: AsyncGenerator<void, string, void>;
|
declare var gen: AsyncGenerator<void, string, void>;
|
||||||
|
|
||||||
gen.return(0).then(
|
gen.return(0).then(
|
||||||
result => {
|
result => {
|
||||||
(result.value: void);
|
(result.value: void);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
async function* refuse_return() {
|
async function* refuse_return() {
|
||||||
try {
|
try {
|
||||||
yield 1;
|
yield 1;
|
||||||
|
@ -147,6 +157,7 @@ async function* refuse_return() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refuse_return().return(\"string\").then(
|
refuse_return().return(\"string\").then(
|
||||||
result => {
|
result => {
|
||||||
if (result.done) {
|
if (result.done) {
|
||||||
|
@ -200,6 +211,7 @@ async function* catch_return() {
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async () => {
|
async () => {
|
||||||
catch_return().throw(\"\").then(
|
catch_return().throw(\"\").then(
|
||||||
({ value }) => {
|
({ value }) => {
|
||||||
|
@ -209,6 +221,7 @@ async () => {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
async function* yield_return() {
|
async function* yield_return() {
|
||||||
try {
|
try {
|
||||||
yield 0;
|
yield 0;
|
||||||
|
@ -217,6 +230,7 @@ async function* yield_return() {
|
||||||
yield e;
|
yield e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async () => {
|
async () => {
|
||||||
yield_return().throw(\"\").then(
|
yield_return().throw(\"\").then(
|
||||||
({ value }) => {
|
({ value }) => {
|
||||||
|
|
|
@ -19,6 +19,7 @@ declare var mergeInto: $Facebookism$MergeInto;
|
||||||
declare var mixin: $Facebookism$Mixin;
|
declare var mixin: $Facebookism$Mixin;
|
||||||
declare var objectGetPrototypeOf: Object$GetPrototypeOf;
|
declare var objectGetPrototypeOf: Object$GetPrototypeOf;
|
||||||
declare var objectAssign: Object$Assign;
|
declare var objectAssign: Object$Assign;
|
||||||
|
|
||||||
m;
|
m;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -78,45 +78,58 @@ let tests = [
|
||||||
let tests = [
|
let tests = [
|
||||||
function() {
|
function() {
|
||||||
\"foo\" in {};
|
\"foo\" in {};
|
||||||
|
|
||||||
\"foo\" in { foo: null };
|
\"foo\" in { foo: null };
|
||||||
|
|
||||||
0 in {};
|
0 in {};
|
||||||
|
|
||||||
0 in { \"0\": null };
|
0 in { \"0\": null };
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
\"foo\" in [ ];
|
\"foo\" in [];
|
||||||
0 in [ ];
|
|
||||||
\"length\" in [ ];
|
0 in [];
|
||||||
|
|
||||||
|
\"length\" in [];
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
\"foo\" in new String(\"bar\");
|
\"foo\" in new String(\"bar\");
|
||||||
|
|
||||||
\"foo\" in new Number(123);
|
\"foo\" in new Number(123);
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
\"foo\" in 123;
|
\"foo\" in 123;
|
||||||
|
|
||||||
\"foo\" in \"bar\";
|
\"foo\" in \"bar\";
|
||||||
|
|
||||||
\"foo\" in void 0;
|
\"foo\" in void 0;
|
||||||
|
|
||||||
\"foo\" in null;
|
\"foo\" in null;
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
null in {};
|
null in {};
|
||||||
|
|
||||||
void 0 in {};
|
void 0 in {};
|
||||||
|
|
||||||
({}) in {};
|
({}) in {};
|
||||||
[ ] in {};
|
|
||||||
false in [ ];
|
[] in {};
|
||||||
|
|
||||||
|
false in [];
|
||||||
},
|
},
|
||||||
function() {
|
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) {
|
function(x: Object, y: mixed) {
|
||||||
\"foo\" in x;
|
\"foo\" in x;
|
||||||
|
|
||||||
\"foo\" in y;
|
\"foo\" in y;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
@ -33,23 +33,38 @@ for (const { baz } of bazzes) {
|
||||||
// error: string ~> number
|
// error: string ~> number
|
||||||
// error: string ~> number
|
// error: string ~> number
|
||||||
const x = 0;
|
const x = 0;
|
||||||
|
|
||||||
x++;
|
x++;
|
||||||
|
|
||||||
x--;
|
x--;
|
||||||
|
|
||||||
x += 0;
|
x += 0;
|
||||||
|
|
||||||
x -= 0;
|
x -= 0;
|
||||||
|
|
||||||
x /= 0;
|
x /= 0;
|
||||||
|
|
||||||
x %= 0;
|
x %= 0;
|
||||||
|
|
||||||
x <<= 0;
|
x <<= 0;
|
||||||
|
|
||||||
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 { foo } = { foo: \"foo\" };
|
||||||
const [ bar ] = [ \"bar\" ];
|
const [ bar ] = [ \"bar\" ];
|
||||||
|
|
||||||
(foo: number);
|
(foo: number);
|
||||||
|
|
||||||
(bar: number);
|
(bar: number);
|
||||||
declare var bazzes: { baz: string }[];
|
declare var bazzes: { baz: string }[];
|
||||||
|
|
||||||
for (const { baz } of bazzes) {
|
for (const { baz } of bazzes) {
|
||||||
(baz: number);
|
(baz: number);
|
||||||
}
|
}
|
||||||
|
@ -311,128 +326,153 @@ function type_type() {
|
||||||
type A = number;
|
type A = number;
|
||||||
type A = number;
|
type A = number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function type_class() {
|
function type_class() {
|
||||||
type A = number;
|
type A = number;
|
||||||
class A {}
|
class A {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function type_let() {
|
function type_let() {
|
||||||
type A = number;
|
type A = number;
|
||||||
let A = 0;
|
let A = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function type_const() {
|
function type_const() {
|
||||||
type A = number;
|
type A = number;
|
||||||
const A = 0;
|
const A = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function type_var() {
|
function type_var() {
|
||||||
type A = number;
|
type A = number;
|
||||||
var A = 0;
|
var A = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function type_reassign() {
|
function type_reassign() {
|
||||||
type A = number;
|
type A = number;
|
||||||
|
|
||||||
A = 42;
|
A = 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
function class_type() {
|
function class_type() {
|
||||||
class A {}
|
class A {}
|
||||||
type A = number;
|
type A = number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function class_class() {
|
function class_class() {
|
||||||
class A {}
|
class A {}
|
||||||
class A {}
|
class A {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function class_let() {
|
function class_let() {
|
||||||
class A {}
|
class A {}
|
||||||
let A = 0;
|
let A = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function class_const() {
|
function class_const() {
|
||||||
class A {}
|
class A {}
|
||||||
const A = 0;
|
const A = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function class_var() {
|
function class_var() {
|
||||||
class A {}
|
class A {}
|
||||||
var A = 0;
|
var A = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function let_type() {
|
function let_type() {
|
||||||
let A = 0;
|
let A = 0;
|
||||||
type A = number;
|
type A = number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function let_class() {
|
function let_class() {
|
||||||
let A = 0;
|
let A = 0;
|
||||||
class A {}
|
class A {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function let_let() {
|
function let_let() {
|
||||||
let A = 0;
|
let A = 0;
|
||||||
let A = 0;
|
let A = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function let_const() {
|
function let_const() {
|
||||||
let A = 0;
|
let A = 0;
|
||||||
const A = 0;
|
const A = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function let_var() {
|
function let_var() {
|
||||||
let A = 0;
|
let A = 0;
|
||||||
var A = 0;
|
var A = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function const_type() {
|
function const_type() {
|
||||||
const A = 0;
|
const A = 0;
|
||||||
type A = number;
|
type A = number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function const_class() {
|
function const_class() {
|
||||||
const A = 0;
|
const A = 0;
|
||||||
class A {}
|
class A {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function const_let() {
|
function const_let() {
|
||||||
const A = 0;
|
const A = 0;
|
||||||
let A = 0;
|
let A = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function const_const() {
|
function const_const() {
|
||||||
const A = 0;
|
const A = 0;
|
||||||
const A = 0;
|
const A = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function const_var() {
|
function const_var() {
|
||||||
const A = 0;
|
const A = 0;
|
||||||
var A = 0;
|
var A = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function const_reassign() {
|
function const_reassign() {
|
||||||
const A = 0;
|
const A = 0;
|
||||||
|
|
||||||
A = 42;
|
A = 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
function var_type() {
|
function var_type() {
|
||||||
var A = 0;
|
var A = 0;
|
||||||
type A = number;
|
type A = number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function var_class() {
|
function var_class() {
|
||||||
var A = 0;
|
var A = 0;
|
||||||
class A {}
|
class A {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function var_let() {
|
function var_let() {
|
||||||
var A = 0;
|
var A = 0;
|
||||||
let A = 0;
|
let A = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function var_const() {
|
function var_const() {
|
||||||
var A = 0;
|
var A = 0;
|
||||||
const A = 0;
|
const A = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function var_var() {
|
function var_var() {
|
||||||
var A = 0;
|
var A = 0;
|
||||||
var A = 0;
|
var A = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function function_toplevel() {
|
function function_toplevel() {
|
||||||
function a() {
|
function a() {}
|
||||||
|
|
||||||
}
|
function a() {}
|
||||||
function a() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function function_block() {
|
function function_block() {
|
||||||
{
|
{
|
||||||
function a() {
|
function a() {}
|
||||||
|
|
||||||
}
|
function a() {}
|
||||||
function a() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function var_shadow_nested_scope() {
|
function var_shadow_nested_scope() {
|
||||||
{
|
{
|
||||||
let x = 0;
|
let x = 0;
|
||||||
|
@ -441,6 +481,7 @@ function var_shadow_nested_scope() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function type_shadow_nested_scope() {
|
function type_shadow_nested_scope() {
|
||||||
{
|
{
|
||||||
let x = 0;
|
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) {
|
function fn_params_clash_fn_binding(x, y) {
|
||||||
let x = 0;
|
let x = 0;
|
||||||
var y = 0;
|
var y = 0;
|
||||||
|
@ -605,6 +646,7 @@ function block_scope() {
|
||||||
var b = \"\";
|
var b = \"\";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function switch_scope(x: string) {
|
function switch_scope(x: string) {
|
||||||
let a: number = 0;
|
let a: number = 0;
|
||||||
var b: number = 0;
|
var b: number = 0;
|
||||||
|
@ -618,9 +660,11 @@ function switch_scope(x: string) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function switch_scope2(x: number) {
|
function switch_scope2(x: number) {
|
||||||
switch (x) {
|
switch (x) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
||||||
a = \"\";
|
a = \"\";
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -630,14 +674,17 @@ function switch_scope2(x: number) {
|
||||||
let a = \"\";
|
let a = \"\";
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
|
||||||
a = \"\";
|
a = \"\";
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
var c: string = a;
|
var c: string = a;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
a = \"\";
|
a = \"\";
|
||||||
}
|
}
|
||||||
|
|
||||||
function try_scope() {
|
function try_scope() {
|
||||||
let a: number = 0;
|
let a: number = 0;
|
||||||
try {
|
try {
|
||||||
|
@ -648,53 +695,63 @@ function try_scope() {
|
||||||
let a = \"\";
|
let a = \"\";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function for_scope_let() {
|
function for_scope_let() {
|
||||||
let a: number = 0;
|
let a: number = 0;
|
||||||
for (let a = \"\"; ; ) {
|
|
||||||
|
|
||||||
}
|
for (let a = \"\"; ; )
|
||||||
|
{}
|
||||||
}
|
}
|
||||||
|
|
||||||
function for_scope_var() {
|
function for_scope_var() {
|
||||||
var a: number = 0;
|
var a: number = 0;
|
||||||
for (var a = \"\"; ; ) {
|
|
||||||
|
|
||||||
}
|
for (var a = \"\"; ; )
|
||||||
|
{}
|
||||||
}
|
}
|
||||||
|
|
||||||
function for_in_scope_let(o: Object) {
|
function for_in_scope_let(o: Object) {
|
||||||
let a: number = 0;
|
let a: number = 0;
|
||||||
for (let a in o) {
|
|
||||||
|
|
||||||
}
|
for (let a in o)
|
||||||
|
{}
|
||||||
}
|
}
|
||||||
|
|
||||||
function for_in_scope_var(o: Object) {
|
function for_in_scope_var(o: Object) {
|
||||||
var a: number = 0;
|
var a: number = 0;
|
||||||
for (var a in o) {
|
|
||||||
|
|
||||||
}
|
for (var a in o)
|
||||||
|
{}
|
||||||
}
|
}
|
||||||
|
|
||||||
function for_of_scope_let(xs: string[]) {
|
function for_of_scope_let(xs: string[]) {
|
||||||
let a: number = 0;
|
let a: number = 0;
|
||||||
for (let a of xs) {
|
|
||||||
|
|
||||||
}
|
for (let a of xs)
|
||||||
|
{}
|
||||||
}
|
}
|
||||||
|
|
||||||
function for_of_scope_var(xs: string[]) {
|
function for_of_scope_var(xs: string[]) {
|
||||||
var a: number = 0;
|
var a: number = 0;
|
||||||
for (var a of xs) {
|
|
||||||
|
|
||||||
}
|
for (var a of xs)
|
||||||
|
{}
|
||||||
}
|
}
|
||||||
|
|
||||||
function default_param_1() {
|
function default_param_1() {
|
||||||
function f(x: () => string = f): number {
|
function f(x: () => string = f): number {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function default_param_2() {
|
function default_param_2() {
|
||||||
let a = \"\";
|
let a = \"\";
|
||||||
|
|
||||||
function f0(x = () => a): number {
|
function f0(x = () => a): number {
|
||||||
let a = 0;
|
let a = 0;
|
||||||
return x();
|
return x();
|
||||||
}
|
}
|
||||||
|
|
||||||
function f1(x = b): number {
|
function f1(x = b): number {
|
||||||
let b = 0;
|
let b = 0;
|
||||||
return x;
|
return x;
|
||||||
|
@ -849,19 +906,23 @@ f(a); // ok, a: number (not ?number)
|
||||||
// ok, a: number (not ?number)
|
// ok, a: number (not ?number)
|
||||||
type T1 = T2;
|
type T1 = T2;
|
||||||
type T2 = number;
|
type T2 = number;
|
||||||
|
|
||||||
function f0() {
|
function f0() {
|
||||||
var v = x * c;
|
var v = x * c;
|
||||||
let x = 0;
|
let x = 0;
|
||||||
const c = 0;
|
const c = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function f1(b) {
|
function f1(b) {
|
||||||
x = 10;
|
x = 10;
|
||||||
let x = 0;
|
let x = 0;
|
||||||
|
|
||||||
if (b) {
|
if (b) {
|
||||||
y = 10;
|
y = 10;
|
||||||
let y = 0;
|
let y = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function f2() {
|
function f2() {
|
||||||
{
|
{
|
||||||
var v = x * c;
|
var v = x * c;
|
||||||
|
@ -869,19 +930,23 @@ function f2() {
|
||||||
let x = 0;
|
let x = 0;
|
||||||
const c = 0;
|
const c = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function f3() {
|
function f3() {
|
||||||
var s: string = foo();
|
var s: string = foo();
|
||||||
{
|
{
|
||||||
var n: number = foo();
|
var n: number = foo();
|
||||||
|
|
||||||
function foo() {
|
function foo() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var s2: string = foo();
|
var s2: string = foo();
|
||||||
|
|
||||||
function foo() {
|
function foo() {
|
||||||
return \"\";
|
return \"\";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function f4() {
|
function f4() {
|
||||||
function g() {
|
function g() {
|
||||||
return x + c;
|
return x + c;
|
||||||
|
@ -889,10 +954,12 @@ function f4() {
|
||||||
let x = 0;
|
let x = 0;
|
||||||
const c = 0;
|
const c = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function f5() {
|
function f5() {
|
||||||
function g() {
|
function g() {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
g();
|
g();
|
||||||
let x = 0;
|
let x = 0;
|
||||||
const c = 0;
|
const c = 0;
|
||||||
|
@ -902,11 +969,15 @@ var y = new C();
|
||||||
class C {}
|
class C {}
|
||||||
var z: C = new C();
|
var z: C = new C();
|
||||||
var a: number;
|
var a: number;
|
||||||
|
|
||||||
function f(n: number) {
|
function f(n: number) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
f(a);
|
f(a);
|
||||||
|
|
||||||
a = 10;
|
a = 10;
|
||||||
|
|
||||||
f(a);
|
f(a);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -125,69 +125,97 @@ for (let [x, y]: [number, number] of a.entries()) {} // incorrect
|
||||||
// incorrect
|
// incorrect
|
||||||
// incorrect
|
// incorrect
|
||||||
const a: FormData = new FormData();
|
const a: FormData = new FormData();
|
||||||
|
|
||||||
new FormData(\"\");
|
new FormData(\"\");
|
||||||
|
|
||||||
new FormData(document.createElement(\"input\"));
|
new FormData(document.createElement(\"input\"));
|
||||||
|
|
||||||
new FormData(document.createElement(\"form\"));
|
new FormData(document.createElement(\"form\"));
|
||||||
const b: boolean = a.has(\"foo\");
|
const b: boolean = a.has(\"foo\");
|
||||||
const c: ?(string | File) = a.get(\"foo\");
|
const c: ?(string | File) = a.get(\"foo\");
|
||||||
const d: string = a.get(\"foo\");
|
const d: string = a.get(\"foo\");
|
||||||
const e: Blob = a.get(\"foo\");
|
const e: Blob = a.get(\"foo\");
|
||||||
const f: ?(string | File | Blob) = a.get(\"foo\");
|
const f: ?(string | File | Blob) = a.get(\"foo\");
|
||||||
|
|
||||||
a.get(2);
|
a.get(2);
|
||||||
const a1: Array<string | File> = a.getAll(\"foo\");
|
const a1: Array<string | File> = a.getAll(\"foo\");
|
||||||
const a2: Array<string | File | number> = a.getAll(\"foo\");
|
const a2: Array<string | File | number> = a.getAll(\"foo\");
|
||||||
const a3: Array<string | Blob | File> = a.getAll(\"foo\");
|
const a3: Array<string | Blob | File> = a.getAll(\"foo\");
|
||||||
|
|
||||||
a.getAll(23);
|
a.getAll(23);
|
||||||
|
|
||||||
a.set(\"foo\", \"bar\");
|
a.set(\"foo\", \"bar\");
|
||||||
|
|
||||||
a.set(\"foo\", {});
|
a.set(\"foo\", {});
|
||||||
|
|
||||||
a.set(2, \"bar\");
|
a.set(2, \"bar\");
|
||||||
|
|
||||||
a.set(\"foo\", \"bar\", \"baz\");
|
a.set(\"foo\", \"bar\", \"baz\");
|
||||||
a.set(\"bar\", new File([ ], \"q\"));
|
|
||||||
a.set(\"bar\", new File([ ], \"q\"), \"x\");
|
a.set(\"bar\", new File([], \"q\"));
|
||||||
a.set(\"bar\", new File([ ], \"q\"), 2);
|
|
||||||
|
a.set(\"bar\", new File([], \"q\"), \"x\");
|
||||||
|
|
||||||
|
a.set(\"bar\", new File([], \"q\"), 2);
|
||||||
|
|
||||||
a.set(\"bar\", new Blob());
|
a.set(\"bar\", new Blob());
|
||||||
|
|
||||||
a.set(\"bar\", new Blob(), \"x\");
|
a.set(\"bar\", new Blob(), \"x\");
|
||||||
|
|
||||||
a.set(\"bar\", new Blob(), 2);
|
a.set(\"bar\", new Blob(), 2);
|
||||||
|
|
||||||
a.append(\"foo\", \"bar\");
|
a.append(\"foo\", \"bar\");
|
||||||
|
|
||||||
a.append(\"foo\", {});
|
a.append(\"foo\", {});
|
||||||
|
|
||||||
a.append(2, \"bar\");
|
a.append(2, \"bar\");
|
||||||
|
|
||||||
a.append(\"foo\", \"bar\", \"baz\");
|
a.append(\"foo\", \"bar\", \"baz\");
|
||||||
|
|
||||||
a.append(\"foo\", \"bar\");
|
a.append(\"foo\", \"bar\");
|
||||||
a.append(\"bar\", new File([ ], \"q\"));
|
|
||||||
a.append(\"bar\", new File([ ], \"q\"), \"x\");
|
a.append(\"bar\", new File([], \"q\"));
|
||||||
a.append(\"bar\", new File([ ], \"q\"), 2);
|
|
||||||
|
a.append(\"bar\", new File([], \"q\"), \"x\");
|
||||||
|
|
||||||
|
a.append(\"bar\", new File([], \"q\"), 2);
|
||||||
|
|
||||||
a.append(\"bar\", new Blob());
|
a.append(\"bar\", new Blob());
|
||||||
|
|
||||||
a.append(\"bar\", new Blob(), \"x\");
|
a.append(\"bar\", new Blob(), \"x\");
|
||||||
|
|
||||||
a.append(\"bar\", new Blob(), 2);
|
a.append(\"bar\", new Blob(), 2);
|
||||||
|
|
||||||
a.delete(\"xx\");
|
a.delete(\"xx\");
|
||||||
|
|
||||||
a.delete(3);
|
a.delete(3);
|
||||||
for (let x: string of a.keys()) {
|
|
||||||
|
|
||||||
}
|
for (let x: string of a.keys())
|
||||||
for (let x: number of a.keys()) {
|
{}
|
||||||
|
|
||||||
}
|
for (let x: number of a.keys())
|
||||||
for (let x: string | File of a.values()) {
|
{}
|
||||||
|
|
||||||
}
|
for (let x: string | File of a.values())
|
||||||
for (let x: string | File | Blob of a.values()) {
|
{}
|
||||||
|
|
||||||
}
|
for (let x: string | File | Blob of a.values())
|
||||||
for (let [ x, y ]: [string, string | File] of a.entries()) {
|
{}
|
||||||
|
|
||||||
}
|
for (let [ x, y ]: [string, string | File] of a.entries())
|
||||||
for (let [ x, y ]: [string, string | File | Blob] of a.entries()) {
|
{}
|
||||||
|
|
||||||
}
|
for (let [ x, y ]: [string, string | File | Blob] of a.entries())
|
||||||
for (let [ x, y ]: [number, string] of a.entries()) {
|
{}
|
||||||
|
|
||||||
}
|
for (let [ x, y ]: [number, string] of a.entries())
|
||||||
for (let [ x, y ]: [string, number] of a.entries()) {
|
{}
|
||||||
|
|
||||||
}
|
for (let [ x, y ]: [string, number] of a.entries())
|
||||||
for (let [ x, y ]: [number, number] of a.entries()) {
|
{}
|
||||||
|
|
||||||
}
|
for (let [ x, y ]: [number, number] of a.entries())
|
||||||
|
{}
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -249,29 +277,36 @@ function callback(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const o: MutationObserver = new MutationObserver(callback);
|
const o: MutationObserver = new MutationObserver(callback);
|
||||||
|
|
||||||
new MutationObserver((arr: Array<MutationRecord>) => true);
|
new MutationObserver((arr: Array<MutationRecord>) => true);
|
||||||
new MutationObserver(
|
|
||||||
() => {
|
|
||||||
|
|
||||||
}
|
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\");
|
const div = document.createElement(\"div\");
|
||||||
|
|
||||||
o.observe(div, { attributes: true, attributeFilter: [ \"style\" ] });
|
o.observe(div, { attributes: true, attributeFilter: [ \"style\" ] });
|
||||||
|
|
||||||
o.observe(div, { characterData: true, invalid: true });
|
o.observe(div, { characterData: true, invalid: true });
|
||||||
|
|
||||||
o.observe();
|
o.observe();
|
||||||
|
|
||||||
o.observe(\"invalid\");
|
o.observe(\"invalid\");
|
||||||
|
|
||||||
o.observe(div);
|
o.observe(div);
|
||||||
|
|
||||||
o.observe(div, {});
|
o.observe(div, {});
|
||||||
|
|
||||||
o.observe(div, { subtree: true });
|
o.observe(div, { subtree: true });
|
||||||
|
|
||||||
o.observe(div, { attributes: true, attributeFilter: true });
|
o.observe(div, { attributes: true, attributeFilter: true });
|
||||||
|
|
||||||
o.takeRecords();
|
o.takeRecords();
|
||||||
|
|
||||||
o.disconnect();
|
o.disconnect();
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -4,10 +4,10 @@ foo(0, \"\");
|
||||||
|
|
||||||
function bar<X:number, Y:X>(x:X, y:Y): number { return y*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, \"\");
|
foo(0, \"\");
|
||||||
|
|
||||||
function bar<X: number, Y: X>(x: X, y: Y): number {
|
function bar<X: number, Y: X>(x: X, y: Y): number {
|
||||||
return y * 0;
|
return y * 0;
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,7 @@ class C<T: number> {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function example<T: { x: number }>(o: T): T {
|
function example<T: { x: number }>(o: T): T {
|
||||||
o.x = 0;
|
o.x = 0;
|
||||||
return o;
|
return o;
|
||||||
|
|
|
@ -93,13 +93,16 @@ function foo(b) {
|
||||||
}
|
}
|
||||||
var w: number = z;
|
var w: number = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
function bar(b) {
|
function bar(b) {
|
||||||
var x = (b ? null : false);
|
var x = (b ? null : false);
|
||||||
|
|
||||||
if (x == null)
|
if (x == null)
|
||||||
return;
|
return;
|
||||||
switch (\"\") {
|
switch (\"\") {
|
||||||
case 0:
|
case 0:
|
||||||
var y: number = x;
|
var y: number = x;
|
||||||
|
|
||||||
x = \"\";
|
x = \"\";
|
||||||
case 1:
|
case 1:
|
||||||
var z: number = x;
|
var z: number = x;
|
||||||
|
@ -108,14 +111,17 @@ function bar(b) {
|
||||||
}
|
}
|
||||||
var w: number = x;
|
var w: number = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function bar2(b) {
|
function bar2(b) {
|
||||||
var x = (b ? null : false);
|
var x = (b ? null : false);
|
||||||
|
|
||||||
if (x == null)
|
if (x == null)
|
||||||
return;
|
return;
|
||||||
switch (\"\") {
|
switch (\"\") {
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
let y: number = x;
|
let y: number = x;
|
||||||
|
|
||||||
x = \"\";
|
x = \"\";
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -127,25 +133,32 @@ function bar2(b) {
|
||||||
}
|
}
|
||||||
var w: number = x;
|
var w: number = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function qux(b) {
|
function qux(b) {
|
||||||
var z = 0;
|
var z = 0;
|
||||||
while (b) {
|
while (b) {
|
||||||
var y: number = z;
|
var y: number = z;
|
||||||
|
|
||||||
if (b) {
|
if (b) {
|
||||||
z = \"\";
|
z = \"\";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
z = 0;
|
z = 0;
|
||||||
}
|
}
|
||||||
var w: number = z;
|
var w: number = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_const() {
|
function test_const() {
|
||||||
let st: string = \"abc\";
|
let st: string = \"abc\";
|
||||||
|
|
||||||
for (let i = 1; i < 100; i++) {
|
for (let i = 1; i < 100; i++) {
|
||||||
const fooRes: ?string = \"HEY\";
|
const fooRes: ?string = \"HEY\";
|
||||||
|
|
||||||
if (!fooRes) {
|
if (!fooRes) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
st = fooRes;
|
st = fooRes;
|
||||||
}
|
}
|
||||||
return st;
|
return st;
|
||||||
|
|
|
@ -4,7 +4,9 @@ exports[`test test.js 1`] = `
|
||||||
module.exports = o;
|
module.exports = o;
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
var o = Object.freeze({ foo: 0 });
|
var o = Object.freeze({ foo: 0 });
|
||||||
|
|
||||||
(o.foo: string);
|
(o.foo: string);
|
||||||
|
|
||||||
module.exports = o;
|
module.exports = o;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -14,6 +16,7 @@ exports[`test test2.js 1`] = `
|
||||||
(o.foo: string);
|
(o.foo: string);
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
var o = require(\"./test\");
|
var o = require(\"./test\");
|
||||||
|
|
||||||
(o.foo: string);
|
(o.foo: string);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -27,7 +27,8 @@ var b = a.map(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
var c: string = b[0];
|
var c: string = b[0];
|
||||||
var array = [ ];
|
var array = [];
|
||||||
|
|
||||||
function f() {
|
function f() {
|
||||||
array = array.map(
|
array = array.map(
|
||||||
function() {
|
function() {
|
||||||
|
@ -38,6 +39,7 @@ function f() {
|
||||||
}
|
}
|
||||||
var Foo = require(\"./genericfoo\");
|
var Foo = require(\"./genericfoo\");
|
||||||
var foo = new Foo();
|
var foo = new Foo();
|
||||||
|
|
||||||
function g() {
|
function g() {
|
||||||
var foo1 = foo.map(
|
var foo1 = foo.map(
|
||||||
function() {
|
function() {
|
||||||
|
@ -45,6 +47,7 @@ function g() {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
var x: number = foo1.get();
|
var x: number = foo1.get();
|
||||||
|
|
||||||
foo = foo1;
|
foo = foo1;
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
@ -69,13 +72,12 @@ class Foo<T> {
|
||||||
map<U>(callbackfn: () => U): Foo<U> {
|
map<U>(callbackfn: () => U): Foo<U> {
|
||||||
return new Foo();
|
return new Foo();
|
||||||
}
|
}
|
||||||
set(x: T): void {
|
set(x: T): void {}
|
||||||
|
|
||||||
}
|
|
||||||
get(): T {
|
get(): T {
|
||||||
return this.x;
|
return this.x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Foo;
|
module.exports = Foo;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -39,18 +39,23 @@ function f(): number {
|
||||||
function a(f: { (): string }, g: { (x: number): string }): string {
|
function a(f: { (): string }, g: { (x: number): string }): string {
|
||||||
return f() + g(123);
|
return f() + g(123);
|
||||||
}
|
}
|
||||||
|
|
||||||
function b(f: { (): string }): number {
|
function b(f: { (): string }): number {
|
||||||
return f();
|
return f();
|
||||||
}
|
}
|
||||||
|
|
||||||
function c(f: { (x: number): number }): number {
|
function c(f: { (x: number): number }): number {
|
||||||
return f(\"hello\");
|
return f(\"hello\");
|
||||||
}
|
}
|
||||||
|
|
||||||
function d(f: { (x: number): number }): number {
|
function d(f: { (x: number): number }): number {
|
||||||
return f();
|
return f();
|
||||||
}
|
}
|
||||||
|
|
||||||
function e(f: {}): number {
|
function e(f: {}): number {
|
||||||
return f();
|
return f();
|
||||||
}
|
}
|
||||||
|
|
||||||
function f(): number {
|
function f(): number {
|
||||||
var x = {};
|
var x = {};
|
||||||
return x();
|
return x();
|
||||||
|
@ -101,15 +106,11 @@ var c: { (x: string): string } = function(x: number): string {
|
||||||
var d: { (): string } = function(x: number): string {
|
var d: { (): string } = function(x: number): string {
|
||||||
return \"hi\";
|
return \"hi\";
|
||||||
};
|
};
|
||||||
var e: { (x: any): void } = function() {
|
var e: { (x: any): void } = function() {};
|
||||||
|
|
||||||
};
|
|
||||||
var f: { (): mixed } = function(): string {
|
var f: { (): mixed } = function(): string {
|
||||||
return \"hi\";
|
return \"hi\";
|
||||||
};
|
};
|
||||||
var g: { (x: string): void } = function(x: mixed) {
|
var g: { (x: string): void } = function(x: mixed) {};
|
||||||
|
|
||||||
};
|
|
||||||
var y: {} = function(x: number): string {
|
var y: {} = function(x: number): string {
|
||||||
return \"hi\";
|
return \"hi\";
|
||||||
};
|
};
|
||||||
|
@ -166,21 +167,27 @@ function g(x: {}): Function {
|
||||||
function a(x: { (z: number): string }): (z: number) => string {
|
function a(x: { (z: number): string }): (z: number) => string {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function b(x: { (z: number): string }): (z: number) => number {
|
function b(x: { (z: number): string }): (z: number) => number {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function c(x: { (z: number): string }): (z: string) => string {
|
function c(x: { (z: number): string }): (z: string) => string {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function d(x: { (z: number): string }): () => string {
|
function d(x: { (z: number): string }): () => string {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function e(x: {}): () => string {
|
function e(x: {}): () => string {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function f(x: { (z: number): string }): Function {
|
function f(x: { (z: number): string }): Function {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function g(x: {}): Function {
|
function g(x: {}): Function {
|
||||||
return x;
|
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 {
|
var c: { (): string; (x: number): string } = function(x: number): string {
|
||||||
return \"hi\";
|
return \"hi\";
|
||||||
};
|
};
|
||||||
|
|
||||||
function d(x: { (): string; (x: number): string }): () => string {
|
function d(x: { (): string; (x: number): string }): () => string {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function e(x: { (): string; (x: number): string }): () => number {
|
function e(x: { (): string; (x: number): string }): () => number {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
@ -249,15 +258,10 @@ var c : { myProp: number } = f;
|
||||||
// Expecting properties that don\'t exist should be an error
|
// Expecting properties that don\'t exist should be an error
|
||||||
// Expecting properties that do exist should be fine
|
// Expecting properties that do exist should be fine
|
||||||
// Expecting properties in the functions statics 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;
|
f.myProp = 123;
|
||||||
var c: { myProp: number } = f;
|
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 b: { (x: number): number } = x => \"hi\";
|
||||||
var c: { (x: string): string } = x => x.toFixed();
|
var c: { (x: string): string } = x => x.toFixed();
|
||||||
var d: { (): string } = x => \"hi\";
|
var d: { (): string } = x => \"hi\";
|
||||||
var e: { (x: any): void } = () => {
|
var e: { (x: any): void } = () => {};
|
||||||
|
|
||||||
};
|
|
||||||
var f: { (): mixed } = () => \"hi\";
|
var f: { (): mixed } = () => \"hi\";
|
||||||
var g: { (x: Date): void } = x => {
|
var g: { (x: Date): void } = x => {
|
||||||
x * 2;
|
x * 2;
|
||||||
|
|
|
@ -11,9 +11,11 @@ function f(x) {
|
||||||
(f: F);
|
(f: F);
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
type F = { (x: string): number; p?: string };
|
type F = { (x: string): number; p?: string };
|
||||||
|
|
||||||
function f(x) {
|
function f(x) {
|
||||||
return x.length;
|
return x.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
(f: F);
|
(f: F);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -47,19 +49,24 @@ callable.call(null, 0); // error, number ~> string
|
||||||
// error, number ~> string
|
// error, number ~> string
|
||||||
// error, number ~> string
|
// error, number ~> string
|
||||||
var x = Boolean(4);
|
var x = Boolean(4);
|
||||||
function foo(fn: (value: any) => boolean) {
|
|
||||||
|
|
||||||
}
|
function foo(fn: (value: any) => boolean) {}
|
||||||
|
|
||||||
foo(Boolean);
|
foo(Boolean);
|
||||||
var dict: { [k: string]: any } = {};
|
var dict: { [k: string]: any } = {};
|
||||||
|
|
||||||
dict();
|
dict();
|
||||||
interface ICall { (x: string): void }
|
interface ICall { (x: string): void }
|
||||||
declare var icall: ICall;
|
declare var icall: ICall;
|
||||||
|
|
||||||
icall(0);
|
icall(0);
|
||||||
|
|
||||||
icall.call(null, 0);
|
icall.call(null, 0);
|
||||||
type Callable = { (x: string): void };
|
type Callable = { (x: string): void };
|
||||||
declare var callable: Callable;
|
declare var callable: Callable;
|
||||||
|
|
||||||
callable(0);
|
callable(0);
|
||||||
|
|
||||||
callable.call(null, 0);
|
callable.call(null, 0);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -77,28 +77,27 @@ module.exports = {
|
||||||
class A {
|
class A {
|
||||||
static x: number;
|
static x: number;
|
||||||
static y: string;
|
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 {
|
class B extends A {
|
||||||
static x: string;
|
static x: string;
|
||||||
static foo(x: string) {
|
static foo(x: string) {}
|
||||||
|
|
||||||
}
|
|
||||||
static main() {
|
static main() {
|
||||||
B.x = 0;
|
B.x = 0;
|
||||||
|
|
||||||
B.x = \"\";
|
B.x = \"\";
|
||||||
|
|
||||||
B.foo(0);
|
B.foo(0);
|
||||||
|
|
||||||
B.foo(\"\");
|
B.foo(\"\");
|
||||||
|
|
||||||
B.y = 0;
|
B.y = 0;
|
||||||
|
|
||||||
B.bar(0);
|
B.bar(0);
|
||||||
|
|
||||||
B.qux(0);
|
B.qux(0);
|
||||||
}
|
}
|
||||||
static create(): A {
|
static create(): A {
|
||||||
|
@ -110,9 +109,7 @@ class B extends A {
|
||||||
}
|
}
|
||||||
class C<X> {
|
class C<X> {
|
||||||
static x: X;
|
static x: X;
|
||||||
static bar(x: X) {
|
static bar(x: X) {}
|
||||||
|
|
||||||
}
|
|
||||||
static create(): C<*> {
|
static create(): C<*> {
|
||||||
return new this();
|
return new this();
|
||||||
}
|
}
|
||||||
|
@ -120,11 +117,14 @@ class C<X> {
|
||||||
class D extends C<string> {
|
class D extends C<string> {
|
||||||
static main() {
|
static main() {
|
||||||
D.foo(0);
|
D.foo(0);
|
||||||
|
|
||||||
D.bar(0);
|
D.bar(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var d: C<*> = D.create();
|
var d: C<*> = D.create();
|
||||||
|
|
||||||
(new A(): typeof A);
|
(new A(): typeof A);
|
||||||
|
|
||||||
(B: typeof A);
|
(B: typeof A);
|
||||||
class E {
|
class E {
|
||||||
static x: number;
|
static x: number;
|
||||||
|
@ -133,6 +133,7 @@ class E {
|
||||||
return this.x;
|
return this.x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { A: A, B: B, C: C, D: D, E: E };
|
module.exports = { A: A, B: B, C: C, D: D, E: E };
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -8,6 +8,7 @@ module.exports = { A, B };
|
||||||
/* @flow */
|
/* @flow */
|
||||||
class A {}
|
class A {}
|
||||||
class B {}
|
class B {}
|
||||||
|
|
||||||
module.exports = { A, B };
|
module.exports = { A, B };
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -65,16 +66,17 @@ foo(new D, { f_: 0 });
|
||||||
class C<X> {
|
class C<X> {
|
||||||
x: X;
|
x: X;
|
||||||
}
|
}
|
||||||
function foo<X>(c: C<X>, x: X) {
|
|
||||||
|
|
||||||
}
|
function foo<X>(c: C<X>, x: X) {}
|
||||||
type O = { f: number };
|
type O = { f: number };
|
||||||
|
|
||||||
foo((new C(): C<O>), { f_: 0 });
|
foo((new C(): C<O>), { f_: 0 });
|
||||||
class D extends C<O> {
|
class D extends C<O> {
|
||||||
bar() {
|
bar() {
|
||||||
this.x;
|
this.x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foo(new D(), { f_: 0 });
|
foo(new D(), { f_: 0 });
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -14,14 +14,14 @@ function bar(x: Class<B>): B {
|
||||||
// OK
|
// OK
|
||||||
// error (too few args)
|
// error (too few args)
|
||||||
class A {}
|
class A {}
|
||||||
|
|
||||||
function foo(x: Class<A>): A {
|
function foo(x: Class<A>): A {
|
||||||
return new x();
|
return new x();
|
||||||
}
|
}
|
||||||
class B {
|
class B {
|
||||||
constructor(_: any) {
|
constructor(_: any) {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function bar(x: Class<B>): B {
|
function bar(x: Class<B>): B {
|
||||||
return new x();
|
return new x();
|
||||||
}
|
}
|
||||||
|
@ -51,10 +51,15 @@ declare function check<X>(cls: $Type<X>, inst: X): void;
|
||||||
class A {}
|
class A {}
|
||||||
class B extends A {}
|
class B extends A {}
|
||||||
class C {}
|
class C {}
|
||||||
|
|
||||||
check(B, new A());
|
check(B, new A());
|
||||||
|
|
||||||
check(A, new B());
|
check(A, new B());
|
||||||
|
|
||||||
check(C, new A());
|
check(C, new A());
|
||||||
|
|
||||||
check(C, new B());
|
check(C, new B());
|
||||||
|
|
||||||
check(B, new C());
|
check(B, new C());
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -6,10 +6,9 @@ exports[`test A.js 1`] = `
|
||||||
module.exports = A;
|
module.exports = A;
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
class A {
|
class A {
|
||||||
foo(x: number): void {
|
foo(x: number): void {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = A;
|
module.exports = A;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -28,7 +27,9 @@ module.exports = B;
|
||||||
var A = require(\"./A\");
|
var A = require(\"./A\");
|
||||||
class B extends A {}
|
class B extends A {}
|
||||||
let b = new B();
|
let b = new B();
|
||||||
|
|
||||||
(b.foo: number);
|
(b.foo: number);
|
||||||
|
|
||||||
module.exports = B;
|
module.exports = B;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -48,12 +49,12 @@ module.exports = C;
|
||||||
// error, number !~> function
|
// error, number !~> function
|
||||||
var B = require(\"./B\");
|
var B = require(\"./B\");
|
||||||
class C extends B {
|
class C extends B {
|
||||||
foo(x: string): void {
|
foo(x: string): void {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
let c = new C();
|
let c = new C();
|
||||||
|
|
||||||
(c.foo: number);
|
(c.foo: number);
|
||||||
|
|
||||||
module.exports = C;
|
module.exports = C;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -65,6 +66,7 @@ new E().x
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
class D {}
|
class D {}
|
||||||
class E {}
|
class E {}
|
||||||
|
|
||||||
new E().x;
|
new E().x;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -126,12 +128,18 @@ class TestClass {
|
||||||
c: ?string;
|
c: ?string;
|
||||||
}
|
}
|
||||||
var x = new TestClass();
|
var x = new TestClass();
|
||||||
|
|
||||||
x.a;
|
x.a;
|
||||||
|
|
||||||
x.b;
|
x.b;
|
||||||
|
|
||||||
x.c;
|
x.c;
|
||||||
|
|
||||||
x.d;
|
x.d;
|
||||||
var y: Foo = x;
|
var y: Foo = x;
|
||||||
|
|
||||||
y.b;
|
y.b;
|
||||||
|
|
||||||
y.d;
|
y.d;
|
||||||
class Test2Superclass {
|
class Test2Superclass {
|
||||||
a: number;
|
a: number;
|
||||||
|
@ -249,10 +257,14 @@ declare var o: {p:number};
|
||||||
class C {
|
class C {
|
||||||
static p: string;
|
static p: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
C.p = \"hi\";
|
C.p = \"hi\";
|
||||||
|
|
||||||
(C: { p: string });
|
(C: { p: string });
|
||||||
|
|
||||||
(C: { p: number });
|
(C: { p: number });
|
||||||
declare var o: { p: number };
|
declare var o: { p: number };
|
||||||
|
|
||||||
(o: Class<C>);
|
(o: Class<C>);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -104,63 +104,79 @@ function local_meth() {
|
||||||
// ok
|
// ok
|
||||||
// error
|
// error
|
||||||
// shouldn\'t pollute linear refinement
|
// shouldn\'t pollute linear refinement
|
||||||
function takes_string(_: string) {
|
function takes_string(_: string) {}
|
||||||
|
|
||||||
}
|
|
||||||
var global_x = \"hello\";
|
var global_x = \"hello\";
|
||||||
function global_f() {
|
|
||||||
|
|
||||||
}
|
function global_f() {}
|
||||||
|
|
||||||
function global_g() {
|
function global_g() {
|
||||||
global_x = 42;
|
global_x = 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
global_f();
|
global_f();
|
||||||
|
|
||||||
takes_string(global_x);
|
takes_string(global_x);
|
||||||
|
|
||||||
global_g();
|
global_g();
|
||||||
|
|
||||||
takes_string(global_x);
|
takes_string(global_x);
|
||||||
|
|
||||||
global_x = 42;
|
global_x = 42;
|
||||||
|
|
||||||
function local_func() {
|
function local_func() {
|
||||||
var local_x = \"hello\";
|
var local_x = \"hello\";
|
||||||
function local_f() {
|
|
||||||
|
|
||||||
}
|
function local_f() {}
|
||||||
|
|
||||||
function local_g() {
|
function local_g() {
|
||||||
local_x = 42;
|
local_x = 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
local_f();
|
local_f();
|
||||||
|
|
||||||
takes_string(local_x);
|
takes_string(local_x);
|
||||||
|
|
||||||
local_g();
|
local_g();
|
||||||
|
|
||||||
takes_string(local_x);
|
takes_string(local_x);
|
||||||
|
|
||||||
local_x = 42;
|
local_x = 42;
|
||||||
}
|
}
|
||||||
var global_y = \"hello\";
|
var global_y = \"hello\";
|
||||||
var global_o = {
|
var global_o = {
|
||||||
f: function() {
|
f: function() {},
|
||||||
|
|
||||||
},
|
|
||||||
g: function() {
|
g: function() {
|
||||||
global_y = 42;
|
global_y = 42;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
global_o.f();
|
global_o.f();
|
||||||
|
|
||||||
takes_string(global_y);
|
takes_string(global_y);
|
||||||
|
|
||||||
global_o.g();
|
global_o.g();
|
||||||
|
|
||||||
takes_string(global_y);
|
takes_string(global_y);
|
||||||
|
|
||||||
global_y = 42;
|
global_y = 42;
|
||||||
|
|
||||||
function local_meth() {
|
function local_meth() {
|
||||||
var local_y = \"hello\";
|
var local_y = \"hello\";
|
||||||
var local_o = {
|
var local_o = {
|
||||||
f: function() {
|
f: function() {},
|
||||||
|
|
||||||
},
|
|
||||||
g: function() {
|
g: function() {
|
||||||
local_y = 42;
|
local_y = 42;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
local_o.f();
|
local_o.f();
|
||||||
|
|
||||||
takes_string(local_y);
|
takes_string(local_y);
|
||||||
|
|
||||||
local_o.g();
|
local_o.g();
|
||||||
|
|
||||||
takes_string(local_y);
|
takes_string(local_y);
|
||||||
|
|
||||||
local_y = 42;
|
local_y = 42;
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
@ -188,9 +204,11 @@ function example(b: bool): number {
|
||||||
// error, string ~/~> number (return type anno) TODO
|
// error, string ~/~> number (return type anno) TODO
|
||||||
function example(b: boolean): number {
|
function example(b: boolean): number {
|
||||||
var x = 0;
|
var x = 0;
|
||||||
|
|
||||||
function f() {
|
function f() {
|
||||||
x = \"\";
|
x = \"\";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b) {
|
if (b) {
|
||||||
f();
|
f();
|
||||||
}
|
}
|
||||||
|
@ -263,26 +281,30 @@ call_me();
|
||||||
// error
|
// error
|
||||||
// error
|
// error
|
||||||
// in a galaxy far far away
|
// in a galaxy far far away
|
||||||
var call_me: () => void = () => {
|
var call_me: () => void = () => {};
|
||||||
|
|
||||||
};
|
|
||||||
function g(x: ?number) {
|
function g(x: ?number) {
|
||||||
const const_x = x;
|
const const_x = x;
|
||||||
|
|
||||||
if (const_x) {
|
if (const_x) {
|
||||||
call_me = () => {
|
call_me = () => {
|
||||||
var y: number = const_x;
|
var y: number = const_x;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var var_x = x;
|
var var_x = x;
|
||||||
|
|
||||||
if (var_x) {
|
if (var_x) {
|
||||||
call_me = () => {
|
call_me = () => {
|
||||||
var y: number = var_x;
|
var y: number = var_x;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var_x = null;
|
var_x = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function h(x: number | string | boolean) {
|
function h(x: number | string | boolean) {
|
||||||
const const_x = x;
|
const const_x = x;
|
||||||
|
|
||||||
if (typeof const_x == \"number\") {
|
if (typeof const_x == \"number\") {
|
||||||
call_me = () => {
|
call_me = () => {
|
||||||
var y: number = const_x;
|
var y: number = const_x;
|
||||||
|
@ -299,6 +321,7 @@ function h(x: number | string | boolean) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
var var_x = x;
|
var var_x = x;
|
||||||
|
|
||||||
if (typeof var_x == \"number\") {
|
if (typeof var_x == \"number\") {
|
||||||
call_me = () => {
|
call_me = () => {
|
||||||
var y: number = var_x;
|
var y: number = var_x;
|
||||||
|
@ -315,6 +338,7 @@ function h(x: number | string | boolean) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
call_me();
|
call_me();
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -4,9 +4,8 @@ function f(x:string) { }
|
||||||
|
|
||||||
module.exports = f;
|
module.exports = f;
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
function f(x: string) {
|
function f(x: string) {}
|
||||||
|
|
||||||
}
|
|
||||||
module.exports = f;
|
module.exports = f;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -18,6 +17,7 @@ var f = require(\'./Abs\');
|
||||||
f(0);
|
f(0);
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
var f = require(\"./Abs\");
|
var f = require(\"./Abs\");
|
||||||
|
|
||||||
f(0);
|
f(0);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -32,8 +32,11 @@ var ColorIdToNumber = {
|
||||||
[ColorId.GREEN]: ColorNumber.GREEN,
|
[ColorId.GREEN]: ColorNumber.GREEN,
|
||||||
[ColorId.BLUE]: ColorNumber.BLUE
|
[ColorId.BLUE]: ColorNumber.BLUE
|
||||||
};
|
};
|
||||||
|
|
||||||
(ColorIdToNumber[ColorId.RED]: \"ffffff\");
|
(ColorIdToNumber[ColorId.RED]: \"ffffff\");
|
||||||
|
|
||||||
ColorIdToNumber.XXX;
|
ColorIdToNumber.XXX;
|
||||||
|
|
||||||
module.exports = { ColorId, ColorNumber };
|
module.exports = { ColorId, ColorNumber };
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -57,7 +60,9 @@ var ColorIdToNumber = {
|
||||||
[ColorId.GREEN]: ColorNumber.GREEN,
|
[ColorId.GREEN]: ColorNumber.GREEN,
|
||||||
[ColorId.BLUE]: ColorNumber.BLUE
|
[ColorId.BLUE]: ColorNumber.BLUE
|
||||||
};
|
};
|
||||||
|
|
||||||
(ColorIdToNumber[ColorId.GREEN]: \"ffffff\");
|
(ColorIdToNumber[ColorId.GREEN]: \"ffffff\");
|
||||||
|
|
||||||
module.exports = ColorIdToNumber;
|
module.exports = ColorIdToNumber;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -71,6 +76,7 @@ var ColorIdToNumber = require(\'./test2\');
|
||||||
// oops
|
// oops
|
||||||
var { ColorId } = require(\"./test\");
|
var { ColorId } = require(\"./test\");
|
||||||
var ColorIdToNumber = require(\"./test2\");
|
var ColorIdToNumber = require(\"./test2\");
|
||||||
|
|
||||||
(ColorIdToNumber[ColorId.BLUE]: \"ffffff\");
|
(ColorIdToNumber[ColorId.BLUE]: \"ffffff\");
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -93,6 +99,7 @@ module.exports = {
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
var hello = require(\"./test4\");
|
var hello = require(\"./test4\");
|
||||||
var dummy = require(\"./test\");
|
var dummy = require(\"./test\");
|
||||||
|
|
||||||
module.exports = { ...dummy, [hello]: \"world\", ...dummy };
|
module.exports = { ...dummy, [hello]: \"world\", ...dummy };
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -103,6 +110,7 @@ exports[`test test6.js 1`] = `
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// oops
|
// oops
|
||||||
var o = require(\"./test5\");
|
var o = require(\"./test5\");
|
||||||
|
|
||||||
(o.hello: \"nothing\");
|
(o.hello: \"nothing\");
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -32,15 +32,18 @@ function a(): number {
|
||||||
var x: ?string = null;
|
var x: ?string = null;
|
||||||
return (x ? 1 : 0);
|
return (x ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function b(): number {
|
function b(): number {
|
||||||
var x: ?number = null;
|
var x: ?number = null;
|
||||||
return (x != null ? x : 0);
|
return (x != null ? x : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function c(): number {
|
function c(): number {
|
||||||
var x = false;
|
var x = false;
|
||||||
var temp = (x ? 1 : x);
|
var temp = (x ? 1 : x);
|
||||||
return (temp ? temp : 0);
|
return (temp ? temp : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function d(): string {
|
function d(): string {
|
||||||
var x: ?number = null;
|
var x: ?number = null;
|
||||||
return (x != null ? x : x != null);
|
return (x != null ? x : x != null);
|
||||||
|
|
|
@ -4,6 +4,7 @@ exports[`test no_at_flow.js 1`] = `
|
||||||
x.length;
|
x.length;
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
var x;
|
var x;
|
||||||
|
|
||||||
x.length;
|
x.length;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -19,6 +19,7 @@ function foo(x) {
|
||||||
var a: number = \"asdf\";
|
var a: number = \"asdf\";
|
||||||
return x * 10;
|
return x * 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
foo(\"Hello, world!\");
|
foo(\"Hello, world!\");
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -9,7 +9,9 @@ import {name} from \"testproj\";
|
||||||
// @flow
|
// @flow
|
||||||
// Error: Resolve from node_modules first!
|
// Error: Resolve from node_modules first!
|
||||||
import { name } from \"testproj\";
|
import { name } from \"testproj\";
|
||||||
|
|
||||||
(name: \"node_modules/testproj\");
|
(name: \"node_modules/testproj\");
|
||||||
|
|
||||||
(name: \"custom_resolve_dir/testproj\");
|
(name: \"custom_resolve_dir/testproj\");
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -9,7 +9,9 @@ import {name} from \"testproj2\";
|
||||||
// @flow
|
// @flow
|
||||||
// Error: Resolve from sibling \'custom_resolve_dir\' first!
|
// Error: Resolve from sibling \'custom_resolve_dir\' first!
|
||||||
import { name } from \"testproj2\";
|
import { name } from \"testproj2\";
|
||||||
|
|
||||||
(name: \"node_modules/testproj2\");
|
(name: \"node_modules/testproj2\");
|
||||||
|
|
||||||
(name: \"subdir/custom_resolve_dir/testproj2\");
|
(name: \"subdir/custom_resolve_dir/testproj2\");
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -48,12 +48,14 @@ class A {
|
||||||
return \"some string\";
|
return \"some string\";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
A._sProperty = 48;
|
A._sProperty = 48;
|
||||||
class B extends A {
|
class B extends A {
|
||||||
_property1: string;
|
_property1: string;
|
||||||
static _sProperty: string;
|
static _sProperty: string;
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this._property1 = \"another string\";
|
this._property1 = \"another string\";
|
||||||
}
|
}
|
||||||
_method1(): string {
|
_method1(): string {
|
||||||
|
@ -63,6 +65,7 @@ class B extends A {
|
||||||
return 23;
|
return 23;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
B._sProperty = \"B._sProperty string\";
|
B._sProperty = \"B._sProperty string\";
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -80,6 +83,7 @@ module.exports = new C;
|
||||||
class C {
|
class C {
|
||||||
_p: string;
|
_p: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = new C();
|
module.exports = new C();
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -48,12 +48,14 @@ class A {
|
||||||
return \"some string\";
|
return \"some string\";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
A._sProperty = 48;
|
A._sProperty = 48;
|
||||||
class B extends A {
|
class B extends A {
|
||||||
_property1: string;
|
_property1: string;
|
||||||
static _sProperty: string;
|
static _sProperty: string;
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this._property1 = \"another string\";
|
this._property1 = \"another string\";
|
||||||
}
|
}
|
||||||
_method1(): string {
|
_method1(): string {
|
||||||
|
@ -63,6 +65,7 @@ class B extends A {
|
||||||
return 23;
|
return 23;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
B._sProperty = \"B._sProperty string\";
|
B._sProperty = \"B._sProperty string\";
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -52,6 +52,7 @@ function durable_refi(x: ?number) {
|
||||||
function cannot_reassign(x: string) {
|
function cannot_reassign(x: string) {
|
||||||
x = \"hey\";
|
x = \"hey\";
|
||||||
}
|
}
|
||||||
|
|
||||||
function durable_refi(x: ?number) {
|
function durable_refi(x: ?number) {
|
||||||
if (x) {
|
if (x) {
|
||||||
return () => {
|
return () => {
|
||||||
|
|
|
@ -10,15 +10,12 @@ class D {
|
||||||
module.exports = C;
|
module.exports = C;
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
class C {
|
class C {
|
||||||
constructor() {
|
constructor() {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
class D {
|
class D {
|
||||||
constructor(): number {
|
constructor(): number {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = C;
|
module.exports = C;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -32,12 +32,15 @@ exports.Foo2 = (Foo: Class<IFoo>);
|
||||||
function Foo() {
|
function Foo() {
|
||||||
this.x = 0;
|
this.x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Foo.y = 0;
|
Foo.y = 0;
|
||||||
|
|
||||||
Foo.prototype = {
|
Foo.prototype = {
|
||||||
m() {
|
m() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.Foo = Foo;
|
exports.Foo = Foo;
|
||||||
interface IFooPrototype { m(): number }
|
interface IFooPrototype { m(): number }
|
||||||
interface IFoo extends IFooPrototype {
|
interface IFoo extends IFooPrototype {
|
||||||
|
@ -45,6 +48,7 @@ interface IFoo extends IFooPrototype {
|
||||||
x: boolean;
|
x: boolean;
|
||||||
static y: boolean
|
static y: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.Foo2 = (Foo: Class<IFoo>);
|
exports.Foo2 = (Foo: Class<IFoo>);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -11,6 +11,7 @@ xxx
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
require(\"./dummy\");
|
require(\"./dummy\");
|
||||||
var xxx = 0;
|
var xxx = 0;
|
||||||
|
|
||||||
xxx;
|
xxx;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -11,6 +11,7 @@ xxx
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
require(\"./dummy\");
|
require(\"./dummy\");
|
||||||
var xxx = 0;
|
var xxx = 0;
|
||||||
|
|
||||||
xxx;
|
xxx;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -51,18 +51,27 @@ let tests = [
|
||||||
let tests = [
|
let tests = [
|
||||||
function() {
|
function() {
|
||||||
new Boolean();
|
new Boolean();
|
||||||
|
|
||||||
new Boolean(0);
|
new Boolean(0);
|
||||||
|
|
||||||
new Boolean(-0);
|
new Boolean(-0);
|
||||||
|
|
||||||
new Boolean(null);
|
new Boolean(null);
|
||||||
|
|
||||||
new Boolean(false);
|
new Boolean(false);
|
||||||
|
|
||||||
new Boolean(NaN);
|
new Boolean(NaN);
|
||||||
|
|
||||||
new Boolean(undefined);
|
new Boolean(undefined);
|
||||||
|
|
||||||
new Boolean(\"\");
|
new Boolean(\"\");
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
true.toString();
|
true.toString();
|
||||||
let x: boolean = false;
|
let x: boolean = false;
|
||||||
|
|
||||||
x.toString();
|
x.toString();
|
||||||
|
|
||||||
new Boolean(true).toString();
|
new Boolean(true).toString();
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
|
@ -70,12 +79,19 @@ let tests = [
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
Boolean();
|
Boolean();
|
||||||
|
|
||||||
Boolean(0);
|
Boolean(0);
|
||||||
|
|
||||||
Boolean(-0);
|
Boolean(-0);
|
||||||
|
|
||||||
Boolean(null);
|
Boolean(null);
|
||||||
|
|
||||||
Boolean(false);
|
Boolean(false);
|
||||||
|
|
||||||
Boolean(NaN);
|
Boolean(NaN);
|
||||||
|
|
||||||
Boolean(undefined);
|
Boolean(undefined);
|
||||||
|
|
||||||
Boolean(\"\");
|
Boolean(\"\");
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -145,6 +161,7 @@ let tests = [
|
||||||
},
|
},
|
||||||
function(x: Map<string, number>) {
|
function(x: Map<string, number>) {
|
||||||
(x.get(\"foo\"): boolean);
|
(x.get(\"foo\"): boolean);
|
||||||
|
|
||||||
x.get(123);
|
x.get(123);
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -195,22 +212,33 @@ let tests = [
|
||||||
let tests = [
|
let tests = [
|
||||||
function() {
|
function() {
|
||||||
new RegExp(\"foo\");
|
new RegExp(\"foo\");
|
||||||
|
|
||||||
new RegExp(/foo/);
|
new RegExp(/foo/);
|
||||||
|
|
||||||
new RegExp(\"foo\", \"i\");
|
new RegExp(\"foo\", \"i\");
|
||||||
|
|
||||||
new RegExp(\"foo\", \"ig\");
|
new RegExp(\"foo\", \"ig\");
|
||||||
|
|
||||||
new RegExp(/foo/, \"i\");
|
new RegExp(/foo/, \"i\");
|
||||||
|
|
||||||
new RegExp(/foo/g, \"i\");
|
new RegExp(/foo/g, \"i\");
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
RegExp(\"foo\");
|
RegExp(\"foo\");
|
||||||
|
|
||||||
RegExp(/foo/);
|
RegExp(/foo/);
|
||||||
|
|
||||||
RegExp(\"foo\", \"i\");
|
RegExp(\"foo\", \"i\");
|
||||||
|
|
||||||
RegExp(\"foo\", \"ig\");
|
RegExp(\"foo\", \"ig\");
|
||||||
|
|
||||||
RegExp(/foo/, \"i\");
|
RegExp(/foo/, \"i\");
|
||||||
|
|
||||||
RegExp(/foo/g, \"i\");
|
RegExp(/foo/g, \"i\");
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
RegExp(\"foo\", \"z\");
|
RegExp(\"foo\", \"z\");
|
||||||
|
|
||||||
new 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 ws = new WeakSet();
|
||||||
let obj: Object = {};
|
let obj: Object = {};
|
||||||
let dict: { foo: string } = { foo: \"bar\" };
|
let dict: { foo: string } = { foo: \"bar\" };
|
||||||
|
|
||||||
ws.add(window);
|
ws.add(window);
|
||||||
|
|
||||||
ws.add(obj);
|
ws.add(obj);
|
||||||
|
|
||||||
ws.add(dict);
|
ws.add(dict);
|
||||||
|
|
||||||
ws.has(window);
|
ws.has(window);
|
||||||
|
|
||||||
ws.has(obj);
|
ws.has(obj);
|
||||||
|
|
||||||
ws.has(dict);
|
ws.has(dict);
|
||||||
|
|
||||||
ws.delete(window);
|
ws.delete(window);
|
||||||
|
|
||||||
ws.delete(obj);
|
ws.delete(obj);
|
||||||
|
|
||||||
ws.delete(dict);
|
ws.delete(dict);
|
||||||
let ws2 = new WeakSet([ obj, dict ]);
|
let ws2 = new WeakSet([ obj, dict ]);
|
||||||
let ws3 = new WeakSet([ 1, 2, 3 ]);
|
let ws3 = new WeakSet([ 1, 2, 3 ]);
|
||||||
|
|
||||||
function* generator(): Iterable<{ foo: string }> {
|
function* generator(): Iterable<{ foo: string }> {
|
||||||
while (true) {
|
while (true) {
|
||||||
yield { foo: \"bar\" };
|
yield { foo: \"bar\" };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let ws4 = new WeakSet(generator());
|
let ws4 = new WeakSet(generator());
|
||||||
|
|
||||||
function* numbers(): Iterable<number> {
|
function* numbers(): Iterable<number> {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
|
@ -87,8 +87,9 @@ n.x = [0];
|
||||||
|
|
||||||
*/
|
*/
|
||||||
type CovArrayVerbose<X, Y: X> = Array<Y>;
|
type CovArrayVerbose<X, Y: X> = Array<Y>;
|
||||||
var b: CovArrayVerbose<number, *> = [ ];
|
var b: CovArrayVerbose<number, *> = [];
|
||||||
var y: CovArrayVerbose<mixed, *> = b;
|
var y: CovArrayVerbose<mixed, *> = b;
|
||||||
|
|
||||||
y[0] = \"\";
|
y[0] = \"\";
|
||||||
class NVerbose<E, I: E> {
|
class NVerbose<E, I: E> {
|
||||||
x: CovArrayVerbose<E, I>;
|
x: CovArrayVerbose<E, I>;
|
||||||
|
@ -97,8 +98,11 @@ class NVerbose<E, I: E> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var nv: NVerbose<number, *> = new NVerbose();
|
var nv: NVerbose<number, *> = new NVerbose();
|
||||||
|
|
||||||
nv.x = [ 0 ];
|
nv.x = [ 0 ];
|
||||||
|
|
||||||
(nv.x[0]: string);
|
(nv.x[0]: string);
|
||||||
|
|
||||||
(nv.foo()[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
|
// that we implicitly assume in type-at-pos and coverage implementations. In
|
||||||
// particular, when unchecked it causes a crash with coverage --color.
|
// particular, when unchecked it causes a crash with coverage --color.
|
||||||
// TODO
|
// TODO
|
||||||
declare module foo {
|
declare module foo {}
|
||||||
|
declare module bar {}
|
||||||
}
|
|
||||||
declare module bar {
|
|
||||||
|
|
||||||
}
|
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -31,9 +27,7 @@ declare module foo {
|
||||||
}
|
}
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// check coverage of declare module
|
// check coverage of declare module
|
||||||
declare module foo {
|
declare module foo {}
|
||||||
|
|
||||||
}
|
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -42,6 +36,7 @@ exports[`test no_pragma.js 1`] = `
|
||||||
(x: string);
|
(x: string);
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
let x = 0;
|
let x = 0;
|
||||||
|
|
||||||
(x: string);
|
(x: string);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -66,12 +61,8 @@ declare class qux {
|
||||||
// that we implicitly assume in type-at-pos and coverage implementations. In
|
// that we implicitly assume in type-at-pos and coverage implementations. In
|
||||||
// particular, when unchecked it causes non-termination with coverage --color.
|
// particular, when unchecked it causes non-termination with coverage --color.
|
||||||
// TODO
|
// TODO
|
||||||
declare module foo {
|
declare module foo {}
|
||||||
|
declare module bar {}
|
||||||
}
|
|
||||||
declare module bar {
|
|
||||||
|
|
||||||
}
|
|
||||||
declare class qux {}
|
declare class qux {}
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -7,6 +7,7 @@ module.exports = A;
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
var B = require(\"./B\");
|
var B = require(\"./B\");
|
||||||
class A extends B {}
|
class A extends B {}
|
||||||
|
|
||||||
module.exports = A;
|
module.exports = A;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -20,6 +21,7 @@ module.exports = B;
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
//class B extends A { }
|
//class B extends A { }
|
||||||
var A = require(\"./A\");
|
var A = require(\"./A\");
|
||||||
|
|
||||||
module.exports = B;
|
module.exports = B;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -34,23 +34,41 @@ new Date(2015, 6, 18, 11, 55, 42, 999, \'hahaha\');
|
||||||
var d = new Date(0);
|
var d = new Date(0);
|
||||||
var x: string = d.getTime();
|
var x: string = d.getTime();
|
||||||
var y: number = d;
|
var y: number = d;
|
||||||
|
|
||||||
new Date();
|
new Date();
|
||||||
|
|
||||||
new Date(1234567890);
|
new Date(1234567890);
|
||||||
|
|
||||||
new Date(\"2015/06/18\");
|
new Date(\"2015/06/18\");
|
||||||
|
|
||||||
new Date(2015, 6);
|
new Date(2015, 6);
|
||||||
|
|
||||||
new Date(2015, 6, 18);
|
new Date(2015, 6, 18);
|
||||||
|
|
||||||
new Date(2015, 6, 18, 11);
|
new Date(2015, 6, 18, 11);
|
||||||
|
|
||||||
new Date(2015, 6, 18, 11, 55);
|
new Date(2015, 6, 18, 11, 55);
|
||||||
|
|
||||||
new Date(2015, 6, 18, 11, 55, 42);
|
new Date(2015, 6, 18, 11, 55, 42);
|
||||||
|
|
||||||
new Date(2015, 6, 18, 11, 55, 42, 999);
|
new Date(2015, 6, 18, 11, 55, 42, 999);
|
||||||
|
|
||||||
new Date({});
|
new Date({});
|
||||||
|
|
||||||
new Date(2015, \"6\");
|
new Date(2015, \"6\");
|
||||||
|
|
||||||
new Date(2015, 6, \"18\");
|
new Date(2015, 6, \"18\");
|
||||||
|
|
||||||
new Date(2015, 6, 18, \"11\");
|
new Date(2015, 6, 18, \"11\");
|
||||||
|
|
||||||
new Date(2015, 6, 18, 11, \"55\");
|
new Date(2015, 6, 18, 11, \"55\");
|
||||||
|
|
||||||
new Date(2015, 6, 18, 11, 55, \"42\");
|
new Date(2015, 6, 18, 11, 55, \"42\");
|
||||||
|
|
||||||
new Date(2015, 6, 18, 11, 55, 42, \"999\");
|
new Date(2015, 6, 18, 11, 55, 42, \"999\");
|
||||||
|
|
||||||
new Date(\"2015\", 6);
|
new Date(\"2015\", 6);
|
||||||
|
|
||||||
new Date(2015, 6, 18, 11, 55, 42, 999, \"hahaha\");
|
new Date(2015, 6, 18, 11, 55, 42, 999, \"hahaha\");
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -68,10 +68,13 @@ var ExplicitDifferentName = require(\'ExplicitProvidesModuleDifferentName\');
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
/* @flow */
|
/* @flow */
|
||||||
var Implicit = require(\"ImplicitProvidesModule\");
|
var Implicit = require(\"ImplicitProvidesModule\");
|
||||||
|
|
||||||
(Implicit.fun(): string);
|
(Implicit.fun(): string);
|
||||||
var ExplicitSameName = require(\"ExplicitProvidesModuleSameName\");
|
var ExplicitSameName = require(\"ExplicitProvidesModuleSameName\");
|
||||||
|
|
||||||
(ExplicitSameName.fun(): string);
|
(ExplicitSameName.fun(): string);
|
||||||
var ExplicitDifferentName = require(\"ExplicitProvidesModuleDifferentName\");
|
var ExplicitDifferentName = require(\"ExplicitProvidesModuleDifferentName\");
|
||||||
|
|
||||||
(ExplicitDifferentName.fun(): string);
|
(ExplicitDifferentName.fun(): string);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -20,8 +20,11 @@ var docblock = require(\"qux/docblock\");
|
||||||
var min = require(\"d3/min.js\");
|
var min = require(\"d3/min.js\");
|
||||||
var corge = require(\"qux/corge\");
|
var corge = require(\"qux/corge\");
|
||||||
var unreachable = require(\"annotation\");
|
var unreachable = require(\"annotation\");
|
||||||
|
|
||||||
(docblock.fun(): string);
|
(docblock.fun(): string);
|
||||||
|
|
||||||
(min.fun(): string);
|
(min.fun(): string);
|
||||||
|
|
||||||
(corge.fun(): string);
|
(corge.fun(): string);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -25,6 +25,7 @@ module.exports.fun = (): Implementation => new Implementation;
|
||||||
* @flow
|
* @flow
|
||||||
*/
|
*/
|
||||||
class Implementation {}
|
class Implementation {}
|
||||||
|
|
||||||
module.exports.fun = (): Implementation => new Implementation();
|
module.exports.fun = (): Implementation => new Implementation();
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -43,6 +44,7 @@ module.exports.fun = (): Implementation => new Implementation;
|
||||||
* @flow
|
* @flow
|
||||||
*/
|
*/
|
||||||
class Implementation {}
|
class Implementation {}
|
||||||
|
|
||||||
module.exports.fun = (): Implementation => new Implementation();
|
module.exports.fun = (): Implementation => new Implementation();
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -61,6 +63,7 @@ module.exports.fun = (): Implementation => new Implementation;
|
||||||
* @flow
|
* @flow
|
||||||
*/
|
*/
|
||||||
class Implementation {}
|
class Implementation {}
|
||||||
|
|
||||||
module.exports.fun = (): Implementation => new 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
|
||||||
// Error: Either Implementation ~> boolean or Declaration ~> boolean
|
// Error: Either Implementation ~> boolean or Declaration ~> boolean
|
||||||
var Implicit = require(\"ImplicitProvidesModule\");
|
var Implicit = require(\"ImplicitProvidesModule\");
|
||||||
|
|
||||||
(Implicit.fun(): boolean);
|
(Implicit.fun(): boolean);
|
||||||
var ExplicitSameName = require(\"ExplicitProvidesModuleSameName\");
|
var ExplicitSameName = require(\"ExplicitProvidesModuleSameName\");
|
||||||
|
|
||||||
(ExplicitSameName.fun(): boolean);
|
(ExplicitSameName.fun(): boolean);
|
||||||
var ExplicitDifferentName = require(\"ExplicitProvidesModuleDifferentName\");
|
var ExplicitDifferentName = require(\"ExplicitProvidesModuleDifferentName\");
|
||||||
|
|
||||||
(ExplicitDifferentName.fun(): boolean);
|
(ExplicitDifferentName.fun(): boolean);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -3,6 +3,7 @@ exports[`test min.js 1`] = `
|
||||||
module.exports.fun = (): Implementation => new Implementation;
|
module.exports.fun = (): Implementation => new Implementation;
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
class Implementation {}
|
class Implementation {}
|
||||||
|
|
||||||
module.exports.fun = (): Implementation => new Implementation();
|
module.exports.fun = (): Implementation => new Implementation();
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -16,8 +16,11 @@ var corge = require(\'qux/corge\');
|
||||||
var docblock = require(\"qux/docblock\");
|
var docblock = require(\"qux/docblock\");
|
||||||
var min = require(\"d3/min.js\");
|
var min = require(\"d3/min.js\");
|
||||||
var corge = require(\"qux/corge\");
|
var corge = require(\"qux/corge\");
|
||||||
|
|
||||||
(docblock.fun(): boolean);
|
(docblock.fun(): boolean);
|
||||||
|
|
||||||
(min.fun(): boolean);
|
(min.fun(): boolean);
|
||||||
|
|
||||||
(corge.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
|
||||||
// Error either Implementation ~> boolean or Declaration ~> boolean
|
// Error either Implementation ~> boolean or Declaration ~> boolean
|
||||||
var B1 = require(\"B\");
|
var B1 = require(\"B\");
|
||||||
|
|
||||||
(B1.fun(): boolean);
|
(B1.fun(): boolean);
|
||||||
var B2 = require(\"B.js\");
|
var B2 = require(\"B.js\");
|
||||||
|
|
||||||
(B2.fun(): boolean);
|
(B2.fun(): boolean);
|
||||||
var C = require(\"package_with_full_main\");
|
var C = require(\"package_with_full_main\");
|
||||||
|
|
||||||
(C.fun(): boolean);
|
(C.fun(): boolean);
|
||||||
var D = require(\"package_with_partial_main\");
|
var D = require(\"package_with_partial_main\");
|
||||||
|
|
||||||
(D.fun(): boolean);
|
(D.fun(): boolean);
|
||||||
var E = require(\"package_with_no_package_json\");
|
var E = require(\"package_with_no_package_json\");
|
||||||
|
|
||||||
(E.fun(): boolean);
|
(E.fun(): boolean);
|
||||||
var F = require(\"package_with_dir_main\");
|
var F = require(\"package_with_dir_main\");
|
||||||
|
|
||||||
(F.fun(): boolean);
|
(F.fun(): boolean);
|
||||||
var B1 = require(\"B\");
|
var B1 = require(\"B\");
|
||||||
|
|
||||||
(B1.fun(): boolean);
|
(B1.fun(): boolean);
|
||||||
var B2 = require(\"B.js\");
|
var B2 = require(\"B.js\");
|
||||||
|
|
||||||
(B2.fun(): boolean);
|
(B2.fun(): boolean);
|
||||||
var C = require(\"package_with_full_main\");
|
var C = require(\"package_with_full_main\");
|
||||||
|
|
||||||
(C.fun(): boolean);
|
(C.fun(): boolean);
|
||||||
var D = require(\"package_with_partial_main\");
|
var D = require(\"package_with_partial_main\");
|
||||||
|
|
||||||
(D.fun(): boolean);
|
(D.fun(): boolean);
|
||||||
var E = require(\"package_with_no_package_json\");
|
var E = require(\"package_with_no_package_json\");
|
||||||
|
|
||||||
(E.fun(): boolean);
|
(E.fun(): boolean);
|
||||||
var F = require(\"package_with_dir_main\");
|
var F = require(\"package_with_dir_main\");
|
||||||
|
|
||||||
(F.fun(): boolean);
|
(F.fun(): boolean);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -103,6 +115,7 @@ exports[`test test_relative.js 1`] = `
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// Error: either Implementation ~> boolean or Definition ~> boolean
|
// Error: either Implementation ~> boolean or Definition ~> boolean
|
||||||
import { foo } from \"./A\";
|
import { foo } from \"./A\";
|
||||||
|
|
||||||
(foo(): boolean);
|
(foo(): boolean);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -50,16 +50,22 @@ var F = require(\'package_with_dir_main\');
|
||||||
// Error number ~> string
|
// Error number ~> string
|
||||||
// Error number ~> string
|
// Error number ~> string
|
||||||
var B1 = require(\"B\");
|
var B1 = require(\"B\");
|
||||||
|
|
||||||
(B1.fun(): string);
|
(B1.fun(): string);
|
||||||
var B2 = require(\"B.js\");
|
var B2 = require(\"B.js\");
|
||||||
|
|
||||||
(B2.fun(): string);
|
(B2.fun(): string);
|
||||||
var C = require(\"package_with_full_main\");
|
var C = require(\"package_with_full_main\");
|
||||||
|
|
||||||
(C.fun(): string);
|
(C.fun(): string);
|
||||||
var D = require(\"package_with_partial_main\");
|
var D = require(\"package_with_partial_main\");
|
||||||
|
|
||||||
(D.fun(): string);
|
(D.fun(): string);
|
||||||
var E = require(\"package_with_no_package_json\");
|
var E = require(\"package_with_no_package_json\");
|
||||||
|
|
||||||
(E.fun(): string);
|
(E.fun(): string);
|
||||||
var F = require(\"package_with_dir_main\");
|
var F = require(\"package_with_dir_main\");
|
||||||
|
|
||||||
(F.fun(): string);
|
(F.fun(): string);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -86,11 +92,15 @@ var CJS = require(\'./CJS.js\');
|
||||||
// Error number ~> string
|
// Error number ~> string
|
||||||
// Error: string ~> number
|
// Error: string ~> number
|
||||||
var A1 = require(\"./A\");
|
var A1 = require(\"./A\");
|
||||||
|
|
||||||
(A1.fun(): string);
|
(A1.fun(): string);
|
||||||
var A2 = require(\"./A.js\");
|
var A2 = require(\"./A.js\");
|
||||||
|
|
||||||
(A2.fun(): string);
|
(A2.fun(): string);
|
||||||
var CJS = require(\"./CJS.js\");
|
var CJS = require(\"./CJS.js\");
|
||||||
|
|
||||||
(CJS: string);
|
(CJS: string);
|
||||||
|
|
||||||
(CJS: number);
|
(CJS: number);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -12,9 +12,13 @@ C.foo(\"\");
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// error, it\'s a string
|
// error, it\'s a string
|
||||||
declare class C { static x: number; static foo(x: number): void }
|
declare class C { static x: number; static foo(x: number): void }
|
||||||
|
|
||||||
C.x = \"\";
|
C.x = \"\";
|
||||||
|
|
||||||
C.foo(\"\");
|
C.foo(\"\");
|
||||||
|
|
||||||
(C.name: string);
|
(C.name: string);
|
||||||
|
|
||||||
(C.name: number);
|
(C.name: number);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -64,6 +64,7 @@ class Test extends Base {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Test;
|
module.exports = Test;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -113,9 +114,13 @@ exports.numberValue5 = 5;
|
||||||
* @flow
|
* @flow
|
||||||
*/
|
*/
|
||||||
exports.numberValue1 = 1;
|
exports.numberValue1 = 1;
|
||||||
|
|
||||||
exports.numberValue2 = 2;
|
exports.numberValue2 = 2;
|
||||||
|
|
||||||
exports.numberValue3 = 3;
|
exports.numberValue3 = 3;
|
||||||
|
|
||||||
exports.numberValue4 = 4;
|
exports.numberValue4 = 4;
|
||||||
|
|
||||||
exports.numberValue5 = 5;
|
exports.numberValue5 = 5;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -488,9 +493,13 @@ exports.stringValue = \"str\";
|
||||||
* @flow
|
* @flow
|
||||||
*/
|
*/
|
||||||
exports.numberValue1 = 42;
|
exports.numberValue1 = 42;
|
||||||
|
|
||||||
exports.numberValue2 = 42;
|
exports.numberValue2 = 42;
|
||||||
|
|
||||||
exports.numberValue3 = 42;
|
exports.numberValue3 = 42;
|
||||||
|
|
||||||
exports.numberValue4 = 42;
|
exports.numberValue4 = 42;
|
||||||
|
|
||||||
exports.stringValue = \"str\";
|
exports.stringValue = \"str\";
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -981,23 +990,28 @@ var d2: string = numVal1;
|
||||||
import CJS_Clobb_Lit from \"CommonJS_Clobbering_Lit\";
|
import CJS_Clobb_Lit from \"CommonJS_Clobbering_Lit\";
|
||||||
var e1: number = CJS_Clobb_Lit.numberValue3;
|
var e1: number = CJS_Clobb_Lit.numberValue3;
|
||||||
var e2: string = CJS_Clobb_Lit.numberValue3;
|
var e2: string = CJS_Clobb_Lit.numberValue3;
|
||||||
|
|
||||||
CJS_Clobb_Lit.doesntExist;
|
CJS_Clobb_Lit.doesntExist;
|
||||||
import * as CJS_Clobb_Lit_NS from \"CommonJS_Clobbering_Lit\";
|
import * as CJS_Clobb_Lit_NS from \"CommonJS_Clobbering_Lit\";
|
||||||
var f1: number = CJS_Clobb_Lit_NS.numberValue4;
|
var f1: number = CJS_Clobb_Lit_NS.numberValue4;
|
||||||
var f2: number = CJS_Clobb_Lit_NS.default.numberValue4;
|
var f2: number = CJS_Clobb_Lit_NS.default.numberValue4;
|
||||||
|
|
||||||
CJS_Clobb_Lit_NS.default.default;
|
CJS_Clobb_Lit_NS.default.default;
|
||||||
var f3: string = CJS_Clobb_Lit_NS.numberValue4;
|
var f3: string = CJS_Clobb_Lit_NS.numberValue4;
|
||||||
var f4: string = CJS_Clobb_Lit_NS.default.numberValue5;
|
var f4: string = CJS_Clobb_Lit_NS.default.numberValue5;
|
||||||
import { doesntExist2 } from \"CommonJS_Clobbering_Class\";
|
import { doesntExist2 } from \"CommonJS_Clobbering_Class\";
|
||||||
import { staticNumber1, baseProp, childProp } from \"CommonJS_Clobbering_Class\";
|
import { staticNumber1, baseProp, childProp } from \"CommonJS_Clobbering_Class\";
|
||||||
import CJS_Clobb_Class from \"CommonJS_Clobbering_Class\";
|
import CJS_Clobb_Class from \"CommonJS_Clobbering_Class\";
|
||||||
|
|
||||||
new CJS_Clobb_Class();
|
new CJS_Clobb_Class();
|
||||||
|
|
||||||
new CJS_Clobb_Class().doesntExist;
|
new CJS_Clobb_Class().doesntExist;
|
||||||
var h1: number = CJS_Clobb_Class.staticNumber2();
|
var h1: number = CJS_Clobb_Class.staticNumber2();
|
||||||
var h2: string = CJS_Clobb_Class.staticNumber2();
|
var h2: string = CJS_Clobb_Class.staticNumber2();
|
||||||
var h3: number = new CJS_Clobb_Class().instNumber1();
|
var h3: number = new CJS_Clobb_Class().instNumber1();
|
||||||
var h4: string = new CJS_Clobb_Class().instNumber1();
|
var h4: string = new CJS_Clobb_Class().instNumber1();
|
||||||
import * as CJS_Clobb_Class_NS from \"CommonJS_Clobbering_Class\";
|
import * as CJS_Clobb_Class_NS from \"CommonJS_Clobbering_Class\";
|
||||||
|
|
||||||
new CJS_Clobb_Class_NS();
|
new CJS_Clobb_Class_NS();
|
||||||
var i1: number = CJS_Clobb_Class_NS.staticNumber3();
|
var i1: number = CJS_Clobb_Class_NS.staticNumber3();
|
||||||
var i2: number = new CJS_Clobb_Class_NS.default().instNumber2();
|
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\";
|
import * as CJS_Named from \"CommonJS_Named\";
|
||||||
var l1: number = CJS_Named.numberValue1;
|
var l1: number = CJS_Named.numberValue1;
|
||||||
var l2: string = CJS_Named.numberValue1;
|
var l2: string = CJS_Named.numberValue1;
|
||||||
|
|
||||||
CJS_Named.doesntExist;
|
CJS_Named.doesntExist;
|
||||||
import * as CJS_Named_NS from \"CommonJS_Named\";
|
import * as CJS_Named_NS from \"CommonJS_Named\";
|
||||||
var m1: number = CJS_Named_NS.numberValue4;
|
var m1: number = CJS_Named_NS.numberValue4;
|
||||||
|
@ -1062,6 +1077,7 @@ var ab2: string = numberValue2_renamed;
|
||||||
import { numberValue1 as numberValue5 } from \"ES6_ExportAllFrom_Intermediary1\";
|
import { numberValue1 as numberValue5 } from \"ES6_ExportAllFrom_Intermediary1\";
|
||||||
var ac1: number = numberValue5;
|
var ac1: number = numberValue5;
|
||||||
var ac2: string = numberValue5;
|
var ac2: string = numberValue5;
|
||||||
|
|
||||||
require(\"ES6_Default_AnonFunction2\").doesntExist;
|
require(\"ES6_Default_AnonFunction2\").doesntExist;
|
||||||
var ES6_Def_AnonFunc2 = require(\"ES6_Default_AnonFunction2\").default;
|
var ES6_Def_AnonFunc2 = require(\"ES6_Default_AnonFunction2\").default;
|
||||||
var ad1: number = ES6_Def_AnonFunc2();
|
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: number): string;
|
||||||
declare function foo(x: string): number;
|
declare function foo(x: string): number;
|
||||||
declare function foo<X>(x: X): X;
|
declare function foo<X>(x: X): X;
|
||||||
|
|
||||||
(foo(0): string);
|
(foo(0): string);
|
||||||
|
|
||||||
(foo(\"hello\"): number);
|
(foo(\"hello\"): number);
|
||||||
|
|
||||||
(foo(false): void);
|
(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
|
||||||
// Error: number ~> string
|
// Error: number ~> string
|
||||||
import declare_module_exports from \"declare_module_exports\";
|
import declare_module_exports from \"declare_module_exports\";
|
||||||
|
|
||||||
(declare_module_exports: number);
|
(declare_module_exports: number);
|
||||||
|
|
||||||
(declare_module_exports: string);
|
(declare_module_exports: string);
|
||||||
import { str } from \"declare_m_e_with_other_value_declares\";
|
import { str } from \"declare_m_e_with_other_value_declares\";
|
||||||
import type { str2 } from \"declare_m_e_with_other_type_declares\";
|
import type { str2 } from \"declare_m_e_with_other_type_declares\";
|
||||||
|
|
||||||
(\"asdf\": str2);
|
(\"asdf\": str2);
|
||||||
|
|
||||||
(42: str2);
|
(42: str2);
|
||||||
import DEPRECATED__declare_var_exports from \"DEPRECATED__declare_var_exports\";
|
import DEPRECATED__declare_var_exports from \"DEPRECATED__declare_var_exports\";
|
||||||
|
|
||||||
(DEPRECATED__declare_var_exports: number);
|
(DEPRECATED__declare_var_exports: number);
|
||||||
|
|
||||||
(DEPRECATED__declare_var_exports: string);
|
(DEPRECATED__declare_var_exports: string);
|
||||||
import declare_m_e_with_declare_var_e from \"declare_m_e_with_declare_var_e\";
|
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: number);
|
||||||
|
|
||||||
(declare_m_e_with_declare_var_e: string);
|
(declare_m_e_with_declare_var_e: string);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -54,9 +54,13 @@ import type { toz } from \"ModuleAliasFoo\";
|
||||||
var k4: toz = foo(k1);
|
var k4: toz = foo(k1);
|
||||||
import blah from \"foo\";
|
import blah from \"foo\";
|
||||||
import type { Foo, Bar, Id } from \"foo\";
|
import type { Foo, Bar, Id } from \"foo\";
|
||||||
|
|
||||||
blah(0, 0);
|
blah(0, 0);
|
||||||
|
|
||||||
({ toz: 3 }: Foo);
|
({ toz: 3 }: Foo);
|
||||||
|
|
||||||
(3: Bar);
|
(3: Bar);
|
||||||
|
|
||||||
(\"lol\": Id<number>);
|
(\"lol\": Id<number>);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -55,8 +55,10 @@ class Variance<+Out, -In> {
|
||||||
}
|
}
|
||||||
class A {}
|
class A {}
|
||||||
class B extends A {}
|
class B extends A {}
|
||||||
|
|
||||||
function subtyping(v1: Variance<A, B>, v2: Variance<B, A>) {
|
function subtyping(v1: Variance<A, B>, v2: Variance<B, A>) {
|
||||||
(v1: Variance<B, A>);
|
(v1: Variance<B, A>);
|
||||||
|
|
||||||
(v2: Variance<A, B>);
|
(v2: Variance<A, B>);
|
||||||
}
|
}
|
||||||
class PropVariance<+Out, -In> {
|
class PropVariance<+Out, -In> {
|
||||||
|
|
|
@ -14,6 +14,7 @@ function f(x) {
|
||||||
return 42 / x;
|
return 42 / x;
|
||||||
}
|
}
|
||||||
var x = null;
|
var x = null;
|
||||||
|
|
||||||
f(x);
|
f(x);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -33,11 +33,14 @@ class A {
|
||||||
return callback(this.getX());
|
return callback(this.getX());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function callback(x: string) {
|
function callback(x: string) {
|
||||||
return x.length;
|
return x.length;
|
||||||
}
|
}
|
||||||
var a = new A(42);
|
var a = new A(42);
|
||||||
|
|
||||||
a.onLoad(callback);
|
a.onLoad(callback);
|
||||||
|
|
||||||
module.exports = A;
|
module.exports = A;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -19,8 +19,11 @@ require(\'./F\');
|
||||||
require(\'./G\');
|
require(\'./G\');
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
require(\"./D\");
|
require(\"./D\");
|
||||||
|
|
||||||
require(\"./E\");
|
require(\"./E\");
|
||||||
|
|
||||||
require(\"./F\");
|
require(\"./F\");
|
||||||
|
|
||||||
require(\"./G\");
|
require(\"./G\");
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -23,9 +23,13 @@ let [ a, ...ys ] = xs;
|
||||||
let [ b, ...zs ] = ys;
|
let [ b, ...zs ] = ys;
|
||||||
let c = zs[0];
|
let c = zs[0];
|
||||||
let d = zs[1];
|
let d = zs[1];
|
||||||
|
|
||||||
(a: void);
|
(a: void);
|
||||||
|
|
||||||
(b: void);
|
(b: void);
|
||||||
|
|
||||||
(c: void);
|
(c: void);
|
||||||
|
|
||||||
(d: void);
|
(d: void);
|
||||||
let [ ...e ] = 0;
|
let [ ...e ] = 0;
|
||||||
"
|
"
|
||||||
|
@ -46,11 +50,14 @@ var { [\"key\"]: val3, ...spread } = { key: \"val\" };
|
||||||
// ok (gasp!) by existing StrT -> ElemT rule
|
// ok (gasp!) by existing StrT -> ElemT rule
|
||||||
// error (gasp!) in general we don\'t know if a computed prop should be excluded from spread
|
// error (gasp!) in general we don\'t know if a computed prop should be excluded from spread
|
||||||
var { [\"key\"]: val1 } = { key: \"val\" };
|
var { [\"key\"]: val1 } = { key: \"val\" };
|
||||||
|
|
||||||
(val1: void);
|
(val1: void);
|
||||||
var key: string = \"key\";
|
var key: string = \"key\";
|
||||||
var { [key]: val2 } = { key: \"val\" };
|
var { [key]: val2 } = { key: \"val\" };
|
||||||
|
|
||||||
(val2: void);
|
(val2: void);
|
||||||
var { [\"key\"]: val3, ...spread } = { key: \"val\" };
|
var { [\"key\"]: val3, ...spread } = { key: \"val\" };
|
||||||
|
|
||||||
(spread.key: void);
|
(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: \"\" } }) {
|
function obj_prop_fun({ p: { q = 0 } = { q: true } } = { p: { q: \"\" } }) {
|
||||||
(q: void);
|
(q: void);
|
||||||
}
|
}
|
||||||
|
|
||||||
obj_prop_fun();
|
obj_prop_fun();
|
||||||
|
|
||||||
obj_prop_fun({});
|
obj_prop_fun({});
|
||||||
|
|
||||||
obj_prop_fun({ p: {} });
|
obj_prop_fun({ p: {} });
|
||||||
|
|
||||||
obj_prop_fun({ p: { q: null } });
|
obj_prop_fun({ p: { q: null } });
|
||||||
|
|
||||||
function obj_prop_var(o = { p: { q: \"\" } }) {
|
function obj_prop_var(o = { p: { q: \"\" } }) {
|
||||||
var { p: { q = 0 } = { q: true } } = o;
|
var { p: { q = 0 } = { q: true } } = o;
|
||||||
|
|
||||||
(q: void);
|
(q: void);
|
||||||
}
|
}
|
||||||
|
|
||||||
obj_prop_var();
|
obj_prop_var();
|
||||||
|
|
||||||
obj_prop_var({});
|
obj_prop_var({});
|
||||||
|
|
||||||
obj_prop_var({ p: {} });
|
obj_prop_var({ p: {} });
|
||||||
|
|
||||||
obj_prop_var({ p: { q: null } });
|
obj_prop_var({ p: { q: null } });
|
||||||
|
|
||||||
function obj_rest(
|
function obj_rest(
|
||||||
{ p: { q, ...o } = { q: 0, r: 0 } } = { p: { q: 0, r: \"\" } }
|
{ p: { q, ...o } = { q: 0, r: 0 } } = { p: { q: 0, r: \"\" } }
|
||||||
) {
|
) {
|
||||||
(o.r: void);
|
(o.r: void);
|
||||||
}
|
}
|
||||||
|
|
||||||
obj_rest();
|
obj_rest();
|
||||||
|
|
||||||
obj_rest({});
|
obj_rest({});
|
||||||
|
|
||||||
obj_rest({ p: {} });
|
obj_rest({ p: {} });
|
||||||
|
|
||||||
obj_rest({ p: { q: 0, r: null } });
|
obj_rest({ p: { q: 0, r: null } });
|
||||||
|
|
||||||
function obj_prop_annot({ p = true }: { p: string } = { p: 0 }) {
|
function obj_prop_annot({ p = true }: { p: string } = { p: 0 }) {
|
||||||
(p: void);
|
(p: void);
|
||||||
}
|
}
|
||||||
var { p = true }: { p: string } = { p: 0 };
|
var { p = true }: { p: string } = { p: 0 };
|
||||||
|
|
||||||
(p: void);
|
(p: void);
|
||||||
function obj_prop_err({ x: { y } } = null) {
|
|
||||||
|
|
||||||
}
|
function obj_prop_err({ x: { y } } = null) {}
|
||||||
function obj_rest_err({ ...o } = 0) {
|
|
||||||
|
|
||||||
}
|
function obj_rest_err({ ...o } = 0) {}
|
||||||
function arr_elem_err([ x ] = null) {
|
|
||||||
|
|
||||||
}
|
function arr_elem_err([ x ] = null) {}
|
||||||
function arr_rest_err([ ...a ] = null) {
|
|
||||||
|
function arr_rest_err([ ...a ] = null) {}
|
||||||
|
|
||||||
}
|
|
||||||
function gen<T>(x: T, { p = x }: { p: T }): T {
|
function gen<T>(x: T, { p = x }: { p: T }): T {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
obj_prop_fun(({}: { p?: { q?: null } }));
|
obj_prop_fun(({}: { p?: { q?: null } }));
|
||||||
|
|
||||||
obj_prop_var(({}: { p?: { q?: null } }));
|
obj_prop_var(({}: { p?: { q?: null } }));
|
||||||
function obj_prop_opt({ p }: { p?: string } = { p: 0 }) {
|
|
||||||
|
|
||||||
}
|
function obj_prop_opt({ p }: { p?: string } = { p: 0 }) {}
|
||||||
function obj_prop_maybe({ p }: { p: ?string } = { p: 0 }) {
|
|
||||||
|
|
||||||
}
|
function obj_prop_maybe({ p }: { p: ?string } = { p: 0 }) {}
|
||||||
function obj_prop_union({ p }: { p: number | string } = { p: true }) {
|
|
||||||
|
|
||||||
}
|
function obj_prop_union({ p }: { p: number | string } = { p: true }) {}
|
||||||
function obj_prop_union2({ p }: { p: number } | { p: string } = { p: true }) {
|
|
||||||
|
|
||||||
}
|
function obj_prop_union2({ p }: { p: number } | { p: string } = { p: true }) {}
|
||||||
function default_expr_scope({ a, b = a }) {
|
|
||||||
|
|
||||||
}
|
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 a: string;
|
||||||
declare var b: string;
|
declare var b: string;
|
||||||
declare var c: string;
|
declare var c: string;
|
||||||
|
|
||||||
[ { a1: a, b }, c ] = [ { a1: 0, b: 1 }, 2 ];
|
[ { a1: a, b }, c ] = [ { a1: 0, b: 1 }, 2 ];
|
||||||
var { m } = { m: 0 };
|
var { m } = { m: 0 };
|
||||||
|
|
||||||
({ m } = { m: m });
|
({ m } = { m: m });
|
||||||
var obj;
|
var obj;
|
||||||
|
|
||||||
({ n: obj.x } = { n: 3 });
|
({ n: obj.x } = { n: 3 });
|
||||||
|
|
||||||
[ obj.x ] = [ \"foo\" ];
|
[ obj.x ] = [ \"foo\" ];
|
||||||
|
|
||||||
function foo({ p, z: [ r ] }) {
|
function foo({ p, z: [ r ] }) {
|
||||||
a = p;
|
a = p;
|
||||||
|
|
||||||
b = z;
|
b = z;
|
||||||
|
|
||||||
c = r;
|
c = r;
|
||||||
}
|
}
|
||||||
|
|
||||||
foo({ p: 0, z: [ 1, 2 ] });
|
foo({ p: 0, z: [ 1, 2 ] });
|
||||||
|
|
||||||
[ a, , b, ...c ] = [ 0, 1, true, 3 ];
|
[ a, , b, ...c ] = [ 0, 1, true, 3 ];
|
||||||
|
|
||||||
function bar({ x, ...z }) {
|
function bar({ x, ...z }) {
|
||||||
var o: { x: string; y: number } = z;
|
var o: { x: string; y: number } = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
bar({ x: \"\", y: 0 });
|
bar({ x: \"\", y: 0 });
|
||||||
var spread = { y: \"\" };
|
var spread = { y: \"\" };
|
||||||
var extend: { x: number; y: string; z: boolean } = { x: 0, ...spread };
|
var extend: { x: number; y: string; z: boolean } = { x: 0, ...spread };
|
||||||
function qux(_: { a: number }) {
|
|
||||||
|
|
||||||
}
|
function qux(_: { a: number }) {}
|
||||||
|
|
||||||
qux({ a: \"\" });
|
qux({ a: \"\" });
|
||||||
function corge({ b }: { b: string }) {
|
|
||||||
|
|
||||||
}
|
function corge({ b }: { b: string }) {}
|
||||||
|
|
||||||
corge({ b: 0 });
|
corge({ b: 0 });
|
||||||
var { n }: { n: number } = { n: \"\" };
|
var { n }: { n: number } = { n: \"\" };
|
||||||
|
|
||||||
function test() {
|
function test() {
|
||||||
var { foo } = { bar: 123 };
|
var { foo } = { bar: 123 };
|
||||||
var { bar, baz } = { bar: 123 };
|
var { bar, baz } = { bar: 123 };
|
||||||
}
|
}
|
||||||
|
|
||||||
function test() {
|
function test() {
|
||||||
var x = { foo: \"abc\", bar: 123 };
|
var x = { foo: \"abc\", bar: 123 };
|
||||||
var { foo, ...rest } = x;
|
var { foo, ...rest } = x;
|
||||||
|
|
||||||
(x.baz: string);
|
(x.baz: string);
|
||||||
|
|
||||||
(rest.baz: string);
|
(rest.baz: string);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = corge;
|
module.exports = corge;
|
||||||
class Base {
|
class Base {
|
||||||
baseprop1: number;
|
baseprop1: number;
|
||||||
|
@ -420,6 +454,7 @@ exports[`test eager.js 1`] = `
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// error, property \`x\` can not be accessed on \`null\`
|
// error, property \`x\` can not be accessed on \`null\`
|
||||||
var x;
|
var x;
|
||||||
|
|
||||||
({ x } = null);
|
({ x } = null);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -471,44 +506,39 @@ function arr_rest_pattern<X>([ _, ...a ] : ArrRest<X>) { // a: [X]
|
||||||
// o: { x: X }
|
// o: { x: X }
|
||||||
// a: [X]
|
// a: [X]
|
||||||
// a: [X]
|
// a: [X]
|
||||||
function obj_pattern<X>({ prop }: { prop: X }) {
|
function obj_pattern<X>({ prop }: { prop: X }) {}
|
||||||
|
|
||||||
}
|
|
||||||
type Prop<X> = { prop: X };
|
type Prop<X> = { prop: X };
|
||||||
function obj_pattern2<X>({ prop }: Prop<X>) {
|
|
||||||
|
|
||||||
}
|
function obj_pattern2<X>({ prop }: Prop<X>) {}
|
||||||
function arr_pattern<X>([ elem ]: X[]) {
|
|
||||||
|
|
||||||
}
|
function arr_pattern<X>([ elem ]: X[]) {}
|
||||||
type Elem<X> = X[];
|
type Elem<X> = X[];
|
||||||
function arr_pattern2<X>([ elem ]: Elem<X>) {
|
|
||||||
|
|
||||||
}
|
function arr_pattern2<X>([ elem ]: Elem<X>) {}
|
||||||
function tup_pattern<X>([ proj ]: [X]) {
|
|
||||||
|
|
||||||
}
|
function tup_pattern<X>([ proj ]: [X]) {}
|
||||||
type Proj<X> = [X];
|
type Proj<X> = [X];
|
||||||
function tup_pattern2<X>([ proj ]: Proj<X>) {
|
|
||||||
|
|
||||||
}
|
function tup_pattern2<X>([ proj ]: Proj<X>) {}
|
||||||
function rest_antipattern<T>(...t: T) {
|
|
||||||
|
|
||||||
}
|
function rest_antipattern<T>(...t: T) {}
|
||||||
function rest_pattern<X>(...r: X[]) {
|
|
||||||
|
function rest_pattern<X>(...r: X[]) {}
|
||||||
|
|
||||||
}
|
|
||||||
function obj_rest_pattern<X>({ _, ...o }: { _: any; x: X }) {
|
function obj_rest_pattern<X>({ _, ...o }: { _: any; x: X }) {
|
||||||
o.x;
|
o.x;
|
||||||
}
|
}
|
||||||
type ObjRest<X> = { _: any; x: X };
|
type ObjRest<X> = { _: any; x: X };
|
||||||
|
|
||||||
function obj_rest_pattern<X>({ _, ...o }: ObjRest<X>) {
|
function obj_rest_pattern<X>({ _, ...o }: ObjRest<X>) {
|
||||||
o.x;
|
o.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function arr_rest_pattern<X>([ _, ...a ]: [any, X]) {
|
function arr_rest_pattern<X>([ _, ...a ]: [any, X]) {
|
||||||
a[0];
|
a[0];
|
||||||
}
|
}
|
||||||
type ArrRest<X> = [any, X];
|
type ArrRest<X> = [any, X];
|
||||||
|
|
||||||
function arr_rest_pattern<X>([ _, ...a ]: ArrRest<X>) {
|
function arr_rest_pattern<X>([ _, ...a ]: ArrRest<X>) {
|
||||||
a[0];
|
a[0];
|
||||||
}
|
}
|
||||||
|
@ -546,6 +576,7 @@ const bar = (i: number) => {
|
||||||
[ i ] = foo(i);
|
[ i ] = foo(i);
|
||||||
return [ i ];
|
return [ i ];
|
||||||
};
|
};
|
||||||
|
|
||||||
foo = (i: number) => {
|
foo = (i: number) => {
|
||||||
return bar(i);
|
return bar(i);
|
||||||
};
|
};
|
||||||
|
@ -564,8 +595,10 @@ var { \"with-dash\": with_dash } = { \"with-dash\": \"motivating example\" };
|
||||||
// error: string ~> void
|
// error: string ~> void
|
||||||
// ok
|
// ok
|
||||||
var { \"key\": val } = { key: \"val\" };
|
var { \"key\": val } = { key: \"val\" };
|
||||||
|
|
||||||
(val: void);
|
(val: void);
|
||||||
var { \"with-dash\": with_dash } = { \"with-dash\": \"motivating example\" };
|
var { \"with-dash\": with_dash } = { \"with-dash\": \"motivating example\" };
|
||||||
|
|
||||||
(with_dash: \"motivating example\");
|
(with_dash: \"motivating example\");
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -583,6 +616,7 @@ function bar() {
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// @flow
|
// @flow
|
||||||
var { x } = { x: { foo: \"foo\" } };
|
var { x } = { x: { foo: \"foo\" } };
|
||||||
|
|
||||||
function bar() {
|
function bar() {
|
||||||
x.bar;
|
x.bar;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ function foo0(x: Array<{ [key: string]: mixed }>): Array<{
|
||||||
x[0].fooBar = \"foobar\";
|
x[0].fooBar = \"foobar\";
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function foo2(x: { [key: string]: number }): {
|
function foo2(x: { [key: string]: number }): {
|
||||||
[key: string]: number;
|
[key: string]: number;
|
||||||
+toString: () => string
|
+toString: () => string
|
||||||
|
@ -503,35 +504,51 @@ class B extends A {}
|
||||||
class C extends B {}
|
class C extends B {}
|
||||||
class X {}
|
class X {}
|
||||||
class Y {}
|
class Y {}
|
||||||
|
|
||||||
function set_prop_to_string_key(o: { [k: string]: any }) {
|
function set_prop_to_string_key(o: { [k: string]: any }) {
|
||||||
o.prop = \"ok\";
|
o.prop = \"ok\";
|
||||||
}
|
}
|
||||||
|
|
||||||
function unsound_dict_has_every_key(o: { [k: string]: X }) {
|
function unsound_dict_has_every_key(o: { [k: string]: X }) {
|
||||||
(o.p: X);
|
(o.p: X);
|
||||||
|
|
||||||
(o[\"p\"]: X);
|
(o[\"p\"]: X);
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_prop_covariant(o: { [k: string]: B }) {
|
function set_prop_covariant(o: { [k: string]: B }) {
|
||||||
o.p = new A();
|
o.p = new A();
|
||||||
|
|
||||||
o.p = new B();
|
o.p = new B();
|
||||||
|
|
||||||
o.p = new C();
|
o.p = new C();
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_prop_contravariant(o: { [k: string]: B }) {
|
function get_prop_contravariant(o: { [k: string]: B }) {
|
||||||
(o.p: A);
|
(o.p: A);
|
||||||
|
|
||||||
(o.p: B);
|
(o.p: B);
|
||||||
|
|
||||||
(o.p: C);
|
(o.p: C);
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_prop_to_nonstring_key_dot(o: { [k: number]: any }) {
|
function add_prop_to_nonstring_key_dot(o: { [k: number]: any }) {
|
||||||
o.prop = \"err\";
|
o.prop = \"err\";
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_prop_to_nonstring_key_bracket(o: { [k: number]: any }) {
|
function add_prop_to_nonstring_key_bracket(o: { [k: number]: any }) {
|
||||||
o[0] = \"ok\";
|
o[0] = \"ok\";
|
||||||
}
|
}
|
||||||
|
|
||||||
function mix_with_declared_props(o: { [k: number]: X; p: Y }, x: X, y: Y) {
|
function mix_with_declared_props(o: { [k: number]: X; p: Y }, x: X, y: Y) {
|
||||||
(o[0]: X);
|
(o[0]: X);
|
||||||
|
|
||||||
(o.p: Y);
|
(o.p: Y);
|
||||||
|
|
||||||
o[0] = x;
|
o[0] = x;
|
||||||
|
|
||||||
o.p = y;
|
o.p = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
function object_prototype(o: { [k: string]: number }): {
|
function object_prototype(o: { [k: string]: number }): {
|
||||||
[k: string]: number;
|
[k: string]: number;
|
||||||
+toString: () => string
|
+toString: () => string
|
||||||
|
@ -539,132 +556,171 @@ function object_prototype(o: { [k: string]: number }): {
|
||||||
(o.toString(): boolean);
|
(o.toString(): boolean);
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
function unsound_string_conversion_alias_declared_prop(
|
function unsound_string_conversion_alias_declared_prop(
|
||||||
o: { [k: number]: any; \"0\": X }
|
o: { [k: number]: any; \"0\": X }
|
||||||
) {
|
) {
|
||||||
o[0] = \"not-x\";
|
o[0] = \"not-x\";
|
||||||
}
|
}
|
||||||
|
|
||||||
function unification_dict_values_invariant(x: Array<{ [k: string]: B }>) {
|
function unification_dict_values_invariant(x: Array<{ [k: string]: B }>) {
|
||||||
let a: Array<{ [k: string]: A }> = x;
|
let a: Array<{ [k: string]: A }> = x;
|
||||||
|
|
||||||
a[0].p = new A();
|
a[0].p = new A();
|
||||||
let b: Array<{ [k: string]: B }> = x;
|
let b: Array<{ [k: string]: B }> = x;
|
||||||
let c: Array<{ [k: string]: C }> = x;
|
let c: Array<{ [k: string]: C }> = x;
|
||||||
|
|
||||||
(x[0].p: C);
|
(x[0].p: C);
|
||||||
}
|
}
|
||||||
|
|
||||||
function subtype_dict_values_invariant(x: { [k: string]: B }) {
|
function subtype_dict_values_invariant(x: { [k: string]: B }) {
|
||||||
let a: { [k: string]: A } = x;
|
let a: { [k: string]: A } = x;
|
||||||
|
|
||||||
a.p = new A();
|
a.p = new A();
|
||||||
let b: { [k: string]: B } = x;
|
let b: { [k: string]: B } = x;
|
||||||
let c: { [k: string]: C } = x;
|
let c: { [k: string]: C } = x;
|
||||||
|
|
||||||
(x.p: C);
|
(x.p: C);
|
||||||
}
|
}
|
||||||
|
|
||||||
function subtype_dict_values_fresh_exception() {
|
function subtype_dict_values_fresh_exception() {
|
||||||
let a: { [k: string]: A } = { a: new A(), b: new B(), c: new C() };
|
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 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() };
|
let c: { [k: string]: C } = { a: new A(), b: new B(), c: new C() };
|
||||||
}
|
}
|
||||||
|
|
||||||
function unification_dict_keys_invariant(x: Array<{ [k: B]: any }>) {
|
function unification_dict_keys_invariant(x: Array<{ [k: B]: any }>) {
|
||||||
let a: Array<{ [k: A]: any }> = x;
|
let a: Array<{ [k: A]: any }> = x;
|
||||||
let b: Array<{ [k: B]: any }> = x;
|
let b: Array<{ [k: B]: any }> = x;
|
||||||
let c: Array<{ [k: C]: any }> = x;
|
let c: Array<{ [k: C]: any }> = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function subtype_dict_keys_invariant(x: { [k: B]: any }) {
|
function subtype_dict_keys_invariant(x: { [k: B]: any }) {
|
||||||
let a: { [k: A]: any } = x;
|
let a: { [k: A]: any } = x;
|
||||||
let b: { [k: B]: any } = x;
|
let b: { [k: B]: any } = x;
|
||||||
let c: { [k: C]: any } = x;
|
let c: { [k: C]: any } = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function unification_mix_with_declared_props_invariant_l(
|
function unification_mix_with_declared_props_invariant_l(
|
||||||
x: Array<{ [k: string]: B }>
|
x: Array<{ [k: string]: B }>
|
||||||
) {
|
) {
|
||||||
let a: Array<{ [k: string]: B; p: A }> = x;
|
let a: Array<{ [k: string]: B; p: A }> = x;
|
||||||
|
|
||||||
a[0].p = new A();
|
a[0].p = new A();
|
||||||
let b: Array<{ [k: string]: B; p: B }> = x;
|
let b: Array<{ [k: string]: B; p: B }> = x;
|
||||||
let c: Array<{ [k: string]: B; p: C }> = x;
|
let c: Array<{ [k: string]: B; p: C }> = x;
|
||||||
|
|
||||||
(x[0].p: C);
|
(x[0].p: C);
|
||||||
}
|
}
|
||||||
|
|
||||||
function unification_mix_with_declared_props_invariant_r(
|
function unification_mix_with_declared_props_invariant_r(
|
||||||
xa: Array<{ [k: string]: A; p: B }>,
|
xa: Array<{ [k: string]: A; p: B }>,
|
||||||
xb: Array<{ [k: string]: B; p: B }>,
|
xb: Array<{ [k: string]: B; p: B }>,
|
||||||
xc: Array<{ [k: string]: C; p: B }>
|
xc: Array<{ [k: string]: C; p: B }>
|
||||||
) {
|
) {
|
||||||
let a: Array<{ [k: string]: A }> = xa;
|
let a: Array<{ [k: string]: A }> = xa;
|
||||||
|
|
||||||
a[0].p = new A();
|
a[0].p = new A();
|
||||||
let b: Array<{ [k: string]: B }> = xb;
|
let b: Array<{ [k: string]: B }> = xb;
|
||||||
let c: Array<{ [k: string]: C }> = xc;
|
let c: Array<{ [k: string]: C }> = xc;
|
||||||
|
|
||||||
(xc[0].p: C);
|
(xc[0].p: C);
|
||||||
}
|
}
|
||||||
|
|
||||||
function subtype_mix_with_declared_props_invariant_l(x: { [k: string]: B }) {
|
function subtype_mix_with_declared_props_invariant_l(x: { [k: string]: B }) {
|
||||||
let a: { [k: string]: B; p: A } = x;
|
let a: { [k: string]: B; p: A } = x;
|
||||||
|
|
||||||
a.p = new A();
|
a.p = new A();
|
||||||
let b: { [k: string]: B; p: B } = x;
|
let b: { [k: string]: B; p: B } = x;
|
||||||
let c: { [k: string]: B; p: C } = x;
|
let c: { [k: string]: B; p: C } = x;
|
||||||
|
|
||||||
(x.p: C);
|
(x.p: C);
|
||||||
}
|
}
|
||||||
|
|
||||||
function subtype_mix_with_declared_props_invariant_r(
|
function subtype_mix_with_declared_props_invariant_r(
|
||||||
xa: { [k: string]: A; p: B },
|
xa: { [k: string]: A; p: B },
|
||||||
xb: { [k: string]: B; p: B },
|
xb: { [k: string]: B; p: B },
|
||||||
xc: { [k: string]: C; p: B }
|
xc: { [k: string]: C; p: B }
|
||||||
) {
|
) {
|
||||||
let a: { [k: string]: A } = xa;
|
let a: { [k: string]: A } = xa;
|
||||||
|
|
||||||
a.p = new A();
|
a.p = new A();
|
||||||
let b: { [k: string]: B } = xb;
|
let b: { [k: string]: B } = xb;
|
||||||
let c: { [k: string]: C } = xc;
|
let c: { [k: string]: C } = xc;
|
||||||
|
|
||||||
(xc.p: C);
|
(xc.p: C);
|
||||||
}
|
}
|
||||||
|
|
||||||
function unification_dict_to_obj(x: Array<{ [k: string]: X }>): Array<{
|
function unification_dict_to_obj(x: Array<{ [k: string]: X }>): Array<{
|
||||||
p: X
|
p: X
|
||||||
}> {
|
}> {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function unification_obj_to_dict(x: Array<{ p: X }>): Array<{
|
function unification_obj_to_dict(x: Array<{ p: X }>): Array<{
|
||||||
[k: string]: X
|
[k: string]: X
|
||||||
}> {
|
}> {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function subtype_dict_to_obj(x: { [k: string]: B }) {
|
function subtype_dict_to_obj(x: { [k: string]: B }) {
|
||||||
let a: { p: A } = x;
|
let a: { p: A } = x;
|
||||||
|
|
||||||
a.p = new A();
|
a.p = new A();
|
||||||
let b: { p: B } = x;
|
let b: { p: B } = x;
|
||||||
let c: { p: C } = x;
|
let c: { p: C } = x;
|
||||||
|
|
||||||
(x.p: C);
|
(x.p: C);
|
||||||
}
|
}
|
||||||
|
|
||||||
function subtype_obj_to_dict(x: { p: B }) {
|
function subtype_obj_to_dict(x: { p: B }) {
|
||||||
let a: { [k: string]: A } = x;
|
let a: { [k: string]: A } = x;
|
||||||
|
|
||||||
a.p = new A();
|
a.p = new A();
|
||||||
let b: { [k: string]: B } = x;
|
let b: { [k: string]: B } = x;
|
||||||
let c: { [k: string]: C } = x;
|
let c: { [k: string]: C } = x;
|
||||||
|
|
||||||
(x.p: C);
|
(x.p: C);
|
||||||
}
|
}
|
||||||
|
|
||||||
function subtype_obj_to_mixed(x: { p: B; x: X }) {
|
function subtype_obj_to_mixed(x: { p: B; x: X }) {
|
||||||
let a: { [k: string]: A; x: X } = x;
|
let a: { [k: string]: A; x: X } = x;
|
||||||
let b: { [k: string]: B; x: X } = x;
|
let b: { [k: string]: B; x: X } = x;
|
||||||
let c: { [k: string]: C; x: X } = x;
|
let c: { [k: string]: C; x: X } = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function unification_dict_to_mixed(x: Array<{ [k: string]: B }>) {
|
function unification_dict_to_mixed(x: Array<{ [k: string]: B }>) {
|
||||||
let a: Array<{ [k: string]: B; p: A }> = x;
|
let a: Array<{ [k: string]: B; p: A }> = x;
|
||||||
let b: Array<{ [k: string]: B; p: B }> = x;
|
let b: Array<{ [k: string]: B; p: B }> = x;
|
||||||
let c: Array<{ [k: string]: B; p: C }> = x;
|
let c: Array<{ [k: string]: B; p: C }> = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function subtype_dict_to_mixed(x: { [k: string]: B }) {
|
function subtype_dict_to_mixed(x: { [k: string]: B }) {
|
||||||
let a: { [k: string]: B; p: A } = x;
|
let a: { [k: string]: B; p: A } = x;
|
||||||
let b: { [k: string]: B; p: B } = x;
|
let b: { [k: string]: B; p: B } = x;
|
||||||
let c: { [k: string]: B; p: C } = x;
|
let c: { [k: string]: B; p: C } = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function subtype_dict_to_optional_a(x: { [k: string]: B }) {
|
function subtype_dict_to_optional_a(x: { [k: string]: B }) {
|
||||||
let a: { p?: A } = x;
|
let a: { p?: A } = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function subtype_dict_to_optional_b(x: { [k: string]: B }) {
|
function subtype_dict_to_optional_b(x: { [k: string]: B }) {
|
||||||
let b: { p?: B } = x;
|
let b: { p?: B } = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function subtype_dict_to_optional_c(x: { [k: string]: B }) {
|
function subtype_dict_to_optional_c(x: { [k: string]: B }) {
|
||||||
let c: { p?: C } = x;
|
let c: { p?: C } = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function subtype_optional_a_to_dict(x: { p?: A }): { [k: string]: B } {
|
function subtype_optional_a_to_dict(x: { p?: A }): { [k: string]: B } {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function subtype_optional_b_to_dict(x: { p?: B }): { [k: string]: B } {
|
function subtype_optional_b_to_dict(x: { p?: B }): { [k: string]: B } {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function subtype_optional_c_to_dict(x: { p?: C }): { [k: string]: B } {
|
function subtype_optional_c_to_dict(x: { p?: C }): { [k: string]: B } {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
@ -750,17 +806,20 @@ var z: { [key: number]: string } = x;
|
||||||
var a: { [key: string]: ?string } = {};
|
var a: { [key: string]: ?string } = {};
|
||||||
var b: { [key: string]: string } = a;
|
var b: { [key: string]: string } = a;
|
||||||
var c: { [key: string]: ?string } = b;
|
var c: { [key: string]: ?string } = b;
|
||||||
|
|
||||||
function foo0(x: Array<{ [key: string]: number }>): Array<{
|
function foo0(x: Array<{ [key: string]: number }>): Array<{
|
||||||
[key: string]: string
|
[key: string]: string
|
||||||
}> {
|
}> {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function foo1(x: Array<{ [key: string]: number }>): Array<{
|
function foo1(x: Array<{ [key: string]: number }>): Array<{
|
||||||
[key: string]: number;
|
[key: string]: number;
|
||||||
fooBar: string
|
fooBar: string
|
||||||
}> {
|
}> {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function foo2(x: Array<{ [key: string]: mixed }>): Array<{
|
function foo2(x: Array<{ [key: string]: mixed }>): Array<{
|
||||||
[key: string]: mixed;
|
[key: string]: mixed;
|
||||||
fooBar: string
|
fooBar: string
|
||||||
|
@ -768,26 +827,33 @@ function foo2(x: Array<{ [key: string]: mixed }>): Array<{
|
||||||
x[0].fooBar = 123;
|
x[0].fooBar = 123;
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function foo3(x: { [key: string]: number }): { foo: number } {
|
function foo3(x: { [key: string]: number }): { foo: number } {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function foo4(x: { [key: string]: number }): {
|
function foo4(x: { [key: string]: number }): {
|
||||||
[key: string]: number;
|
[key: string]: number;
|
||||||
foo: string
|
foo: string
|
||||||
} {
|
} {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function foo5(x: Array<{ [key: string]: number }>): Array<{ foo: number }> {
|
function foo5(x: Array<{ [key: string]: number }>): Array<{ foo: number }> {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function foo6(x: Array<{ foo: number }>): Array<{ [key: string]: number }> {
|
function foo6(x: Array<{ foo: number }>): Array<{ [key: string]: number }> {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function foo7(x: { [key: string]: number; bar: string }) {
|
function foo7(x: { [key: string]: number; bar: string }) {
|
||||||
(x.bar: string);
|
(x.bar: string);
|
||||||
}
|
}
|
||||||
|
|
||||||
function foo8(x: { [key: string]: number }) {
|
function foo8(x: { [key: string]: number }) {
|
||||||
(x.foo: string);
|
(x.foo: string);
|
||||||
|
|
||||||
(x.foo: number);
|
(x.foo: number);
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
@ -866,6 +932,7 @@ var o: { foo: QueryFunction } = {
|
||||||
return params.count;
|
return params.count;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = o;
|
module.exports = o;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -879,6 +946,7 @@ o.foo = function (params) {
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// error, number ~/~ string
|
// error, number ~/~ string
|
||||||
var o = require(\"./test\");
|
var o = require(\"./test\");
|
||||||
|
|
||||||
o.foo = function(params) {
|
o.foo = function(params) {
|
||||||
return params.count;
|
return params.count;
|
||||||
};
|
};
|
||||||
|
|
|
@ -213,6 +213,7 @@ export function emitExpression(node: TypedNode) : t.Expression {
|
||||||
import * as t from \"./jsAst\";
|
import * as t from \"./jsAst\";
|
||||||
const b = t.builders;
|
const b = t.builders;
|
||||||
import type { TypedNode } from \"./ast\";
|
import type { TypedNode } from \"./ast\";
|
||||||
|
|
||||||
function getBinaryOp(
|
function getBinaryOp(
|
||||||
op: \"plus\" | \"minus\" | \"divide\" | \"multiply\"
|
op: \"plus\" | \"minus\" | \"divide\" | \"multiply\"
|
||||||
): \"+\" | \"-\" | \"*\" | \"/\" {
|
): \"+\" | \"-\" | \"*\" | \"/\" {
|
||||||
|
|
|
@ -102,6 +102,7 @@ exports[`test use_strict_with_flow.js 1`] = `
|
||||||
/* @flow */
|
/* @flow */
|
||||||
// error
|
// error
|
||||||
\"use strict\";
|
\"use strict\";
|
||||||
|
|
||||||
(\"\": void);
|
(\"\": void);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -44,6 +44,7 @@ let tests = [
|
||||||
let tests = [
|
let tests = [
|
||||||
function(document: Document) {
|
function(document: Document) {
|
||||||
const event = document.createEvent(\"CustomEvent\");
|
const event = document.createEvent(\"CustomEvent\");
|
||||||
|
|
||||||
event.initCustomEvent(\"butts\", true, false, { nice: 42 });
|
event.initCustomEvent(\"butts\", true, false, { nice: 42 });
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -68,8 +69,11 @@ let tests = [
|
||||||
let tests = [
|
let tests = [
|
||||||
function(document: Document) {
|
function(document: Document) {
|
||||||
(document.createElement(\"canvas\"): HTMLCanvasElement);
|
(document.createElement(\"canvas\"): HTMLCanvasElement);
|
||||||
|
|
||||||
(document.createElement(\"link\"): HTMLLinkElement);
|
(document.createElement(\"link\"): HTMLLinkElement);
|
||||||
|
|
||||||
(document.createElement(\"option\"): HTMLOptionElement);
|
(document.createElement(\"option\"): HTMLOptionElement);
|
||||||
|
|
||||||
(document.createElement(\"select\"): HTMLSelectElement);
|
(document.createElement(\"select\"): HTMLSelectElement);
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -102,13 +106,21 @@ let tests = [
|
||||||
let tests = [
|
let tests = [
|
||||||
function(element: Element) {
|
function(element: Element) {
|
||||||
element.scrollIntoView();
|
element.scrollIntoView();
|
||||||
|
|
||||||
element.scrollIntoView(false);
|
element.scrollIntoView(false);
|
||||||
|
|
||||||
element.scrollIntoView({});
|
element.scrollIntoView({});
|
||||||
|
|
||||||
element.scrollIntoView({ behavior: \"smooth\", block: \"end\" });
|
element.scrollIntoView({ behavior: \"smooth\", block: \"end\" });
|
||||||
|
|
||||||
element.scrollIntoView({ block: \"end\" });
|
element.scrollIntoView({ block: \"end\" });
|
||||||
|
|
||||||
element.scrollIntoView({ behavior: \"smooth\" });
|
element.scrollIntoView({ behavior: \"smooth\" });
|
||||||
|
|
||||||
element.scrollIntoView({ behavior: \"invalid\" });
|
element.scrollIntoView({ behavior: \"invalid\" });
|
||||||
|
|
||||||
element.scrollIntoView({ block: \"invalid\" });
|
element.scrollIntoView({ block: \"invalid\" });
|
||||||
|
|
||||||
element.scrollIntoView(1);
|
element.scrollIntoView(1);
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -161,13 +173,21 @@ let tests = [
|
||||||
let tests = [
|
let tests = [
|
||||||
function(element: HTMLElement) {
|
function(element: HTMLElement) {
|
||||||
element.scrollIntoView();
|
element.scrollIntoView();
|
||||||
|
|
||||||
element.scrollIntoView(false);
|
element.scrollIntoView(false);
|
||||||
|
|
||||||
element.scrollIntoView({});
|
element.scrollIntoView({});
|
||||||
|
|
||||||
element.scrollIntoView({ behavior: \"smooth\", block: \"end\" });
|
element.scrollIntoView({ behavior: \"smooth\", block: \"end\" });
|
||||||
|
|
||||||
element.scrollIntoView({ block: \"end\" });
|
element.scrollIntoView({ block: \"end\" });
|
||||||
|
|
||||||
element.scrollIntoView({ behavior: \"smooth\" });
|
element.scrollIntoView({ behavior: \"smooth\" });
|
||||||
|
|
||||||
element.scrollIntoView({ behavior: \"invalid\" });
|
element.scrollIntoView({ behavior: \"invalid\" });
|
||||||
|
|
||||||
element.scrollIntoView({ block: \"invalid\" });
|
element.scrollIntoView({ block: \"invalid\" });
|
||||||
|
|
||||||
element.scrollIntoView(1);
|
element.scrollIntoView(1);
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -195,9 +215,13 @@ let tests = [
|
||||||
let tests = [
|
let tests = [
|
||||||
function(el: HTMLInputElement) {
|
function(el: HTMLInputElement) {
|
||||||
el.setRangeText(\"foo\");
|
el.setRangeText(\"foo\");
|
||||||
|
|
||||||
el.setRangeText(\"foo\", 123);
|
el.setRangeText(\"foo\", 123);
|
||||||
|
|
||||||
el.setRangeText(\"foo\", 123, 234);
|
el.setRangeText(\"foo\", 123, 234);
|
||||||
|
|
||||||
el.setRangeText(\"foo\", 123, 234, \"select\");
|
el.setRangeText(\"foo\", 123, 234, \"select\");
|
||||||
|
|
||||||
el.setRangeText(\"foo\", 123, 234, \"bogus\");
|
el.setRangeText(\"foo\", 123, 234, \"bogus\");
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -298,18 +322,20 @@ let tests = [
|
||||||
// detachEvent
|
// detachEvent
|
||||||
// invalid, may be undefined
|
// invalid, may be undefined
|
||||||
// valid
|
// valid
|
||||||
let listener: EventListener = function(event: Event): void {
|
let listener: EventListener = function(event: Event): void {};
|
||||||
|
|
||||||
};
|
|
||||||
let tests = [
|
let tests = [
|
||||||
function() {
|
function() {
|
||||||
let target = new EventTarget();
|
let target = new EventTarget();
|
||||||
|
|
||||||
(target.attachEvent(\"foo\", listener): void);
|
(target.attachEvent(\"foo\", listener): void);
|
||||||
|
|
||||||
(target.attachEvent && target.attachEvent(\"foo\", listener): void);
|
(target.attachEvent && target.attachEvent(\"foo\", listener): void);
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
let target = new EventTarget();
|
let target = new EventTarget();
|
||||||
|
|
||||||
(target.detachEvent(\"foo\", listener): void);
|
(target.detachEvent(\"foo\", listener): void);
|
||||||
|
|
||||||
(target.detachEvent && target.detachEvent(\"foo\", listener): void);
|
(target.detachEvent && target.detachEvent(\"foo\", listener): void);
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
|
@ -342,8 +368,11 @@ let tests = [
|
||||||
let tests = [
|
let tests = [
|
||||||
function() {
|
function() {
|
||||||
let path = new Path2D();
|
let path = new Path2D();
|
||||||
|
|
||||||
(path.arcTo(0, 0, 0, 0, 10): void);
|
(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);
|
||||||
|
|
||||||
(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(
|
prototype: Object.create(
|
||||||
HTMLElement.prototype,
|
HTMLElement.prototype,
|
||||||
{
|
{
|
||||||
createdCallback: {
|
createdCallback: { value: function createdCallback() {} },
|
||||||
value: function createdCallback() {
|
attachedCallback: { value: function attachedCallback() {} },
|
||||||
|
detachedCallback: { value: function detachedCallback() {} },
|
||||||
}
|
|
||||||
},
|
|
||||||
attachedCallback: {
|
|
||||||
value: function attachedCallback() {
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
|
||||||
detachedCallback: {
|
|
||||||
value: function detachedCallback() {
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
|
||||||
attributeChangedCallback: {
|
attributeChangedCallback: {
|
||||||
value: function attributeChangedCallback(
|
value: function attributeChangedCallback(
|
||||||
attributeLocalName,
|
attributeLocalName,
|
||||||
oldAttributeValue,
|
oldAttributeValue,
|
||||||
newAttributeValue,
|
newAttributeValue,
|
||||||
attributeNamespace
|
attributeNamespace
|
||||||
) {
|
) {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -461,21 +476,13 @@ let tests = [
|
||||||
prototype: Object.assign(
|
prototype: Object.assign(
|
||||||
Object.create(HTMLElement.prototype),
|
Object.create(HTMLElement.prototype),
|
||||||
{
|
{
|
||||||
createdCallback() {
|
createdCallback() {},
|
||||||
|
attachedCallback() {},
|
||||||
},
|
detachedCallback() {},
|
||||||
attachedCallback() {
|
|
||||||
|
|
||||||
},
|
|
||||||
detachedCallback() {
|
|
||||||
|
|
||||||
},
|
|
||||||
attributeChangedCallback(attributeLocalName,
|
attributeChangedCallback(attributeLocalName,
|
||||||
oldAttributeValue,
|
oldAttributeValue,
|
||||||
newAttributeValue,
|
newAttributeValue,
|
||||||
attributeNamespace) {
|
attributeNamespace) {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -489,9 +496,7 @@ let tests = [
|
||||||
attributeChangedCallback(localName: string,
|
attributeChangedCallback(localName: string,
|
||||||
oldVal: string,
|
oldVal: string,
|
||||||
newVal: string,
|
newVal: string,
|
||||||
namespace: string) {
|
namespace: string) {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -732,10 +737,12 @@ let tests = [
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
document.createNodeIterator(document.body);
|
document.createNodeIterator(document.body);
|
||||||
|
|
||||||
document.createNodeIterator({});
|
document.createNodeIterator({});
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
document.createTreeWalker(document.body);
|
document.createTreeWalker(document.body);
|
||||||
|
|
||||||
document.createTreeWalker({});
|
document.createTreeWalker({});
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
|
@ -897,17 +904,21 @@ let tests = [
|
||||||
-1,
|
-1,
|
||||||
node => NodeFilter.FILTER_ACCEPT
|
node => NodeFilter.FILTER_ACCEPT
|
||||||
);
|
);
|
||||||
|
|
||||||
document.createNodeIterator(document.body, -1, node => \"accept\");
|
document.createNodeIterator(document.body, -1, node => \"accept\");
|
||||||
|
|
||||||
document.createNodeIterator(
|
document.createNodeIterator(
|
||||||
document.body,
|
document.body,
|
||||||
-1,
|
-1,
|
||||||
{ accept: node => NodeFilter.FILTER_ACCEPT }
|
{ accept: node => NodeFilter.FILTER_ACCEPT }
|
||||||
);
|
);
|
||||||
|
|
||||||
document.createNodeIterator(
|
document.createNodeIterator(
|
||||||
document.body,
|
document.body,
|
||||||
-1,
|
-1,
|
||||||
{ accept: node => \"accept\" }
|
{ accept: node => \"accept\" }
|
||||||
);
|
);
|
||||||
|
|
||||||
document.createNodeIterator(document.body, -1, {});
|
document.createNodeIterator(document.body, -1, {});
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
|
@ -916,13 +927,17 @@ let tests = [
|
||||||
-1,
|
-1,
|
||||||
node => NodeFilter.FILTER_ACCEPT
|
node => NodeFilter.FILTER_ACCEPT
|
||||||
);
|
);
|
||||||
|
|
||||||
document.createTreeWalker(document.body, -1, node => \"accept\");
|
document.createTreeWalker(document.body, -1, node => \"accept\");
|
||||||
|
|
||||||
document.createTreeWalker(
|
document.createTreeWalker(
|
||||||
document.body,
|
document.body,
|
||||||
-1,
|
-1,
|
||||||
{ accept: node => NodeFilter.FILTER_ACCEPT }
|
{ accept: node => NodeFilter.FILTER_ACCEPT }
|
||||||
);
|
);
|
||||||
|
|
||||||
document.createTreeWalker(document.body, -1, { accept: node => \"accept\" });
|
document.createTreeWalker(document.body, -1, { accept: node => \"accept\" });
|
||||||
|
|
||||||
document.createTreeWalker(document.body, -1, {});
|
document.createTreeWalker(document.body, -1, {});
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
|
@ -7,10 +7,11 @@ module.exports = num;
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// @flow
|
// @flow
|
||||||
var num = 42;
|
var num = 42;
|
||||||
function bar() {
|
|
||||||
|
|
||||||
}
|
function bar() {}
|
||||||
|
|
||||||
bar();
|
bar();
|
||||||
|
|
||||||
module.exports = num;
|
module.exports = num;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -41,24 +42,29 @@ const idxResult = idx(obj, obj => obj.a.b.c.d);
|
||||||
// @flow
|
// @flow
|
||||||
// test deduping of inferred types
|
// test deduping of inferred types
|
||||||
var num = require(\"./import\");
|
var num = require(\"./import\");
|
||||||
function foo(x) {
|
|
||||||
|
|
||||||
}
|
function foo(x) {}
|
||||||
|
|
||||||
foo(0);
|
foo(0);
|
||||||
var a: string = num;
|
var a: string = num;
|
||||||
|
|
||||||
function unannotated(x) {
|
function unannotated(x) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
const nullToUndefined = val => (val === null ? undefined : val);
|
const nullToUndefined = val => (val === null ? undefined : val);
|
||||||
|
|
||||||
function f0(x: ?Object) {
|
function f0(x: ?Object) {
|
||||||
return nullToUndefined(x);
|
return nullToUndefined(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
function f1(x: ?Object) {
|
function f1(x: ?Object) {
|
||||||
return nullToUndefined(x);
|
return nullToUndefined(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
function f2(x: ?string) {
|
function f2(x: ?string) {
|
||||||
return nullToUndefined(x);
|
return nullToUndefined(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
function f3(x: ?string) {
|
function f3(x: ?string) {
|
||||||
return nullToUndefined(x);
|
return nullToUndefined(x);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,52 +36,41 @@ class C5 {
|
||||||
new C5().m = new C5().m - 42;
|
new C5().m = new C5().m - 42;
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
class C1 {
|
class C1 {
|
||||||
m() {
|
m() {}
|
||||||
|
m() {}
|
||||||
}
|
|
||||||
m() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
new C1().m();
|
new C1().m();
|
||||||
class C2 {
|
class C2 {
|
||||||
get m() {
|
get m() {
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
m() {
|
m() {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
new C2().m();
|
new C2().m();
|
||||||
class C3 {
|
class C3 {
|
||||||
set m(x) {
|
set m(x) {}
|
||||||
|
m() {}
|
||||||
}
|
|
||||||
m() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
new C3().m();
|
new C3().m();
|
||||||
class C4 {
|
class C4 {
|
||||||
get m() {
|
get m() {
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
set m(x: number) {
|
set m(x: number) {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
new C4().m = new C4().m - 42;
|
new C4().m = new C4().m - 42;
|
||||||
class C5 {
|
class C5 {
|
||||||
m() {
|
m() {}
|
||||||
|
|
||||||
}
|
|
||||||
get m() {
|
get m() {
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
set m(x: number) {
|
set m(x: number) {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
new C5().m = new C5().m - 42;
|
new C5().m = new C5().m - 42;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -23,15 +23,18 @@ var s3 = tag2 \`la la la\`;
|
||||||
class A {}
|
class A {}
|
||||||
var a = new A();
|
var a = new A();
|
||||||
var s1 = \`l\${a.x}r\`;
|
var s1 = \`l\${a.x}r\`;
|
||||||
|
|
||||||
function tag(strings, ...values) {
|
function tag(strings, ...values) {
|
||||||
var x: number = strings[0];
|
var x: number = strings[0];
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
var s2 = tag\`l\${42}r\`;
|
var s2 = tag\`l\${42}r\`;
|
||||||
|
|
||||||
function tag2(strings, ...values) {
|
function tag2(strings, ...values) {
|
||||||
return { foo: \"\" };
|
return { foo: \"\" };
|
||||||
}
|
}
|
||||||
var s3 = tag2\`la la la\`;
|
var s3 = tag2\`la la la\`;
|
||||||
|
|
||||||
(s3.foo: number);
|
(s3.foo: number);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -34,17 +34,22 @@ function isActive(
|
||||||
): boolean {
|
): boolean {
|
||||||
return ad.state === \"ACTIVE\";
|
return ad.state === \"ACTIVE\";
|
||||||
}
|
}
|
||||||
|
|
||||||
isActive({ state: \"PAUSE\" });
|
isActive({ state: \"PAUSE\" });
|
||||||
var MyStates = { PAUSED: \"PAUSED\", ACTIVE: \"ACTIVE\", DELETED: \"DELETED\" };
|
var MyStates = { PAUSED: \"PAUSED\", ACTIVE: \"ACTIVE\", DELETED: \"DELETED\" };
|
||||||
|
|
||||||
function isActive2(ad: { state: $Keys<typeof MyStates> }): boolean {
|
function isActive2(ad: { state: $Keys<typeof MyStates> }): boolean {
|
||||||
return ad.state === MyStates.ACTIVE;
|
return ad.state === MyStates.ACTIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
isActive2({ state: \"PAUSE\" });
|
isActive2({ state: \"PAUSE\" });
|
||||||
type Keys = $Keys<{ x: any; y: any }>;
|
type Keys = $Keys<{ x: any; y: any }>;
|
||||||
type Union = \"x\" | \"y\";
|
type Union = \"x\" | \"y\";
|
||||||
|
|
||||||
function keys2union(s: Keys): Union {
|
function keys2union(s: Keys): Union {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
function union2keys(s: Union): Keys {
|
function union2keys(s: Union): Keys {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,13 +16,20 @@ var x = (null : ?number);
|
||||||
// error
|
// error
|
||||||
// error
|
// error
|
||||||
1 == 1;
|
1 == 1;
|
||||||
|
|
||||||
\"foo\" == \"bar\";
|
\"foo\" == \"bar\";
|
||||||
|
|
||||||
1 == null;
|
1 == null;
|
||||||
|
|
||||||
null == 1;
|
null == 1;
|
||||||
|
|
||||||
1 == \"\";
|
1 == \"\";
|
||||||
|
|
||||||
\"\" == 1;
|
\"\" == 1;
|
||||||
var x = (null: ?number);
|
var x = (null: ?number);
|
||||||
|
|
||||||
x == 1;
|
x == 1;
|
||||||
|
|
||||||
1 == x;
|
1 == x;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
exports[`test errors.js 1`] = `
|
exports[`test errors.js 1`] = `
|
||||||
"if (typeof define === \'function\' && define.amd) { }
|
"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;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Test;
|
module.exports = Test;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -131,9 +132,13 @@ exports.numberValue5 = 5;
|
||||||
* @flow
|
* @flow
|
||||||
*/
|
*/
|
||||||
exports.numberValue1 = 1;
|
exports.numberValue1 = 1;
|
||||||
|
|
||||||
exports.numberValue2 = 2;
|
exports.numberValue2 = 2;
|
||||||
|
|
||||||
exports.numberValue3 = 3;
|
exports.numberValue3 = 3;
|
||||||
|
|
||||||
exports.numberValue4 = 4;
|
exports.numberValue4 = 4;
|
||||||
|
|
||||||
exports.numberValue5 = 5;
|
exports.numberValue5 = 5;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -239,6 +244,7 @@ export default class Foo {
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new Foo();
|
new Foo();
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -582,9 +588,13 @@ exports.stringValue = \"str\";
|
||||||
* @flow
|
* @flow
|
||||||
*/
|
*/
|
||||||
exports.numberValue1 = 42;
|
exports.numberValue1 = 42;
|
||||||
|
|
||||||
exports.numberValue2 = 42;
|
exports.numberValue2 = 42;
|
||||||
|
|
||||||
exports.numberValue3 = 42;
|
exports.numberValue3 = 42;
|
||||||
|
|
||||||
exports.numberValue4 = 42;
|
exports.numberValue4 = 42;
|
||||||
|
|
||||||
exports.stringValue = \"str\";
|
exports.stringValue = \"str\";
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -1090,23 +1100,28 @@ var d2: string = numVal1;
|
||||||
import CJS_Clobb_Lit from \"CommonJS_Clobbering_Lit\";
|
import CJS_Clobb_Lit from \"CommonJS_Clobbering_Lit\";
|
||||||
var e1: number = CJS_Clobb_Lit.numberValue3;
|
var e1: number = CJS_Clobb_Lit.numberValue3;
|
||||||
var e2: string = CJS_Clobb_Lit.numberValue3;
|
var e2: string = CJS_Clobb_Lit.numberValue3;
|
||||||
|
|
||||||
CJS_Clobb_Lit.doesntExist;
|
CJS_Clobb_Lit.doesntExist;
|
||||||
import * as CJS_Clobb_Lit_NS from \"CommonJS_Clobbering_Lit\";
|
import * as CJS_Clobb_Lit_NS from \"CommonJS_Clobbering_Lit\";
|
||||||
var f1: number = CJS_Clobb_Lit_NS.numberValue4;
|
var f1: number = CJS_Clobb_Lit_NS.numberValue4;
|
||||||
var f2: number = CJS_Clobb_Lit_NS.default.numberValue4;
|
var f2: number = CJS_Clobb_Lit_NS.default.numberValue4;
|
||||||
|
|
||||||
CJS_Clobb_Lit_NS.default.default;
|
CJS_Clobb_Lit_NS.default.default;
|
||||||
var f3: string = CJS_Clobb_Lit_NS.numberValue4;
|
var f3: string = CJS_Clobb_Lit_NS.numberValue4;
|
||||||
var f4: string = CJS_Clobb_Lit_NS.default.numberValue5;
|
var f4: string = CJS_Clobb_Lit_NS.default.numberValue5;
|
||||||
import { doesntExist2 } from \"CommonJS_Clobbering_Class\";
|
import { doesntExist2 } from \"CommonJS_Clobbering_Class\";
|
||||||
import { staticNumber1, baseProp, childProp } from \"CommonJS_Clobbering_Class\";
|
import { staticNumber1, baseProp, childProp } from \"CommonJS_Clobbering_Class\";
|
||||||
import CJS_Clobb_Class from \"CommonJS_Clobbering_Class\";
|
import CJS_Clobb_Class from \"CommonJS_Clobbering_Class\";
|
||||||
|
|
||||||
new CJS_Clobb_Class();
|
new CJS_Clobb_Class();
|
||||||
|
|
||||||
new CJS_Clobb_Class().doesntExist;
|
new CJS_Clobb_Class().doesntExist;
|
||||||
var h1: number = CJS_Clobb_Class.staticNumber2();
|
var h1: number = CJS_Clobb_Class.staticNumber2();
|
||||||
var h2: string = CJS_Clobb_Class.staticNumber2();
|
var h2: string = CJS_Clobb_Class.staticNumber2();
|
||||||
var h3: number = new CJS_Clobb_Class().instNumber1();
|
var h3: number = new CJS_Clobb_Class().instNumber1();
|
||||||
var h4: string = new CJS_Clobb_Class().instNumber1();
|
var h4: string = new CJS_Clobb_Class().instNumber1();
|
||||||
import * as CJS_Clobb_Class_NS from \"CommonJS_Clobbering_Class\";
|
import * as CJS_Clobb_Class_NS from \"CommonJS_Clobbering_Class\";
|
||||||
|
|
||||||
new CJS_Clobb_Class_NS();
|
new CJS_Clobb_Class_NS();
|
||||||
var i1: number = CJS_Clobb_Class_NS.staticNumber3();
|
var i1: number = CJS_Clobb_Class_NS.staticNumber3();
|
||||||
var i2: number = new CJS_Clobb_Class_NS.default().instNumber2();
|
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\";
|
import * as CJS_Named from \"CommonJS_Named\";
|
||||||
var l1: number = CJS_Named.numberValue1;
|
var l1: number = CJS_Named.numberValue1;
|
||||||
var l2: string = CJS_Named.numberValue1;
|
var l2: string = CJS_Named.numberValue1;
|
||||||
|
|
||||||
CJS_Named.doesntExist;
|
CJS_Named.doesntExist;
|
||||||
import * as CJS_Named_NS from \"CommonJS_Named\";
|
import * as CJS_Named_NS from \"CommonJS_Named\";
|
||||||
var m1: number = CJS_Named_NS.numberValue4;
|
var m1: number = CJS_Named_NS.numberValue4;
|
||||||
|
@ -1180,6 +1196,7 @@ var ab2: string = numberValue2_renamed;
|
||||||
import { numberValue1 as numberValue5 } from \"ES6_ExportAllFrom_Intermediary1\";
|
import { numberValue1 as numberValue5 } from \"ES6_ExportAllFrom_Intermediary1\";
|
||||||
var ac1: number = numberValue5;
|
var ac1: number = numberValue5;
|
||||||
var ac2: string = numberValue5;
|
var ac2: string = numberValue5;
|
||||||
|
|
||||||
require(\"ES6_Default_AnonFunction2\").doesntExist;
|
require(\"ES6_Default_AnonFunction2\").doesntExist;
|
||||||
var ES6_Def_AnonFunc2 = require(\"ES6_Default_AnonFunction2\").default;
|
var ES6_Def_AnonFunc2 = require(\"ES6_Default_AnonFunction2\").default;
|
||||||
var ad1: number = ES6_Def_AnonFunc2();
|
var ad1: number = ES6_Def_AnonFunc2();
|
||||||
|
@ -1333,27 +1350,40 @@ function testRequires() {
|
||||||
// CommonJS module that clobbers module.exports with a frozen object
|
// CommonJS module that clobbers module.exports with a frozen object
|
||||||
// Error: frozen
|
// Error: frozen
|
||||||
import * as DefaultA from \"A\";
|
import * as DefaultA from \"A\";
|
||||||
|
|
||||||
DefaultA.numberValue1 = 123;
|
DefaultA.numberValue1 = 123;
|
||||||
import * as ES6_Named1 from \"ES6_Named1\";
|
import * as ES6_Named1 from \"ES6_Named1\";
|
||||||
|
|
||||||
ES6_Named1.varDeclNumber1 = 123;
|
ES6_Named1.varDeclNumber1 = 123;
|
||||||
import * as CommonJS_Star from \"CommonJS_Clobbering_Lit\";
|
import * as CommonJS_Star from \"CommonJS_Clobbering_Lit\";
|
||||||
|
|
||||||
CommonJS_Star.numberValue1 = 123;
|
CommonJS_Star.numberValue1 = 123;
|
||||||
|
|
||||||
CommonJS_Star.default.numberValue1 = 123;
|
CommonJS_Star.default.numberValue1 = 123;
|
||||||
import CommonJS_Clobbering_Lit from \"CommonJS_Clobbering_Lit\";
|
import CommonJS_Clobbering_Lit from \"CommonJS_Clobbering_Lit\";
|
||||||
|
|
||||||
CommonJS_Clobbering_Lit.numberValue1 = 123;
|
CommonJS_Clobbering_Lit.numberValue1 = 123;
|
||||||
import * as CommonJS_Frozen_Star from \"CommonJS_Clobbering_Frozen\";
|
import * as CommonJS_Frozen_Star from \"CommonJS_Clobbering_Frozen\";
|
||||||
|
|
||||||
CommonJS_Frozen_Star.numberValue1 = 123;
|
CommonJS_Frozen_Star.numberValue1 = 123;
|
||||||
|
|
||||||
CommonJS_Frozen_Star.default.numberValue1 = 123;
|
CommonJS_Frozen_Star.default.numberValue1 = 123;
|
||||||
import CommonJS_Clobbering_Frozen from \"CommonJS_Clobbering_Frozen\";
|
import CommonJS_Clobbering_Frozen from \"CommonJS_Clobbering_Frozen\";
|
||||||
|
|
||||||
CommonJS_Clobbering_Frozen.numberValue1 = 123;
|
CommonJS_Clobbering_Frozen.numberValue1 = 123;
|
||||||
|
|
||||||
function testRequires() {
|
function testRequires() {
|
||||||
var DefaultA = require(\"A\");
|
var DefaultA = require(\"A\");
|
||||||
|
|
||||||
DefaultA.numberValue1 = 123;
|
DefaultA.numberValue1 = 123;
|
||||||
var ES6_Named1 = require(\"ES6_Named1\");
|
var ES6_Named1 = require(\"ES6_Named1\");
|
||||||
|
|
||||||
ES6_Named1.numberValue = 123;
|
ES6_Named1.numberValue = 123;
|
||||||
var CommonJS_Star = require(\"CommonJS_Clobbering_Lit\");
|
var CommonJS_Star = require(\"CommonJS_Clobbering_Lit\");
|
||||||
|
|
||||||
CommonJS_Star.numberValue1 = 123;
|
CommonJS_Star.numberValue1 = 123;
|
||||||
var CommonJS_Frozen_Star = require(\"CommonJS_Clobbering_Frozen\");
|
var CommonJS_Frozen_Star = require(\"CommonJS_Clobbering_Frozen\");
|
||||||
|
|
||||||
CommonJS_Frozen_Star.numberValue1 = 123;
|
CommonJS_Frozen_Star.numberValue1 = 123;
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
|
|
@ -58,35 +58,55 @@ import {exports as nope} from \"ES\"; // Error: Not an export
|
||||||
// Error: Not an export
|
// Error: Not an export
|
||||||
import { num1, str1 } from \"CJS_Named\";
|
import { num1, str1 } from \"CJS_Named\";
|
||||||
import CJS_Named from \"CJS_Named\";
|
import CJS_Named from \"CJS_Named\";
|
||||||
|
|
||||||
(num1: number);
|
(num1: number);
|
||||||
|
|
||||||
(num1: string);
|
(num1: string);
|
||||||
|
|
||||||
(str1: string);
|
(str1: string);
|
||||||
|
|
||||||
(str1: number);
|
(str1: number);
|
||||||
|
|
||||||
(CJS_Named: { num1: number; str1: string });
|
(CJS_Named: { num1: number; str1: string });
|
||||||
|
|
||||||
(CJS_Named: number);
|
(CJS_Named: number);
|
||||||
import { num2 } from \"CJS_Clobbered\";
|
import { num2 } from \"CJS_Clobbered\";
|
||||||
import { numExport } from \"CJS_Clobbered\";
|
import { numExport } from \"CJS_Clobbered\";
|
||||||
|
|
||||||
(numExport: number);
|
(numExport: number);
|
||||||
|
|
||||||
(numExport: string);
|
(numExport: string);
|
||||||
import type { numType } from \"CJS_Clobbered\";
|
import type { numType } from \"CJS_Clobbered\";
|
||||||
|
|
||||||
(42: numType);
|
(42: numType);
|
||||||
|
|
||||||
(\"asdf\": numType);
|
(\"asdf\": numType);
|
||||||
import { strHidden } from \"ES\";
|
import { strHidden } from \"ES\";
|
||||||
import { str3 } from \"ES\";
|
import { str3 } from \"ES\";
|
||||||
|
|
||||||
(str3: string);
|
(str3: string);
|
||||||
|
|
||||||
(str3: number);
|
(str3: number);
|
||||||
import { num3 } from \"ES\";
|
import { num3 } from \"ES\";
|
||||||
|
|
||||||
(num3: number);
|
(num3: number);
|
||||||
|
|
||||||
(num3: string);
|
(num3: string);
|
||||||
import { C } from \"ES\";
|
import { C } from \"ES\";
|
||||||
import type { C as CType } from \"ES\";
|
import type { C as CType } from \"ES\";
|
||||||
|
|
||||||
(new C(): C);
|
(new C(): C);
|
||||||
|
|
||||||
(42: C);
|
(42: C);
|
||||||
|
|
||||||
(new C(): CType);
|
(new C(): CType);
|
||||||
|
|
||||||
(42: CType);
|
(42: CType);
|
||||||
import { T } from \"ES\";
|
import { T } from \"ES\";
|
||||||
import type { T as T2 } from \"ES\";
|
import type { T as T2 } from \"ES\";
|
||||||
|
|
||||||
(42: T2);
|
(42: T2);
|
||||||
|
|
||||||
(\"asdf\": T2);
|
(\"asdf\": T2);
|
||||||
import { exports as nope } from \"ES\";
|
import { exports as nope } from \"ES\";
|
||||||
"
|
"
|
||||||
|
|
|
@ -18,10 +18,13 @@ N.z = Q(N.z);
|
||||||
// declaration of Q redirects to module M
|
// declaration of Q redirects to module M
|
||||||
var M = require(\"M\");
|
var M = require(\"M\");
|
||||||
var N = require(\"N\");
|
var N = require(\"N\");
|
||||||
|
|
||||||
N.x = M(N.x);
|
N.x = M(N.x);
|
||||||
var P = require(\"./P\");
|
var P = require(\"./P\");
|
||||||
|
|
||||||
N.y = P(N.y);
|
N.y = P(N.y);
|
||||||
var Q = require(\"Q\");
|
var Q = require(\"Q\");
|
||||||
|
|
||||||
N.z = Q(N.z);
|
N.z = Q(N.z);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -9,6 +9,7 @@ module.exports = {}
|
||||||
/* @flow */
|
/* @flow */
|
||||||
export type talias4 = number;
|
export type talias4 = number;
|
||||||
export interface IFoo { prop: number }
|
export interface IFoo { prop: number }
|
||||||
|
|
||||||
module.exports = {};
|
module.exports = {};
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -3,6 +3,7 @@ exports[`test foo.js 1`] = `
|
||||||
imp(1337);
|
imp(1337);
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
var imp = require(\"./bar\");
|
var imp = require(\"./bar\");
|
||||||
|
|
||||||
imp(1337);
|
imp(1337);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -7,7 +7,9 @@ var React = require(\'react\');
|
||||||
// @flow
|
// @flow
|
||||||
// Error: ReactElement ~> number
|
// Error: ReactElement ~> number
|
||||||
var React = require(\"react\");
|
var React = require(\"react\");
|
||||||
|
|
||||||
(<fbt/>: React.Element<*>);
|
(<fbt/>: React.Element<*>);
|
||||||
|
|
||||||
(<fbt/>: number);
|
(<fbt/>: number);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -7,6 +7,7 @@ exports[`test main.js 1`] = `
|
||||||
// @flow
|
// @flow
|
||||||
// Error (the libdef in this test marks fbt as number)
|
// Error (the libdef in this test marks fbt as number)
|
||||||
(<fbt/>: number);
|
(<fbt/>: number);
|
||||||
|
|
||||||
(<fbt/>: string);
|
(<fbt/>: string);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -3,6 +3,7 @@ exports[`test Bar.js 1`] = `
|
||||||
module.exports = Bar;
|
module.exports = Bar;
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
var Bar = { x: 0 };
|
var Bar = { x: 0 };
|
||||||
|
|
||||||
module.exports = Bar;
|
module.exports = Bar;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -62,7 +63,9 @@ let tests = [
|
||||||
},
|
},
|
||||||
function(copyProperties: Object$Assign) {
|
function(copyProperties: Object$Assign) {
|
||||||
let result = {};
|
let result = {};
|
||||||
|
|
||||||
result.baz = false;
|
result.baz = false;
|
||||||
|
|
||||||
(copyProperties(result, { foo: \"a\" }, { bar: 123 }): {
|
(copyProperties(result, { foo: \"a\" }, { bar: 123 }): {
|
||||||
foo: string;
|
foo: string;
|
||||||
bar: number;
|
bar: number;
|
||||||
|
@ -73,16 +76,17 @@ let tests = [
|
||||||
const copyProperties = require(\"copyProperties\");
|
const copyProperties = require(\"copyProperties\");
|
||||||
let x = { foo: \"a\" };
|
let x = { foo: \"a\" };
|
||||||
let y = { bar: 123 };
|
let y = { bar: 123 };
|
||||||
|
|
||||||
(copyProperties({}, x, y): { foo: string; bar: number });
|
(copyProperties({}, x, y): { foo: string; bar: number });
|
||||||
},
|
},
|
||||||
function(copyProperties: Object$Assign) {
|
function(copyProperties: Object$Assign) {
|
||||||
copyProperties();
|
copyProperties();
|
||||||
|
|
||||||
(copyProperties({ foo: \"a\" }): { foo: number });
|
(copyProperties({ foo: \"a\" }): { foo: number });
|
||||||
},
|
},
|
||||||
function(copyProperties: Object$Assign) {
|
function(copyProperties: Object$Assign) {
|
||||||
function x(cb: Function) {
|
function x(cb: Function) {}
|
||||||
|
|
||||||
}
|
|
||||||
x(copyProperties);
|
x(copyProperties);
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -110,11 +114,14 @@ let tests = [
|
||||||
let tests = [
|
let tests = [
|
||||||
function() {
|
function() {
|
||||||
let x: ?string = null;
|
let x: ?string = null;
|
||||||
|
|
||||||
invariant(x, \"truthy only\");
|
invariant(x, \"truthy only\");
|
||||||
},
|
},
|
||||||
function(invariant: Function) {
|
function(invariant: Function) {
|
||||||
let x: ?string = null;
|
let x: ?string = null;
|
||||||
|
|
||||||
invariant(x);
|
invariant(x);
|
||||||
|
|
||||||
(x: string);
|
(x: string);
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -195,22 +202,25 @@ let tests = [
|
||||||
},
|
},
|
||||||
function(mergeInto: $Facebookism$MergeInto) {
|
function(mergeInto: $Facebookism$MergeInto) {
|
||||||
let result = {};
|
let result = {};
|
||||||
|
|
||||||
result.baz = false;
|
result.baz = false;
|
||||||
|
|
||||||
(mergeInto(result, { foo: \"a\" }, { bar: 123 }): void);
|
(mergeInto(result, { foo: \"a\" }, { bar: 123 }): void);
|
||||||
|
|
||||||
(result: { foo: string; bar: number; baz: boolean });
|
(result: { foo: string; bar: number; baz: boolean });
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
const mergeInto = require(\"mergeInto\");
|
const mergeInto = require(\"mergeInto\");
|
||||||
let result: { foo?: string; bar?: number; baz: boolean } = { baz: false };
|
let result: { foo?: string; bar?: number; baz: boolean } = { baz: false };
|
||||||
|
|
||||||
(mergeInto(result, { foo: \"a\" }, { bar: 123 }): void);
|
(mergeInto(result, { foo: \"a\" }, { bar: 123 }): void);
|
||||||
},
|
},
|
||||||
function(mergeInto: $Facebookism$MergeInto) {
|
function(mergeInto: $Facebookism$MergeInto) {
|
||||||
mergeInto();
|
mergeInto();
|
||||||
},
|
},
|
||||||
function(mergeInto: $Facebookism$MergeInto) {
|
function(mergeInto: $Facebookism$MergeInto) {
|
||||||
function x(cb: Function) {
|
function x(cb: Function) {}
|
||||||
|
|
||||||
}
|
|
||||||
x(mergeInto);
|
x(mergeInto);
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -233,6 +243,7 @@ var mixin = require(\"mixin\");
|
||||||
class Foo extends mixin(Bar) {
|
class Foo extends mixin(Bar) {
|
||||||
m() {
|
m() {
|
||||||
var x: string = this.x;
|
var x: string = this.x;
|
||||||
|
|
||||||
this.y = \"\";
|
this.y = \"\";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,26 +98,31 @@ const b = new Headers([ \"Content-Type\", \"image/jpeg\" ]);
|
||||||
const c = new Headers({ \"Content-Type\", \"image/jpeg\" });
|
const c = new Headers({ \"Content-Type\", \"image/jpeg\" });
|
||||||
const d = new Headers(c);
|
const d = new Headers(c);
|
||||||
const e: Headers = new Headers();
|
const e: Headers = new Headers();
|
||||||
|
|
||||||
e.append(\"Content-Type\", \"image/jpeg\");
|
e.append(\"Content-Type\", \"image/jpeg\");
|
||||||
|
|
||||||
e.append(\"Content-Type\");
|
e.append(\"Content-Type\");
|
||||||
|
|
||||||
e.append({ \"Content-Type\", \"image/jpeg\" });
|
e.append({ \"Content-Type\", \"image/jpeg\" });
|
||||||
|
|
||||||
e.set(\"Content-Type\", \"image/jpeg\");
|
e.set(\"Content-Type\", \"image/jpeg\");
|
||||||
|
|
||||||
e.set(\"Content-Type\");
|
e.set(\"Content-Type\");
|
||||||
|
|
||||||
e.set({ \"Content-Type\", \"image/jpeg\" });
|
e.set({ \"Content-Type\", \"image/jpeg\" });
|
||||||
const f: Headers = e.append(\"Content-Type\", \"image/jpeg\");
|
const f: Headers = e.append(\"Content-Type\", \"image/jpeg\");
|
||||||
const g: string = e.get(\"Content-Type\");
|
const g: string = e.get(\"Content-Type\");
|
||||||
const h: number = e.get(\"Content-Type\");
|
const h: number = e.get(\"Content-Type\");
|
||||||
|
|
||||||
for (let v of e) {
|
for (let v of e) {
|
||||||
const [ i, j ]: [string, string] = v;
|
const [ i, j ]: [string, string] = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let v of e.entries()) {
|
for (let v of e.entries()) {
|
||||||
const [ i, j ]: [string, string] = v;
|
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;
|
var l: boolean = h.bodyUsed;
|
||||||
|
|
||||||
h.text().then((t: string) => t);
|
h.text().then((t: string) => t);
|
||||||
|
|
||||||
h.text().then((t: Buffer) => t);
|
h.text().then((t: Buffer) => t);
|
||||||
|
|
||||||
h.arrayBuffer().then((ab: ArrayBuffer) => ab);
|
h.arrayBuffer().then((ab: ArrayBuffer) => ab);
|
||||||
|
|
||||||
h.arrayBuffer().then((ab: Buffer) => ab);
|
h.arrayBuffer().then((ab: Buffer) => ab);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -327,9 +336,13 @@ const i: Response = new Response({
|
||||||
});
|
});
|
||||||
const ok: boolean = h.ok;
|
const ok: boolean = h.ok;
|
||||||
const status: number = h.status;
|
const status: number = h.status;
|
||||||
|
|
||||||
h.text().then((t: string) => t);
|
h.text().then((t: string) => t);
|
||||||
|
|
||||||
h.text().then((t: Buffer) => t);
|
h.text().then((t: Buffer) => t);
|
||||||
|
|
||||||
h.arrayBuffer().then((ab: ArrayBuffer) => ab);
|
h.arrayBuffer().then((ab: ArrayBuffer) => ab);
|
||||||
|
|
||||||
h.arrayBuffer().then((ab: Buffer) => ab);
|
h.arrayBuffer().then((ab: Buffer) => ab);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -387,25 +400,30 @@ const b = new URLSearchParams([ \"key1\", \"value1\" ]);
|
||||||
const c = new URLSearchParams({ \"key1\", \"value1\" });
|
const c = new URLSearchParams({ \"key1\", \"value1\" });
|
||||||
const d = new URLSearchParams(c);
|
const d = new URLSearchParams(c);
|
||||||
const e: URLSearchParams = new URLSearchParams();
|
const e: URLSearchParams = new URLSearchParams();
|
||||||
|
|
||||||
e.append(\"key1\", \"value1\");
|
e.append(\"key1\", \"value1\");
|
||||||
|
|
||||||
e.append(\"key1\");
|
e.append(\"key1\");
|
||||||
|
|
||||||
e.append({ \"key1\", \"value1\" });
|
e.append({ \"key1\", \"value1\" });
|
||||||
|
|
||||||
e.set(\"key1\", \"value1\");
|
e.set(\"key1\", \"value1\");
|
||||||
|
|
||||||
e.set(\"key1\");
|
e.set(\"key1\");
|
||||||
|
|
||||||
e.set({ \"key1\", \"value1\" });
|
e.set({ \"key1\", \"value1\" });
|
||||||
const f: URLSearchParams = e.append(\"key1\", \"value1\");
|
const f: URLSearchParams = e.append(\"key1\", \"value1\");
|
||||||
const g: string = e.get(\"key1\");
|
const g: string = e.get(\"key1\");
|
||||||
const h: number = e.get(\"key1\");
|
const h: number = e.get(\"key1\");
|
||||||
|
|
||||||
for (let v of e) {
|
for (let v of e) {
|
||||||
const [ i, j ]: [string, string] = v;
|
const [ i, j ]: [string, string] = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let v of e.entries()) {
|
for (let v of e.entries()) {
|
||||||
const [ i, j ]: [string, string] = v;
|
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\';
|
import x from \'./req\';
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
var x = require(\"./req\");
|
var x = require(\"./req\");
|
||||||
|
|
||||||
(x: string);
|
(x: string);
|
||||||
import x from \"./req\";
|
import x from \"./req\";
|
||||||
"
|
"
|
||||||
|
|
|
@ -34,12 +34,15 @@ module.exports = {fn: fix};
|
||||||
function eq(x: number, y: number) {
|
function eq(x: number, y: number) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sub(x: number, y: number) {
|
function sub(x: number, y: number) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function mul(x: number, y: number) {
|
function mul(x: number, y: number) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fix(fold) {
|
function fix(fold) {
|
||||||
var delta = function(delta) {
|
var delta = function(delta) {
|
||||||
return fold(
|
return fold(
|
||||||
|
@ -51,6 +54,7 @@ function fix(fold) {
|
||||||
};
|
};
|
||||||
return delta(delta);
|
return delta(delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
function mk_factorial() {
|
function mk_factorial() {
|
||||||
return fix(
|
return fix(
|
||||||
function(factorial) {
|
function(factorial) {
|
||||||
|
@ -64,7 +68,9 @@ function mk_factorial() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
var factorial = mk_factorial();
|
var factorial = mk_factorial();
|
||||||
|
|
||||||
factorial(\"...\");
|
factorial(\"...\");
|
||||||
|
|
||||||
module.exports = { fn: fix };
|
module.exports = { fn: fix };
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -97,22 +103,28 @@ function Y(f) {
|
||||||
function g(x) {
|
function g(x) {
|
||||||
return f(x(x));
|
return f(x(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
g(g);
|
g(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
function func1(f) {
|
function func1(f) {
|
||||||
function fix_f(x: number): number {
|
function fix_f(x: number): number {
|
||||||
return f(x);
|
return f(x);
|
||||||
}
|
}
|
||||||
return fix_f;
|
return fix_f;
|
||||||
}
|
}
|
||||||
|
|
||||||
function func2(f) {
|
function func2(f) {
|
||||||
function fix_f(x: string): string {
|
function fix_f(x: string): string {
|
||||||
return f(x);
|
return f(x);
|
||||||
}
|
}
|
||||||
return fix_f;
|
return fix_f;
|
||||||
}
|
}
|
||||||
|
|
||||||
Y(func1);
|
Y(func1);
|
||||||
|
|
||||||
Y(func2);
|
Y(func2);
|
||||||
|
|
||||||
module.exports = Y;
|
module.exports = Y;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -50,45 +50,59 @@ function corge(x: boolean) {
|
||||||
/* @flow */
|
/* @flow */
|
||||||
function foo(x: boolean) {
|
function foo(x: boolean) {
|
||||||
var max = 10;
|
var max = 10;
|
||||||
|
|
||||||
for (var ii = 0; ii < max; ii++) {
|
for (var ii = 0; ii < max; ii++) {
|
||||||
if (x) {
|
if (x) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(\"this is still reachable\");
|
console.log(\"this is still reachable\");
|
||||||
}
|
}
|
||||||
|
|
||||||
function bar(x: boolean) {
|
function bar(x: boolean) {
|
||||||
var max = 0;
|
var max = 0;
|
||||||
|
|
||||||
for (var ii = 0; ii < max; ii++) {
|
for (var ii = 0; ii < max; ii++) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(\"this is still reachable\");
|
console.log(\"this is still reachable\");
|
||||||
}
|
}
|
||||||
|
|
||||||
function baz(x: boolean) {
|
function baz(x: boolean) {
|
||||||
var max = 0;
|
var max = 0;
|
||||||
|
|
||||||
for (var ii = 0; ii < max; ii++) {
|
for (var ii = 0; ii < max; ii++) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(\"this is still reachable\");
|
console.log(\"this is still reachable\");
|
||||||
}
|
}
|
||||||
|
|
||||||
function bliffl(x: boolean) {
|
function bliffl(x: boolean) {
|
||||||
var max = 10;
|
var max = 10;
|
||||||
loop1:
|
loop1:
|
||||||
for (var ii = 0; ii < max; ii++) {
|
for (var ii = 0; ii < max; ii++) {
|
||||||
loop2:
|
loop2:
|
||||||
for (var jj = 0; jj < max; jj++) {
|
for (var jj = 0; jj < max; jj++) {
|
||||||
break loop1;
|
break loop1;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(\"this is still reachable\");
|
console.log(\"this is still reachable\");
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(\"this is still reachable\");
|
console.log(\"this is still reachable\");
|
||||||
}
|
}
|
||||||
|
|
||||||
function corge(x: boolean) {
|
function corge(x: boolean) {
|
||||||
var max = 0;
|
var max = 0;
|
||||||
|
|
||||||
for (var ii = 0; ii < max; ii++) {
|
for (var ii = 0; ii < max; ii++) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(\"this is still reachable\");
|
console.log(\"this is still reachable\");
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
@ -140,42 +154,53 @@ function corge(x: boolean) {
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
function foo(x: boolean) {
|
function foo(x: boolean) {
|
||||||
var obj = { a: 1, b: 2 };
|
var obj = { a: 1, b: 2 };
|
||||||
|
|
||||||
for (var prop in obj) {
|
for (var prop in obj) {
|
||||||
if (x) {
|
if (x) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(\"this is still reachable\");
|
console.log(\"this is still reachable\");
|
||||||
}
|
}
|
||||||
|
|
||||||
function bar(x: boolean) {
|
function bar(x: boolean) {
|
||||||
for (var prop in {}) {
|
for (var prop in {}) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(\"this is still reachable\");
|
console.log(\"this is still reachable\");
|
||||||
}
|
}
|
||||||
|
|
||||||
function baz(x: boolean) {
|
function baz(x: boolean) {
|
||||||
for (var prop in {}) {
|
for (var prop in {}) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(\"this is still reachable\");
|
console.log(\"this is still reachable\");
|
||||||
}
|
}
|
||||||
|
|
||||||
function bliffl(x: boolean) {
|
function bliffl(x: boolean) {
|
||||||
var obj = { a: 1, b: 2 };
|
var obj = { a: 1, b: 2 };
|
||||||
loop1:
|
loop1:
|
||||||
for (var prop1 in obj) {
|
for (var prop1 in obj) {
|
||||||
loop2:
|
loop2:
|
||||||
for (var prop2 in obj) {
|
for (var prop2 in obj) {
|
||||||
break loop1;
|
break loop1;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(\"this is still reachable\");
|
console.log(\"this is still reachable\");
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(\"this is still reachable\");
|
console.log(\"this is still reachable\");
|
||||||
}
|
}
|
||||||
|
|
||||||
function corge(x: boolean) {
|
function corge(x: boolean) {
|
||||||
for (var prop in {}) {
|
for (var prop in {}) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(\"this is still reachable\");
|
console.log(\"this is still reachable\");
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
@ -227,42 +252,53 @@ function corge(x: boolean) {
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
function foo(x: boolean) {
|
function foo(x: boolean) {
|
||||||
var arr = [ 1, 2, 3 ];
|
var arr = [ 1, 2, 3 ];
|
||||||
|
|
||||||
for (var elem of arr) {
|
for (var elem of arr) {
|
||||||
if (x) {
|
if (x) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(\"this is still reachable\");
|
console.log(\"this is still reachable\");
|
||||||
}
|
}
|
||||||
|
|
||||||
function bar(x: boolean) {
|
function bar(x: boolean) {
|
||||||
for (var elem of [ ]) {
|
for (var elem of []) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(\"this is still reachable\");
|
console.log(\"this is still reachable\");
|
||||||
}
|
}
|
||||||
|
|
||||||
function baz(x: boolean) {
|
function baz(x: boolean) {
|
||||||
for (var elem of [ ]) {
|
for (var elem of []) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(\"this is still reachable\");
|
console.log(\"this is still reachable\");
|
||||||
}
|
}
|
||||||
|
|
||||||
function bliffl(x: boolean) {
|
function bliffl(x: boolean) {
|
||||||
var arr = [ 1, 2, 3 ];
|
var arr = [ 1, 2, 3 ];
|
||||||
loop1:
|
loop1:
|
||||||
for (var elem of arr) {
|
for (var elem of arr) {
|
||||||
loop2:
|
loop2:
|
||||||
for (var elem of arr) {
|
for (var elem of arr) {
|
||||||
break loop1;
|
break loop1;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(\"this is still reachable\");
|
console.log(\"this is still reachable\");
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(\"this is still reachable\");
|
console.log(\"this is still reachable\");
|
||||||
}
|
}
|
||||||
|
|
||||||
function corge(x: boolean) {
|
function corge(x: boolean) {
|
||||||
for (var elem of [ ]) {
|
for (var elem of []) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(\"this is still reachable\");
|
console.log(\"this is still reachable\");
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
|
|
@ -69,38 +69,47 @@ function testArray(arr: Array<number>): void {
|
||||||
(x: string);
|
(x: string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function testIterable1(iterable: Iterable<number>): void {
|
function testIterable1(iterable: Iterable<number>): void {
|
||||||
for (var x of iterable) {
|
for (var x of iterable) {
|
||||||
(x: string);
|
(x: string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function testIterable2(iterable: Iterable<*>): void {
|
function testIterable2(iterable: Iterable<*>): void {
|
||||||
for (var x of iterable) {
|
for (var x of iterable) {
|
||||||
(x: string);
|
(x: string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function testString(str: string): void {
|
function testString(str: string): void {
|
||||||
for (var x of str) {
|
for (var x of str) {
|
||||||
(x: number);
|
(x: number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function testMap1(map: Map<string, number>): void {
|
function testMap1(map: Map<string, number>): void {
|
||||||
for (var elem of map) {
|
for (var elem of map) {
|
||||||
(elem: [string, number]);
|
(elem: [string, number]);
|
||||||
|
|
||||||
(elem: number);
|
(elem: number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function testMap2(map: Map<*, *>): void {
|
function testMap2(map: Map<*, *>): void {
|
||||||
for (var elem of map) {
|
for (var elem of map) {
|
||||||
(elem: [number, string]);
|
(elem: [number, string]);
|
||||||
|
|
||||||
(elem: number);
|
(elem: number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function testSet1(set: Set<string>): void {
|
function testSet1(set: Set<string>): void {
|
||||||
for (var x of set) {
|
for (var x of set) {
|
||||||
(x: number);
|
(x: number);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function testSet2(set: Set<*>): void {
|
function testSet2(set: Set<*>): void {
|
||||||
for (var x of set) {
|
for (var x of set) {
|
||||||
(x: number);
|
(x: number);
|
||||||
|
|
|
@ -69,24 +69,39 @@ function test2(): number { return 0; }
|
||||||
function test(a: string, b: number): number {
|
function test(a: string, b: number): number {
|
||||||
return this.length;
|
return this.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
test.apply(\"\", [ \"\", 0 ]);
|
test.apply(\"\", [ \"\", 0 ]);
|
||||||
|
|
||||||
test.apply(0, [ \"\", 0 ]);
|
test.apply(0, [ \"\", 0 ]);
|
||||||
|
|
||||||
test.apply(\"\", [ \"\" ]);
|
test.apply(\"\", [ \"\" ]);
|
||||||
|
|
||||||
test.apply(\"\", [ \"\", \"\" ]);
|
test.apply(\"\", [ \"\", \"\" ]);
|
||||||
|
|
||||||
test.apply(\"\", [ 0, 0 ]);
|
test.apply(\"\", [ 0, 0 ]);
|
||||||
|
|
||||||
function f(args) {
|
function f(args) {
|
||||||
test.apply(\"\", args);
|
test.apply(\"\", args);
|
||||||
}
|
}
|
||||||
|
|
||||||
f([ \"\", 0 ]);
|
f([ \"\", 0 ]);
|
||||||
|
|
||||||
f([ \"\", \"\" ]);
|
f([ \"\", \"\" ]);
|
||||||
|
|
||||||
f([ 0, 0 ]);
|
f([ 0, 0 ]);
|
||||||
|
|
||||||
test.apply(\"\", \"not array\");
|
test.apply(\"\", \"not array\");
|
||||||
|
|
||||||
(test.call.apply(test, [ 0, 123, \"foo\" ]): void);
|
(test.call.apply(test, [ 0, 123, \"foo\" ]): void);
|
||||||
|
|
||||||
(test.bind.apply(test, [ 0, 123 ]): (b: number) => number);
|
(test.bind.apply(test, [ 0, 123 ]): (b: number) => number);
|
||||||
|
|
||||||
function test2(): number {
|
function test2(): number {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
(test2.apply(): number);
|
(test2.apply(): number);
|
||||||
|
|
||||||
(test2.apply(\"\"): number);
|
(test2.apply(\"\"): number);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -108,7 +123,9 @@ let tests = [
|
||||||
let tests = [
|
let tests = [
|
||||||
function(x: (a: string, b: string) => void) {
|
function(x: (a: string, b: string) => void) {
|
||||||
let y = x.bind(x, \"foo\");
|
let y = x.bind(x, \"foo\");
|
||||||
|
|
||||||
y(\"bar\");
|
y(\"bar\");
|
||||||
|
|
||||||
y(123);
|
y(123);
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -174,22 +191,35 @@ function test2(): number { return 0; }
|
||||||
function test(a: string, b: number): number {
|
function test(a: string, b: number): number {
|
||||||
return this.length;
|
return this.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
test.call(\"\", \"\", 0);
|
test.call(\"\", \"\", 0);
|
||||||
|
|
||||||
test.call(0, \"\", 0);
|
test.call(0, \"\", 0);
|
||||||
|
|
||||||
test.call(\"\", \"\");
|
test.call(\"\", \"\");
|
||||||
|
|
||||||
test.call(\"\", \"\", \"\");
|
test.call(\"\", \"\", \"\");
|
||||||
|
|
||||||
test.call(\"\", 0, 0);
|
test.call(\"\", 0, 0);
|
||||||
|
|
||||||
function f(args) {
|
function f(args) {
|
||||||
test.call(\"\", args[0], args[1]);
|
test.call(\"\", args[0], args[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
f([ \"\", 0 ]);
|
f([ \"\", 0 ]);
|
||||||
|
|
||||||
f([ \"\", \"\" ]);
|
f([ \"\", \"\" ]);
|
||||||
|
|
||||||
f([ 0, 0 ]);
|
f([ 0, 0 ]);
|
||||||
|
|
||||||
(test.apply.call(test, 0, [ 0, \"foo\" ]): number);
|
(test.apply.call(test, 0, [ 0, \"foo\" ]): number);
|
||||||
|
|
||||||
function test2(): number {
|
function test2(): number {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
(test2.call(): number);
|
(test2.call(): number);
|
||||||
|
|
||||||
(test2.call(\"\"): number);
|
(test2.call(\"\"): number);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -292,17 +322,25 @@ var b: Function = function(a: number, b: number): number {
|
||||||
};
|
};
|
||||||
class C {}
|
class C {}
|
||||||
var c: Function = C;
|
var c: Function = C;
|
||||||
|
|
||||||
function good(x: Function, MyThing: Function): number {
|
function good(x: Function, MyThing: Function): number {
|
||||||
var o: Object = x;
|
var o: Object = x;
|
||||||
|
|
||||||
x.foo = 123;
|
x.foo = 123;
|
||||||
|
|
||||||
x[\"foo\"] = 456;
|
x[\"foo\"] = 456;
|
||||||
|
|
||||||
x();
|
x();
|
||||||
|
|
||||||
<MyThing/>;
|
<MyThing/>;
|
||||||
var { ...something } = x;
|
var { ...something } = x;
|
||||||
|
|
||||||
Object.assign(x, { hi: \"there\" });
|
Object.assign(x, { hi: \"there\" });
|
||||||
|
|
||||||
Object.keys(x);
|
Object.keys(x);
|
||||||
return x.bar + x[\"bar\"] + x.lala();
|
return x.bar + x[\"bar\"] + x.lala();
|
||||||
}
|
}
|
||||||
|
|
||||||
function bad(x: Function, y: Object): void {
|
function bad(x: Function, y: Object): void {
|
||||||
var a: number = x;
|
var a: number = x;
|
||||||
var b: string = x;
|
var b: string = x;
|
||||||
|
@ -310,33 +348,45 @@ function bad(x: Function, y: Object): void {
|
||||||
}
|
}
|
||||||
let tests = [
|
let tests = [
|
||||||
function(y: () => void, z: Function) {
|
function(y: () => void, z: Function) {
|
||||||
function x() {
|
function x() {}
|
||||||
|
|
||||||
}
|
|
||||||
(x.length: void);
|
(x.length: void);
|
||||||
|
|
||||||
(y.length: void);
|
(y.length: void);
|
||||||
|
|
||||||
(z.length: void);
|
(z.length: void);
|
||||||
|
|
||||||
(x.name: void);
|
(x.name: void);
|
||||||
|
|
||||||
(y.name: void);
|
(y.name: void);
|
||||||
|
|
||||||
(z.name: void);
|
(z.name: void);
|
||||||
},
|
},
|
||||||
function(y: () => void, z: Function) {
|
function(y: () => void, z: Function) {
|
||||||
function x() {
|
function x() {}
|
||||||
|
|
||||||
}
|
|
||||||
x.length = \"foo\";
|
x.length = \"foo\";
|
||||||
|
|
||||||
y.length = \"foo\";
|
y.length = \"foo\";
|
||||||
|
|
||||||
z.length = \"foo\";
|
z.length = \"foo\";
|
||||||
|
|
||||||
x.name = 123;
|
x.name = 123;
|
||||||
|
|
||||||
y.name = 123;
|
y.name = 123;
|
||||||
|
|
||||||
z.name = 123;
|
z.name = 123;
|
||||||
|
|
||||||
(z.foo: number);
|
(z.foo: number);
|
||||||
|
|
||||||
(z.foo: string);
|
(z.foo: string);
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
var d: Function = () => 1;
|
var d: Function = () => 1;
|
||||||
var e = (d.bind(1): Function)();
|
var e = (d.bind(1): Function)();
|
||||||
|
|
||||||
(e: number);
|
(e: number);
|
||||||
|
|
||||||
(e: string);
|
(e: string);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -368,12 +418,15 @@ function rest_t<U, T: Array<U>>(...xs: T): U {
|
||||||
function rest_array<T>(...xs: Array<T>): T {
|
function rest_array<T>(...xs: Array<T>): T {
|
||||||
return xs[0];
|
return xs[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
function rest_tuple<T>(...xs: [T]): T {
|
function rest_tuple<T>(...xs: [T]): T {
|
||||||
return xs[0];
|
return xs[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
function rest_any(...xs: any): any {
|
function rest_any(...xs: any): any {
|
||||||
return xs[0];
|
return xs[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
function rest_t<U, T: Array<U>>(...xs: T): U {
|
function rest_t<U, T: Array<U>>(...xs: T): U {
|
||||||
return xs[0];
|
return xs[0];
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ function foo() {
|
||||||
function bar(x) {
|
function bar(x) {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
function foo() {
|
function foo() {
|
||||||
return function bound() {
|
return function bound() {
|
||||||
return bar(bound);
|
return bar(bound);
|
||||||
|
|
|
@ -151,14 +151,17 @@ for (var x of examples.delegate_yield_iterable([])) {
|
||||||
class GeneratorExamples {
|
class GeneratorExamples {
|
||||||
*stmt_yield(): Generator<number, void, void> {
|
*stmt_yield(): Generator<number, void, void> {
|
||||||
yield 0;
|
yield 0;
|
||||||
|
|
||||||
yield \"\";
|
yield \"\";
|
||||||
}
|
}
|
||||||
*stmt_next(): Generator<void, void, number> {
|
*stmt_next(): Generator<void, void, number> {
|
||||||
var a = yield;
|
var a = yield;
|
||||||
|
|
||||||
if (a) {
|
if (a) {
|
||||||
(a: number);
|
(a: number);
|
||||||
}
|
}
|
||||||
var b = yield;
|
var b = yield;
|
||||||
|
|
||||||
if (b) {
|
if (b) {
|
||||||
(b: string);
|
(b: string);
|
||||||
}
|
}
|
||||||
|
@ -175,30 +178,35 @@ class GeneratorExamples {
|
||||||
}
|
}
|
||||||
*widen_next() {
|
*widen_next() {
|
||||||
var x = yield 0;
|
var x = yield 0;
|
||||||
if (typeof x === \"number\") {
|
|
||||||
|
|
||||||
} else
|
if (typeof x === \"number\")
|
||||||
if (typeof x === \"boolean\") {
|
{}
|
||||||
|
else
|
||||||
} else {
|
if (typeof x === \"boolean\")
|
||||||
|
{}
|
||||||
|
else {
|
||||||
(x: string);
|
(x: string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*widen_yield() {
|
*widen_yield() {
|
||||||
yield 0;
|
yield 0;
|
||||||
|
|
||||||
yield \"\";
|
yield \"\";
|
||||||
|
|
||||||
yield true;
|
yield true;
|
||||||
}
|
}
|
||||||
*delegate_next_generator() {
|
*delegate_next_generator() {
|
||||||
function* inner() {
|
function* inner() {
|
||||||
var x: number = yield;
|
var x: number = yield;
|
||||||
}
|
}
|
||||||
|
|
||||||
yield* inner();
|
yield* inner();
|
||||||
}
|
}
|
||||||
*delegate_yield_generator() {
|
*delegate_yield_generator() {
|
||||||
function* inner() {
|
function* inner() {
|
||||||
yield \"\";
|
yield \"\";
|
||||||
}
|
}
|
||||||
|
|
||||||
yield* inner();
|
yield* inner();
|
||||||
}
|
}
|
||||||
*delegate_return_generator() {
|
*delegate_return_generator() {
|
||||||
|
@ -227,37 +235,47 @@ class GeneratorExamples {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var examples = new GeneratorExamples();
|
var examples = new GeneratorExamples();
|
||||||
|
|
||||||
for (var x of examples.infer_stmt()) {
|
for (var x of examples.infer_stmt()) {
|
||||||
(x: string);
|
(x: string);
|
||||||
}
|
}
|
||||||
var infer_stmt_next = examples.infer_stmt().next(0).value;
|
var infer_stmt_next = examples.infer_stmt().next(0).value;
|
||||||
if (typeof infer_stmt_next === \"undefined\") {
|
|
||||||
|
|
||||||
} else
|
if (typeof infer_stmt_next === \"undefined\")
|
||||||
if (typeof infer_stmt_next === \"number\") {
|
{}
|
||||||
|
else
|
||||||
} else {
|
if (typeof infer_stmt_next === \"number\")
|
||||||
|
{}
|
||||||
|
else {
|
||||||
(infer_stmt_next: boolean);
|
(infer_stmt_next: boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
examples.widen_next().next(0);
|
examples.widen_next().next(0);
|
||||||
|
|
||||||
examples.widen_next().next(\"\");
|
examples.widen_next().next(\"\");
|
||||||
|
|
||||||
examples.widen_next().next(true);
|
examples.widen_next().next(true);
|
||||||
|
|
||||||
for (var x of examples.widen_yield()) {
|
for (var x of examples.widen_yield()) {
|
||||||
if (typeof x === \"number\") {
|
if (typeof x === \"number\")
|
||||||
|
{}
|
||||||
} else
|
else
|
||||||
if (typeof x === \"boolean\") {
|
if (typeof x === \"boolean\")
|
||||||
|
{}
|
||||||
} else {
|
else {
|
||||||
(x: string);
|
(x: string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
examples.delegate_next_generator().next(\"\");
|
examples.delegate_next_generator().next(\"\");
|
||||||
|
|
||||||
for (var x of examples.delegate_yield_generator()) {
|
for (var x of examples.delegate_yield_generator()) {
|
||||||
(x: number);
|
(x: number);
|
||||||
}
|
}
|
||||||
examples.delegate_next_iterable([ ]).next(\"\");
|
|
||||||
for (var x of examples.delegate_yield_iterable([ ])) {
|
examples.delegate_next_iterable([]).next(\"\");
|
||||||
|
|
||||||
|
for (var x of examples.delegate_yield_iterable([])) {
|
||||||
(x: string);
|
(x: string);
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
@ -297,16 +315,18 @@ class GeneratorExamples<X> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var examples = new GeneratorExamples();
|
var examples = new GeneratorExamples();
|
||||||
|
|
||||||
for (var x of examples.infer_stmt()) {
|
for (var x of examples.infer_stmt()) {
|
||||||
(x: string);
|
(x: string);
|
||||||
}
|
}
|
||||||
var infer_stmt_next = examples.infer_stmt().next(0).value;
|
var infer_stmt_next = examples.infer_stmt().next(0).value;
|
||||||
if (typeof infer_stmt_next === \"undefined\") {
|
|
||||||
|
|
||||||
} else
|
if (typeof infer_stmt_next === \"undefined\")
|
||||||
if (typeof infer_stmt_next === \"number\") {
|
{}
|
||||||
|
else
|
||||||
} else {
|
if (typeof infer_stmt_next === \"number\")
|
||||||
|
{}
|
||||||
|
else {
|
||||||
(infer_stmt_next: boolean);
|
(infer_stmt_next: boolean);
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
@ -464,113 +484,147 @@ if (multiple_return_result.done) {
|
||||||
// error: number|string ~> void
|
// error: number|string ~> void
|
||||||
function* stmt_yield(): Generator<number, void, void> {
|
function* stmt_yield(): Generator<number, void, void> {
|
||||||
yield 0;
|
yield 0;
|
||||||
|
|
||||||
yield \"\";
|
yield \"\";
|
||||||
}
|
}
|
||||||
|
|
||||||
function* stmt_next(): Generator<void, void, number> {
|
function* stmt_next(): Generator<void, void, number> {
|
||||||
var a = yield;
|
var a = yield;
|
||||||
|
|
||||||
if (a) {
|
if (a) {
|
||||||
(a: number);
|
(a: number);
|
||||||
}
|
}
|
||||||
var b = yield;
|
var b = yield;
|
||||||
|
|
||||||
if (b) {
|
if (b) {
|
||||||
(b: string);
|
(b: string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function* stmt_return_ok(): Generator<void, number, void> {
|
function* stmt_return_ok(): Generator<void, number, void> {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function* stmt_return_err(): Generator<void, number, void> {
|
function* stmt_return_err(): Generator<void, number, void> {
|
||||||
return \"\";
|
return \"\";
|
||||||
}
|
}
|
||||||
|
|
||||||
function* infer_stmt() {
|
function* infer_stmt() {
|
||||||
var x: boolean = yield 0;
|
var x: boolean = yield 0;
|
||||||
return \"\";
|
return \"\";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var x of infer_stmt()) {
|
for (var x of infer_stmt()) {
|
||||||
(x: string);
|
(x: string);
|
||||||
}
|
}
|
||||||
var infer_stmt_next = infer_stmt().next(0).value;
|
var infer_stmt_next = infer_stmt().next(0).value;
|
||||||
if (typeof infer_stmt_next === \"undefined\") {
|
|
||||||
|
|
||||||
} else
|
if (typeof infer_stmt_next === \"undefined\")
|
||||||
if (typeof infer_stmt_next === \"number\") {
|
{}
|
||||||
|
else
|
||||||
} else {
|
if (typeof infer_stmt_next === \"number\")
|
||||||
|
{}
|
||||||
|
else {
|
||||||
(infer_stmt_next: boolean);
|
(infer_stmt_next: boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
function* widen_next() {
|
function* widen_next() {
|
||||||
var x = yield 0;
|
var x = yield 0;
|
||||||
if (typeof x === \"number\") {
|
|
||||||
|
|
||||||
} else
|
if (typeof x === \"number\")
|
||||||
if (typeof x === \"boolean\") {
|
{}
|
||||||
|
else
|
||||||
} else {
|
if (typeof x === \"boolean\")
|
||||||
|
{}
|
||||||
|
else {
|
||||||
(x: string);
|
(x: string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
widen_next().next(0);
|
widen_next().next(0);
|
||||||
|
|
||||||
widen_next().next(\"\");
|
widen_next().next(\"\");
|
||||||
|
|
||||||
widen_next().next(true);
|
widen_next().next(true);
|
||||||
|
|
||||||
function* widen_yield() {
|
function* widen_yield() {
|
||||||
yield 0;
|
yield 0;
|
||||||
|
|
||||||
yield \"\";
|
yield \"\";
|
||||||
|
|
||||||
yield true;
|
yield true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var x of widen_yield()) {
|
for (var x of widen_yield()) {
|
||||||
if (typeof x === \"number\") {
|
if (typeof x === \"number\")
|
||||||
|
{}
|
||||||
} else
|
else
|
||||||
if (typeof x === \"boolean\") {
|
if (typeof x === \"boolean\")
|
||||||
|
{}
|
||||||
} else {
|
else {
|
||||||
(x: string);
|
(x: string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function* delegate_next_generator() {
|
function* delegate_next_generator() {
|
||||||
function* inner() {
|
function* inner() {
|
||||||
var x: number = yield;
|
var x: number = yield;
|
||||||
}
|
}
|
||||||
|
|
||||||
yield* inner();
|
yield* inner();
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate_next_generator().next(\"\");
|
delegate_next_generator().next(\"\");
|
||||||
|
|
||||||
function* delegate_yield_generator() {
|
function* delegate_yield_generator() {
|
||||||
function* inner() {
|
function* inner() {
|
||||||
yield \"\";
|
yield \"\";
|
||||||
}
|
}
|
||||||
|
|
||||||
yield* inner();
|
yield* inner();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var x of delegate_yield_generator()) {
|
for (var x of delegate_yield_generator()) {
|
||||||
(x: number);
|
(x: number);
|
||||||
}
|
}
|
||||||
|
|
||||||
function* delegate_return_generator() {
|
function* delegate_return_generator() {
|
||||||
function* inner() {
|
function* inner() {
|
||||||
return \"\";
|
return \"\";
|
||||||
}
|
}
|
||||||
var x: number = yield* inner();
|
var x: number = yield* inner();
|
||||||
}
|
}
|
||||||
|
|
||||||
function* delegate_next_iterable(xs: Array<number>) {
|
function* delegate_next_iterable(xs: Array<number>) {
|
||||||
yield* xs;
|
yield* xs;
|
||||||
}
|
}
|
||||||
delegate_next_iterable([ ]).next(\"\");
|
|
||||||
|
delegate_next_iterable([]).next(\"\");
|
||||||
|
|
||||||
function* delegate_yield_iterable(xs: Array<number>) {
|
function* delegate_yield_iterable(xs: Array<number>) {
|
||||||
yield* xs;
|
yield* xs;
|
||||||
}
|
}
|
||||||
for (var x of delegate_yield_iterable([ ])) {
|
|
||||||
|
for (var x of delegate_yield_iterable([])) {
|
||||||
(x: string);
|
(x: string);
|
||||||
}
|
}
|
||||||
|
|
||||||
function* delegate_return_iterable(xs: Array<number>) {
|
function* delegate_return_iterable(xs: Array<number>) {
|
||||||
var x: void = yield* xs;
|
var x: void = yield* xs;
|
||||||
}
|
}
|
||||||
|
|
||||||
function* generic_yield<Y>(y: Y): Generator<Y, void, void> {
|
function* generic_yield<Y>(y: Y): Generator<Y, void, void> {
|
||||||
yield y;
|
yield y;
|
||||||
}
|
}
|
||||||
|
|
||||||
function* generic_return<R>(r: R): Generator<void, R, void> {
|
function* generic_return<R>(r: R): Generator<void, R, void> {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
function* generic_next<N>(): Generator<void, N, N> {
|
function* generic_next<N>(): Generator<void, N, N> {
|
||||||
return yield undefined;
|
return yield undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function* multiple_return(b) {
|
function* multiple_return(b) {
|
||||||
if (b) {
|
if (b) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -579,6 +633,7 @@ function* multiple_return(b) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let multiple_return_result = multiple_return().next();
|
let multiple_return_result = multiple_return().next();
|
||||||
|
|
||||||
if (multiple_return_result.done) {
|
if (multiple_return_result.done) {
|
||||||
(multiple_return_result.value: void);
|
(multiple_return_result.value: void);
|
||||||
}
|
}
|
||||||
|
@ -616,8 +671,10 @@ if (refuse_return_result.done) {
|
||||||
// error: number | void ~> string
|
// error: number | void ~> string
|
||||||
function test1(gen: Generator<void, string, void>) {
|
function test1(gen: Generator<void, string, void>) {
|
||||||
var ret = gen.return(0);
|
var ret = gen.return(0);
|
||||||
|
|
||||||
(ret.value: void);
|
(ret.value: void);
|
||||||
}
|
}
|
||||||
|
|
||||||
function* refuse_return() {
|
function* refuse_return() {
|
||||||
try {
|
try {
|
||||||
yield 1;
|
yield 1;
|
||||||
|
@ -627,6 +684,7 @@ function* refuse_return() {
|
||||||
}
|
}
|
||||||
var refuse_return_gen = refuse_return();
|
var refuse_return_gen = refuse_return();
|
||||||
var refuse_return_result = refuse_return_gen.return(\"string\");
|
var refuse_return_result = refuse_return_gen.return(\"string\");
|
||||||
|
|
||||||
if (refuse_return_result.done) {
|
if (refuse_return_result.done) {
|
||||||
(refuse_return_result.value: string);
|
(refuse_return_result.value: string);
|
||||||
}
|
}
|
||||||
|
@ -670,9 +728,11 @@ function* catch_return() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var catch_return_value = catch_return().throw(\"\").value;
|
var catch_return_value = catch_return().throw(\"\").value;
|
||||||
|
|
||||||
if (catch_return_value !== undefined) {
|
if (catch_return_value !== undefined) {
|
||||||
(catch_return_value: string);
|
(catch_return_value: string);
|
||||||
}
|
}
|
||||||
|
|
||||||
function* yield_return() {
|
function* yield_return() {
|
||||||
try {
|
try {
|
||||||
yield 0;
|
yield 0;
|
||||||
|
@ -682,6 +742,7 @@ function* yield_return() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var yield_return_value = yield_return().throw(\"\").value;
|
var yield_return_value = yield_return().throw(\"\").value;
|
||||||
|
|
||||||
if (yield_return_value !== undefined) {
|
if (yield_return_value !== undefined) {
|
||||||
(yield_return_value: string);
|
(yield_return_value: string);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ class D<T> {
|
||||||
x: T;
|
x: T;
|
||||||
m<S>(z: S, u: T, v): S {
|
m<S>(z: S, u: T, v): S {
|
||||||
this.x = u;
|
this.x = u;
|
||||||
|
|
||||||
v.u = u;
|
v.u = u;
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
@ -89,6 +90,7 @@ class H<Z> extends G<Array<Z>> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var h1 = new H();
|
var h1 = new H();
|
||||||
|
|
||||||
h1.foo([ \"...\" ]);
|
h1.foo([ \"...\" ]);
|
||||||
var h2: F<Array<Array<Array<number>>>> = h1;
|
var h2: F<Array<Array<Array<number>>>> = h1;
|
||||||
var obj: Object<string, string> = {};
|
var obj: Object<string, string> = {};
|
||||||
|
|
|
@ -38,6 +38,7 @@ var id = geolocation.watchPosition(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
geolocation.clearWatch(id);
|
geolocation.clearWatch(id);
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -19,11 +19,14 @@ lib.bar();
|
||||||
// t123456
|
// t123456
|
||||||
// D123456
|
// D123456
|
||||||
var lib = require(\"./library\");
|
var lib = require(\"./library\");
|
||||||
|
|
||||||
function add(a: number, b: number): number {
|
function add(a: number, b: number): number {
|
||||||
return a + b;
|
return a + b;
|
||||||
}
|
}
|
||||||
var re = /^keynote (talk){2} (lightning){3,5} (talk){2} closing partytime!!!/;
|
var re = /^keynote (talk){2} (lightning){3,5} (talk){2} closing partytime!!!/;
|
||||||
|
|
||||||
add(lib.iTakeAString(42), 7);
|
add(lib.iTakeAString(42), 7);
|
||||||
|
|
||||||
lib.bar();
|
lib.bar();
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -43,11 +46,15 @@ things;
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// @flow
|
// @flow
|
||||||
import thing from \"./helpers/exports_default.js\";
|
import thing from \"./helpers/exports_default.js\";
|
||||||
|
|
||||||
thing;
|
thing;
|
||||||
import { foo, bar as baz } from \"./helpers/exports_named.js\";
|
import { foo, bar as baz } from \"./helpers/exports_named.js\";
|
||||||
|
|
||||||
foo;
|
foo;
|
||||||
|
|
||||||
baz;
|
baz;
|
||||||
import * as things from \"./helpers/exports_named.js\";
|
import * as things from \"./helpers/exports_named.js\";
|
||||||
|
|
||||||
things;
|
things;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -6,6 +6,7 @@ module.exports = {ParentFoo};
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// @flow
|
// @flow
|
||||||
var ParentFoo = { foo: \"bar\" };
|
var ParentFoo = { foo: \"bar\" };
|
||||||
|
|
||||||
module.exports = { ParentFoo };
|
module.exports = { ParentFoo };
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -45,14 +46,20 @@ import type {Foo} from \'./types\';
|
||||||
// Follows non-destructured property access of \`require(\'Parent\')\`
|
// Follows non-destructured property access of \`require(\'Parent\')\`
|
||||||
var Parent = require(\"./Parent\");
|
var Parent = require(\"./Parent\");
|
||||||
let ParentFoo;
|
let ParentFoo;
|
||||||
|
|
||||||
({ ParentFoo } = Parent);
|
({ ParentFoo } = Parent);
|
||||||
|
|
||||||
ParentFoo;
|
ParentFoo;
|
||||||
let ParentFoo2;
|
let ParentFoo2;
|
||||||
|
|
||||||
ParentFoo2 = Parent;
|
ParentFoo2 = Parent;
|
||||||
|
|
||||||
ParentFoo2;
|
ParentFoo2;
|
||||||
let ParentFoo3 = Parent;
|
let ParentFoo3 = Parent;
|
||||||
|
|
||||||
ParentFoo3;
|
ParentFoo3;
|
||||||
let foo = require(\"./Parent\").ParentFoo.foo;
|
let foo = require(\"./Parent\").ParentFoo.foo;
|
||||||
|
|
||||||
foo;
|
foo;
|
||||||
import type { Foo } from \"./types\";
|
import type { Foo } from \"./types\";
|
||||||
"
|
"
|
||||||
|
@ -73,9 +80,7 @@ class D extends C {
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// @flow
|
// @flow
|
||||||
class C {
|
class C {
|
||||||
override() {
|
override() {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
class D extends C {
|
class D extends C {
|
||||||
foo() {
|
foo() {
|
||||||
|
@ -84,9 +89,7 @@ class D extends C {
|
||||||
bar() {
|
bar() {
|
||||||
this.override;
|
this.override;
|
||||||
}
|
}
|
||||||
override() {
|
override() {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -109,7 +112,9 @@ class C extends React.Component {
|
||||||
props: { x: string };
|
props: { x: string };
|
||||||
}
|
}
|
||||||
let msg = \"hello\";
|
let msg = \"hello\";
|
||||||
|
|
||||||
<C x={msg}/>;
|
<C x={msg}/>;
|
||||||
|
|
||||||
<div id={msg}/>;
|
<div id={msg}/>;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -28,6 +28,7 @@ require(\'b\');
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// @flow
|
// @flow
|
||||||
require(\"./a.js\");
|
require(\"./a.js\");
|
||||||
|
|
||||||
require(\"b\");
|
require(\"b\");
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -88,47 +88,42 @@ class Foo {
|
||||||
get propWithMatchingGetterAndSetter(): number {
|
get propWithMatchingGetterAndSetter(): number {
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
set propWithMatchingGetterAndSetter(x: number) {
|
set propWithMatchingGetterAndSetter(x: number) {}
|
||||||
|
|
||||||
}
|
|
||||||
get propWithSubtypingGetterAndSetter(): ?number {
|
get propWithSubtypingGetterAndSetter(): ?number {
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
set propWithSubtypingGetterAndSetter(x: number) {
|
set propWithSubtypingGetterAndSetter(x: number) {}
|
||||||
|
set propWithSubtypingGetterAndSetterReordered(x: number) {}
|
||||||
}
|
|
||||||
set propWithSubtypingGetterAndSetterReordered(x: number) {
|
|
||||||
|
|
||||||
}
|
|
||||||
get propWithSubtypingGetterAndSetterReordered(): ?number {
|
get propWithSubtypingGetterAndSetterReordered(): ?number {
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
get propWithMismatchingGetterAndSetter(): number {
|
get propWithMismatchingGetterAndSetter(): number {
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
set propWithMismatchingGetterAndSetter(x: string) {
|
set propWithMismatchingGetterAndSetter(x: string) {}
|
||||||
|
|
||||||
}
|
|
||||||
propOverriddenWithGetter: number;
|
propOverriddenWithGetter: number;
|
||||||
get propOverriddenWithGetter() {
|
get propOverriddenWithGetter() {
|
||||||
return \"hello\";
|
return \"hello\";
|
||||||
}
|
}
|
||||||
propOverriddenWithSetter: number;
|
propOverriddenWithSetter: number;
|
||||||
set propOverriddenWithSetter(x: string) {
|
set propOverriddenWithSetter(x: string) {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var foo = new Foo();
|
var foo = new Foo();
|
||||||
var testGetterNoError1: number = foo.goodGetterNoAnnotation;
|
var testGetterNoError1: number = foo.goodGetterNoAnnotation;
|
||||||
var testGetterNoError2: number = foo.goodGetterWithAnnotation;
|
var testGetterNoError2: number = foo.goodGetterWithAnnotation;
|
||||||
var testGetterWithError1: string = foo.goodGetterNoAnnotation;
|
var testGetterWithError1: string = foo.goodGetterNoAnnotation;
|
||||||
var testGetterWithError2: string = foo.goodGetterWithAnnotation;
|
var testGetterWithError2: string = foo.goodGetterWithAnnotation;
|
||||||
|
|
||||||
foo.goodSetterNoAnnotation = 123;
|
foo.goodSetterNoAnnotation = 123;
|
||||||
|
|
||||||
foo.goodSetterWithAnnotation = 123;
|
foo.goodSetterWithAnnotation = 123;
|
||||||
|
|
||||||
foo.goodSetterNoAnnotation = \"hello\";
|
foo.goodSetterNoAnnotation = \"hello\";
|
||||||
|
|
||||||
foo.goodSetterWithAnnotation = \"hello\";
|
foo.goodSetterWithAnnotation = \"hello\";
|
||||||
var testSubtypingGetterAndSetter: number = foo.propWithSubtypingGetterAndSetter;
|
var testSubtypingGetterAndSetter: number = foo.propWithSubtypingGetterAndSetter;
|
||||||
var testPropOverridenWithGetter: number = foo.propOverriddenWithGetter;
|
var testPropOverridenWithGetter: number = foo.propOverriddenWithGetter;
|
||||||
|
|
||||||
foo.propOverriddenWithSetter = 123;
|
foo.propOverriddenWithSetter = 123;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
@ -234,30 +229,20 @@ var obj = {
|
||||||
get propWithMatchingGetterAndSetter(): number {
|
get propWithMatchingGetterAndSetter(): number {
|
||||||
return 4;
|
return 4;
|
||||||
},
|
},
|
||||||
set propWithMatchingGetterAndSetter(x: number) {
|
set propWithMatchingGetterAndSetter(x: number) {},
|
||||||
|
|
||||||
},
|
|
||||||
get propWithSubtypingGetterAndSetter(): ?number {
|
get propWithSubtypingGetterAndSetter(): ?number {
|
||||||
return 4;
|
return 4;
|
||||||
},
|
},
|
||||||
set propWithSubtypingGetterAndSetter(x: number) {
|
set propWithSubtypingGetterAndSetter(x: number) {},
|
||||||
|
set propWithSubtypingGetterAndSetterReordered(x: number) {},
|
||||||
},
|
|
||||||
set propWithSubtypingGetterAndSetterReordered(x: number) {
|
|
||||||
|
|
||||||
},
|
|
||||||
get propWithSubtypingGetterAndSetterReordered(): ?number {
|
get propWithSubtypingGetterAndSetterReordered(): ?number {
|
||||||
return 4;
|
return 4;
|
||||||
},
|
},
|
||||||
get exampleOfOrderOfGetterAndSetter(): A {
|
get exampleOfOrderOfGetterAndSetter(): A {
|
||||||
return new A();
|
return new A();
|
||||||
},
|
},
|
||||||
set exampleOfOrderOfGetterAndSetter(x: B) {
|
set exampleOfOrderOfGetterAndSetter(x: B) {},
|
||||||
|
set exampleOfOrderOfGetterAndSetterReordered(x: B) {},
|
||||||
},
|
|
||||||
set exampleOfOrderOfGetterAndSetterReordered(x: B) {
|
|
||||||
|
|
||||||
},
|
|
||||||
get exampleOfOrderOfGetterAndSetterReordered(): A {
|
get exampleOfOrderOfGetterAndSetterReordered(): A {
|
||||||
return new A();
|
return new A();
|
||||||
}
|
}
|
||||||
|
@ -266,11 +251,16 @@ var testGetterNoError1: number = obj.goodGetterNoAnnotation;
|
||||||
var testGetterNoError2: number = obj.goodGetterWithAnnotation;
|
var testGetterNoError2: number = obj.goodGetterWithAnnotation;
|
||||||
var testGetterWithError1: string = obj.goodGetterNoAnnotation;
|
var testGetterWithError1: string = obj.goodGetterNoAnnotation;
|
||||||
var testGetterWithError2: string = obj.goodGetterWithAnnotation;
|
var testGetterWithError2: string = obj.goodGetterWithAnnotation;
|
||||||
|
|
||||||
obj.goodSetterNoAnnotation = 123;
|
obj.goodSetterNoAnnotation = 123;
|
||||||
|
|
||||||
obj.goodSetterWithAnnotation = 123;
|
obj.goodSetterWithAnnotation = 123;
|
||||||
|
|
||||||
obj.goodSetterNoAnnotation = \"hello\";
|
obj.goodSetterNoAnnotation = \"hello\";
|
||||||
|
|
||||||
obj.goodSetterWithAnnotation = \"hello\";
|
obj.goodSetterWithAnnotation = \"hello\";
|
||||||
var testSubtypingGetterAndSetter: number = obj.propWithSubtypingGetterAndSetter;
|
var testSubtypingGetterAndSetter: number = obj.propWithSubtypingGetterAndSetter;
|
||||||
|
|
||||||
obj.exampleOfOrderOfGetterAndSetter = new C();
|
obj.exampleOfOrderOfGetterAndSetter = new C();
|
||||||
var testExampleOrOrderOfGetterAndSetterReordered: number = obj.exampleOfOrderOfGetterAndSetterReordered;
|
var testExampleOrOrderOfGetterAndSetterReordered: number = obj.exampleOfOrderOfGetterAndSetterReordered;
|
||||||
"
|
"
|
||||||
|
@ -412,50 +402,52 @@ class Base {
|
||||||
this.x = value;
|
this.x = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(class extends Base {
|
(class extends Base {
|
||||||
get x(): B {
|
get x(): B {
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
(class extends Base {
|
|
||||||
set x(value: B): void {
|
|
||||||
|
|
||||||
}
|
(class extends Base {
|
||||||
|
set x(value: B): void {}
|
||||||
});
|
});
|
||||||
|
|
||||||
(class extends Base {
|
(class extends Base {
|
||||||
get x(): C {
|
get x(): C {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
set x(value: A): void {
|
set x(value: A): void {}
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
(class extends Base {
|
(class extends Base {
|
||||||
set pos(value: B): void {
|
set pos(value: B): void {}
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
(class extends Base {
|
(class extends Base {
|
||||||
get pos(): C {
|
get pos(): C {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
(class extends Base {
|
(class extends Base {
|
||||||
get neg(): B {
|
get neg(): B {
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
(class extends Base {
|
|
||||||
set neg(value: A): void {
|
|
||||||
|
|
||||||
}
|
(class extends Base {
|
||||||
|
set neg(value: A): void {}
|
||||||
});
|
});
|
||||||
|
|
||||||
(class extends Base {
|
(class extends Base {
|
||||||
get: C;
|
get: C;
|
||||||
});
|
});
|
||||||
|
|
||||||
(class extends Base {
|
(class extends Base {
|
||||||
set: A;
|
set: A;
|
||||||
});
|
});
|
||||||
|
|
||||||
(class extends Base {
|
(class extends Base {
|
||||||
getset: B;
|
getset: B;
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,9 +22,11 @@ module.exports = foo;
|
||||||
\'Required module not found\'.
|
\'Required module not found\'.
|
||||||
*/
|
*/
|
||||||
var _ = require(\"underscore\");
|
var _ = require(\"underscore\");
|
||||||
|
|
||||||
function foo(): string {
|
function foo(): string {
|
||||||
return _.foo();
|
return _.foo();
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = foo;
|
module.exports = foo;
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -21,6 +21,7 @@ class B extends A {
|
||||||
}
|
}
|
||||||
class C extends A {}
|
class C extends A {}
|
||||||
var a: A = new B();
|
var a: A = new B();
|
||||||
|
|
||||||
a.foo = function(): C {
|
a.foo = function(): C {
|
||||||
return new 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