Update snapshots
parent
de4d7ac799
commit
37601b0a86
|
@ -34,10 +34,10 @@ function bar(x: number) {}
|
|||
|
||||
function foo() {
|
||||
var x = null;
|
||||
|
||||
|
||||
if (x == null)
|
||||
return;
|
||||
|
||||
|
||||
bar(x);
|
||||
}
|
||||
"
|
||||
|
|
|
@ -73,6 +73,7 @@ function barfoo(n : number | null | void) : ?number { return n; }
|
|||
function foo(str: string, i: number): string {
|
||||
return str;
|
||||
}
|
||||
|
||||
var bar: (str: number, i: number) => string = foo;
|
||||
var qux = function(str: string, i: number): number {
|
||||
return foo(str, i);
|
||||
|
@ -111,6 +112,7 @@ function param_anno2(
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
var toz: null = 3;
|
||||
var zer: null = null;
|
||||
|
||||
|
@ -150,14 +152,16 @@ let myClassInstance: MyClass = null;
|
|||
function bar(): MyClass {
|
||||
return null;
|
||||
}
|
||||
|
||||
class MyClass {}
|
||||
|
||||
function foo() {
|
||||
let myClassInstance: MyClass = mk();
|
||||
|
||||
|
||||
function mk() {
|
||||
return new MyClass();
|
||||
}
|
||||
|
||||
class MyClass {}
|
||||
}
|
||||
"
|
||||
|
@ -271,8 +275,10 @@ function insertMany<K, V>(
|
|||
function f([ k, v ]: [K, V], m: Map<K, V>): Map<K, V> {
|
||||
return m.insertWith(merge, k, v);
|
||||
}
|
||||
|
||||
return foldr(f, m, vs);
|
||||
}
|
||||
|
||||
class Foo<A> {
|
||||
bar<B>() {
|
||||
return function<C>(a: A, b: B, c: C): void {
|
||||
|
|
|
@ -21,6 +21,7 @@ function bar(x: any): mixed {
|
|||
function qux(x: mixed): any {
|
||||
return x;
|
||||
}
|
||||
|
||||
var x: string = foo(0);
|
||||
var y: string = bar(0);
|
||||
var z: string = qux(0);
|
||||
|
@ -82,6 +83,7 @@ function qux(x: $FlowFixMe<number>): $FlowFixMe<number> {
|
|||
function baz(x: $FlowFixMe<nnumber>): $FlowFixMe<number> {
|
||||
return x;
|
||||
}
|
||||
|
||||
var x: string = foo(0);
|
||||
var y: string = bar(0);
|
||||
var z: string = qux(0);
|
||||
|
@ -134,6 +136,7 @@ function qux(x: $FlowIssue<number>): $FlowIssue<number> {
|
|||
function baz(x: $FlowIssue<nnumber>): $FlowIssue<number> {
|
||||
return x;
|
||||
}
|
||||
|
||||
var x: string = foo(0);
|
||||
var y: string = bar(0);
|
||||
var z: string = qux(0);
|
||||
|
@ -189,6 +192,7 @@ function foo(c: C, x: any): string {
|
|||
let y = x.y;
|
||||
return c.bar(0, y);
|
||||
}
|
||||
|
||||
var any_fun1 = require(\"./nonflowfile\");
|
||||
|
||||
function bar1(x: mixed) {
|
||||
|
@ -196,6 +200,7 @@ function bar1(x: mixed) {
|
|||
(x: boolean);
|
||||
}
|
||||
}
|
||||
|
||||
var any_fun2 = require(\"./anyexportflowfile\");
|
||||
|
||||
function bar2(x: mixed) {
|
||||
|
|
|
@ -140,15 +140,15 @@ function foo() {
|
|||
var x = 0;
|
||||
var y = \"...\";
|
||||
var z = {};
|
||||
|
||||
|
||||
num(x + x);
|
||||
|
||||
|
||||
num(x + y);
|
||||
|
||||
|
||||
str(x + y);
|
||||
|
||||
|
||||
str(x + x);
|
||||
|
||||
|
||||
str(z + y);
|
||||
}
|
||||
|
||||
|
@ -207,38 +207,39 @@ str(null + \"foo\");
|
|||
str(\"foo\" + undefined);
|
||||
|
||||
str(undefined + \"foo\");
|
||||
|
||||
let tests = [
|
||||
function(x: mixed, y: mixed) {
|
||||
x + y;
|
||||
|
||||
|
||||
x + 0;
|
||||
|
||||
|
||||
0 + x;
|
||||
|
||||
|
||||
x + \"\";
|
||||
|
||||
|
||||
\"\" + x;
|
||||
|
||||
|
||||
x + {};
|
||||
|
||||
|
||||
({}) + x;
|
||||
},
|
||||
function() {
|
||||
(1 + {}: number);
|
||||
|
||||
|
||||
({} + 1: number);
|
||||
|
||||
|
||||
(\"1\" + {}: string);
|
||||
|
||||
|
||||
({} + \"1\": string);
|
||||
},
|
||||
function(x: any, y: number, z: string) {
|
||||
(x + y: string);
|
||||
|
||||
|
||||
(y + x: string);
|
||||
|
||||
|
||||
(x + z: empty);
|
||||
|
||||
|
||||
(z + x: empty);
|
||||
}
|
||||
];
|
||||
|
@ -263,6 +264,7 @@ y **= 2; // error
|
|||
let x: number = 2 ** 3;
|
||||
|
||||
x **= 4;
|
||||
|
||||
let y: string = \"123\";
|
||||
|
||||
y **= 2;
|
||||
|
@ -333,9 +335,11 @@ function num(x: number) {}
|
|||
num(null * 1);
|
||||
|
||||
num(1 * null);
|
||||
|
||||
let x: number = 2 * 3;
|
||||
|
||||
x *= 4;
|
||||
|
||||
let y: string = \"123\";
|
||||
|
||||
y *= 2;
|
||||
|
@ -405,6 +409,7 @@ let tests = [
|
|||
\"foo\" < { foo: 1 };
|
||||
|
||||
({ foo: 1 }) < \"foo\";
|
||||
|
||||
var x = (null: ?number);
|
||||
|
||||
1 < x;
|
||||
|
@ -424,10 +429,11 @@ NaN < 1;
|
|||
1 < NaN;
|
||||
|
||||
NaN < NaN;
|
||||
|
||||
let tests = [
|
||||
function(x: any, y: number, z: string) {
|
||||
x > y;
|
||||
|
||||
|
||||
x > z;
|
||||
}
|
||||
];
|
||||
|
|
|
@ -49,6 +49,7 @@ function filterItems(items: Array<string | number>): Array<string | number> {
|
|||
}
|
||||
).filter(Boolean);
|
||||
}
|
||||
|
||||
const filteredItems = filterItems([ \"foo\", \"b\", 1, 2 ]);
|
||||
|
||||
console.log(filteredItems);
|
||||
|
|
|
@ -15,6 +15,7 @@ var C = [ 1, 2, 3 ];
|
|||
B.sort((a, b) => a - b);
|
||||
|
||||
C.sort((a, b) => a - b);
|
||||
|
||||
var x: Array<string> = [ \"1\", \"2\" ];
|
||||
var y: Array<string> = [ \"3\", ...x ];
|
||||
"
|
||||
|
|
|
@ -67,10 +67,12 @@ function from_test() {
|
|||
// error, string ~> number
|
||||
// error, string ~> number
|
||||
function foo(x: string) {}
|
||||
|
||||
var a = [ 0 ];
|
||||
var b = a.map(
|
||||
function(x) {
|
||||
foo(x);
|
||||
|
||||
return \"\" + x;
|
||||
}
|
||||
);
|
||||
|
@ -97,13 +99,14 @@ function reduce_test() {
|
|||
return previousValue + currentValue + array[index];
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
[ 0, 1, 2, 3, 4 ].reduce(
|
||||
function(previousValue, currentValue, index, array) {
|
||||
return previousValue + currentValue + array[index];
|
||||
},
|
||||
10
|
||||
);
|
||||
|
||||
var total = [ 0, 1, 2, 3 ].reduce(
|
||||
function(a, b) {
|
||||
return a + b;
|
||||
|
@ -114,9 +117,9 @@ function reduce_test() {
|
|||
return a.concat(b);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
[ \"\" ].reduce((acc, str) => acc * str.length);
|
||||
|
||||
|
||||
[ \"\" ].reduceRight((acc, str) => acc * str.length);
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ module.exports = \"arrays\";
|
|||
// for literals, composite element type is union of individuals
|
||||
// note: test both tuple and non-tuple inferred literals
|
||||
function foo(x: string) {}
|
||||
|
||||
var a = [];
|
||||
|
||||
a[0] = 1;
|
||||
|
@ -50,9 +51,11 @@ a[0] = 1;
|
|||
a[1] = \"...\";
|
||||
|
||||
foo(a[1]);
|
||||
|
||||
var y;
|
||||
|
||||
a.forEach(x => y = x);
|
||||
|
||||
var alittle: Array<?number> = [ 0, 1, 2, 3, null ];
|
||||
var abig: Array<?number> = [ 0, 1, 2, 3, 4, 5, 6, 8, null ];
|
||||
var abig2: Array<{ x: number; y: number }> = [
|
||||
|
|
|
@ -43,8 +43,9 @@ function selectBestEffortImageForWidth(
|
|||
maxWidth: number, images: Array<Image>
|
||||
): Image {
|
||||
var maxPixelWidth = maxWidth;
|
||||
|
||||
|
||||
images = images.sort((a, b) => a.width - b.width + \"\");
|
||||
|
||||
return images.find(image => image.width >= maxPixelWidth) ||
|
||||
images[images.length - 1];
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ async function f3(p: Promise<number>): Promise<number> {
|
|||
async function f4(p: Promise<number>): Promise<boolean> {
|
||||
return await p;
|
||||
}
|
||||
|
||||
var f5: () => Promise<number> = async () => await 1;
|
||||
class C {
|
||||
async m() {
|
||||
|
@ -172,6 +173,7 @@ var y = { async };
|
|||
async function f() {}
|
||||
|
||||
async function ft<T>(a: T) {}
|
||||
|
||||
class C {
|
||||
async m() {}
|
||||
async mt<T>(a: T) {}
|
||||
|
@ -187,6 +189,7 @@ var oz = { async async() {} };
|
|||
var x = { async: 5 };
|
||||
|
||||
console.log(x.async);
|
||||
|
||||
var async = 3;
|
||||
var y = { async };
|
||||
"
|
||||
|
@ -230,6 +233,7 @@ async function foo2(): Promise<string> {
|
|||
|
||||
async function foo3(): Promise<string> {
|
||||
function bar() {}
|
||||
|
||||
return bar();
|
||||
}
|
||||
"
|
||||
|
@ -322,7 +326,7 @@ function test1() {
|
|||
async function foo() {
|
||||
return 42;
|
||||
}
|
||||
|
||||
|
||||
async function bar() {
|
||||
var a = await foo();
|
||||
var b: number = a;
|
||||
|
@ -334,6 +338,7 @@ function test2() {
|
|||
async function voidoid1() {
|
||||
console.log(\"HEY\");
|
||||
}
|
||||
|
||||
var voidoid2: () => Promise<void> = voidoid1;
|
||||
var voidoid3: () => void = voidoid1;
|
||||
}
|
||||
|
@ -455,6 +460,7 @@ async function f() {
|
|||
async function ft<T>(a: T) {
|
||||
await 1;
|
||||
}
|
||||
|
||||
class C {
|
||||
async m() {
|
||||
await 1;
|
||||
|
@ -496,6 +502,7 @@ var oz = {
|
|||
var x = { await: 5 };
|
||||
|
||||
console.log(x.await);
|
||||
|
||||
var await = 3;
|
||||
var y = { await };
|
||||
"
|
||||
|
|
|
@ -33,7 +33,7 @@ async function* delegate_next() {
|
|||
async function* inner() {
|
||||
var x: void = yield;
|
||||
}
|
||||
|
||||
|
||||
yield* inner();
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ async function* delegate_yield() {
|
|||
async function* inner() {
|
||||
yield 0;
|
||||
}
|
||||
|
||||
|
||||
yield* inner();
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,7 @@ async function* delegate_return() {
|
|||
async function* inner() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var x: void = yield* inner();
|
||||
}
|
||||
"
|
||||
|
@ -225,6 +226,7 @@ async () => {
|
|||
async function* yield_return() {
|
||||
try {
|
||||
yield 0;
|
||||
|
||||
return;
|
||||
} catch (e) {
|
||||
yield e;
|
||||
|
|
|
@ -78,58 +78,58 @@ let tests = [
|
|||
let tests = [
|
||||
function() {
|
||||
\"foo\" in {};
|
||||
|
||||
|
||||
\"foo\" in { foo: null };
|
||||
|
||||
|
||||
0 in {};
|
||||
|
||||
|
||||
0 in { \"0\": null };
|
||||
},
|
||||
function() {
|
||||
\"foo\" in [];
|
||||
|
||||
|
||||
0 in [];
|
||||
|
||||
|
||||
\"length\" in [];
|
||||
},
|
||||
function() {
|
||||
\"foo\" in new String(\"bar\");
|
||||
|
||||
|
||||
\"foo\" in new Number(123);
|
||||
},
|
||||
function() {
|
||||
\"foo\" in 123;
|
||||
|
||||
|
||||
\"foo\" in \"bar\";
|
||||
|
||||
|
||||
\"foo\" in void 0;
|
||||
|
||||
|
||||
\"foo\" in null;
|
||||
},
|
||||
function() {
|
||||
null in {};
|
||||
|
||||
|
||||
void 0 in {};
|
||||
|
||||
|
||||
({}) in {};
|
||||
|
||||
|
||||
[] in {};
|
||||
|
||||
|
||||
false in [];
|
||||
},
|
||||
function() {
|
||||
if (\"foo\" in 123)
|
||||
{}
|
||||
|
||||
|
||||
if (!\"foo\" in {})
|
||||
{}
|
||||
|
||||
|
||||
if (!(\"foo\" in {}))
|
||||
{}
|
||||
},
|
||||
function(x: Object, y: mixed) {
|
||||
\"foo\" in x;
|
||||
|
||||
|
||||
\"foo\" in y;
|
||||
}
|
||||
];
|
||||
|
|
|
@ -57,12 +57,14 @@ x |= 0;
|
|||
x ^= 0;
|
||||
|
||||
x &= 0;
|
||||
|
||||
const { foo } = { foo: \"foo\" };
|
||||
const [ bar ] = [ \"bar\" ];
|
||||
|
||||
(foo: number);
|
||||
|
||||
(bar: number);
|
||||
|
||||
declare var bazzes: { baz: string }[];
|
||||
|
||||
for (const { baz } of bazzes) {
|
||||
|
@ -349,7 +351,7 @@ function type_var() {
|
|||
|
||||
function type_reassign() {
|
||||
type A = number;
|
||||
|
||||
|
||||
A = 42;
|
||||
}
|
||||
|
||||
|
@ -430,7 +432,7 @@ function const_var() {
|
|||
|
||||
function const_reassign() {
|
||||
const A = 0;
|
||||
|
||||
|
||||
A = 42;
|
||||
}
|
||||
|
||||
|
@ -461,15 +463,17 @@ function var_var() {
|
|||
|
||||
function function_toplevel() {
|
||||
function a() {}
|
||||
|
||||
|
||||
function a() {}
|
||||
|
||||
}
|
||||
|
||||
function function_block() {
|
||||
{
|
||||
function a() {}
|
||||
|
||||
|
||||
function a() {}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -664,8 +668,9 @@ function switch_scope(x: string) {
|
|||
function switch_scope2(x: number) {
|
||||
switch (x) {
|
||||
case 0:
|
||||
|
||||
|
||||
a = \"\";
|
||||
|
||||
break;
|
||||
case 1:
|
||||
var b = a;
|
||||
|
@ -674,14 +679,15 @@ function switch_scope2(x: number) {
|
|||
let a = \"\";
|
||||
break;
|
||||
case 3:
|
||||
|
||||
|
||||
a = \"\";
|
||||
|
||||
break;
|
||||
case 4:
|
||||
var c: string = a;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
a = \"\";
|
||||
}
|
||||
|
||||
|
@ -698,42 +704,42 @@ function try_scope() {
|
|||
|
||||
function for_scope_let() {
|
||||
let a: number = 0;
|
||||
|
||||
|
||||
for (let a = \"\"; ; )
|
||||
{}
|
||||
}
|
||||
|
||||
function for_scope_var() {
|
||||
var a: number = 0;
|
||||
|
||||
|
||||
for (var a = \"\"; ; )
|
||||
{}
|
||||
}
|
||||
|
||||
function for_in_scope_let(o: Object) {
|
||||
let a: number = 0;
|
||||
|
||||
|
||||
for (let a in o)
|
||||
{}
|
||||
}
|
||||
|
||||
function for_in_scope_var(o: Object) {
|
||||
var a: number = 0;
|
||||
|
||||
|
||||
for (var a in o)
|
||||
{}
|
||||
}
|
||||
|
||||
function for_of_scope_let(xs: string[]) {
|
||||
let a: number = 0;
|
||||
|
||||
|
||||
for (let a of xs)
|
||||
{}
|
||||
}
|
||||
|
||||
function for_of_scope_var(xs: string[]) {
|
||||
var a: number = 0;
|
||||
|
||||
|
||||
for (var a of xs)
|
||||
{}
|
||||
}
|
||||
|
@ -746,12 +752,12 @@ function default_param_1() {
|
|||
|
||||
function default_param_2() {
|
||||
let a = \"\";
|
||||
|
||||
|
||||
function f0(x = () => a): number {
|
||||
let a = 0;
|
||||
return x();
|
||||
}
|
||||
|
||||
|
||||
function f1(x = b): number {
|
||||
let b = 0;
|
||||
return x;
|
||||
|
@ -915,10 +921,12 @@ function f0() {
|
|||
|
||||
function f1(b) {
|
||||
x = 10;
|
||||
|
||||
let x = 0;
|
||||
|
||||
|
||||
if (b) {
|
||||
y = 10;
|
||||
|
||||
let y = 0;
|
||||
}
|
||||
}
|
||||
|
@ -935,13 +943,13 @@ function f3() {
|
|||
var s: string = foo();
|
||||
{
|
||||
var n: number = foo();
|
||||
|
||||
|
||||
function foo() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
var s2: string = foo();
|
||||
|
||||
|
||||
function foo() {
|
||||
return \"\";
|
||||
}
|
||||
|
@ -951,6 +959,7 @@ function f4() {
|
|||
function g() {
|
||||
return x + c;
|
||||
}
|
||||
|
||||
let x = 0;
|
||||
const c = 0;
|
||||
}
|
||||
|
@ -959,11 +968,13 @@ function f5() {
|
|||
function g() {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
g();
|
||||
|
||||
let x = 0;
|
||||
const c = 0;
|
||||
}
|
||||
|
||||
var x: C;
|
||||
var y = new C();
|
||||
class C {}
|
||||
|
|
|
@ -131,6 +131,7 @@ new FormData(\"\");
|
|||
new FormData(document.createElement(\"input\"));
|
||||
|
||||
new FormData(document.createElement(\"form\"));
|
||||
|
||||
const b: boolean = a.has(\"foo\");
|
||||
const c: ?(string | File) = a.get(\"foo\");
|
||||
const d: string = a.get(\"foo\");
|
||||
|
@ -138,6 +139,7 @@ const e: Blob = a.get(\"foo\");
|
|||
const f: ?(string | File | Blob) = a.get(\"foo\");
|
||||
|
||||
a.get(2);
|
||||
|
||||
const a1: Array<string | File> = a.getAll(\"foo\");
|
||||
const a2: Array<string | File | number> = a.getAll(\"foo\");
|
||||
const a3: Array<string | Blob | File> = a.getAll(\"foo\");
|
||||
|
@ -276,6 +278,7 @@ function callback(
|
|||
): void {
|
||||
return;
|
||||
}
|
||||
|
||||
const o: MutationObserver = new MutationObserver(callback);
|
||||
|
||||
new MutationObserver((arr: Array<MutationRecord>) => true);
|
||||
|
@ -287,6 +290,7 @@ new MutationObserver();
|
|||
new MutationObserver(42);
|
||||
|
||||
new MutationObserver((n: number) => {});
|
||||
|
||||
const div = document.createElement(\"div\");
|
||||
|
||||
o.observe(div, { attributes: true, attributeFilter: [ \"style\" ] });
|
||||
|
|
|
@ -56,6 +56,7 @@ function foo<T: number>(x: T): T {
|
|||
var y: string = x;
|
||||
return x;
|
||||
}
|
||||
|
||||
class C<T: number> {
|
||||
bar<U: number>(x: U): T {
|
||||
return x;
|
||||
|
@ -69,8 +70,10 @@ class C<T: number> {
|
|||
|
||||
function example<T: { x: number }>(o: T): T {
|
||||
o.x = 0;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
var obj1: { x: number; y: string } = example({ x: 0, y: \"\" });
|
||||
var obj2: { x: number } = example({ x: 0 });
|
||||
var c: C<string> = new C();
|
||||
|
|
|
@ -87,8 +87,10 @@ function foo(b) {
|
|||
while (b) {
|
||||
if (x == null) {
|
||||
z = \"\";
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
var y: number = x;
|
||||
}
|
||||
var w: number = z;
|
||||
|
@ -96,14 +98,16 @@ function foo(b) {
|
|||
|
||||
function bar(b) {
|
||||
var x = (b ? null : false);
|
||||
|
||||
|
||||
if (x == null)
|
||||
return;
|
||||
|
||||
switch (\"\") {
|
||||
case 0:
|
||||
var y: number = x;
|
||||
|
||||
|
||||
x = \"\";
|
||||
|
||||
case 1:
|
||||
var z: number = x;
|
||||
break;
|
||||
|
@ -114,14 +118,15 @@ function bar(b) {
|
|||
|
||||
function bar2(b) {
|
||||
var x = (b ? null : false);
|
||||
|
||||
|
||||
if (x == null)
|
||||
return;
|
||||
|
||||
switch (\"\") {
|
||||
case 0:
|
||||
{
|
||||
let y: number = x;
|
||||
|
||||
|
||||
x = \"\";
|
||||
}
|
||||
case 1:
|
||||
|
@ -138,12 +143,13 @@ function qux(b) {
|
|||
var z = 0;
|
||||
while (b) {
|
||||
var y: number = z;
|
||||
|
||||
|
||||
if (b) {
|
||||
z = \"\";
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
z = 0;
|
||||
}
|
||||
var w: number = z;
|
||||
|
@ -151,16 +157,17 @@ function qux(b) {
|
|||
|
||||
function test_const() {
|
||||
let st: string = \"abc\";
|
||||
|
||||
|
||||
for (let i = 1; i < 100; i++) {
|
||||
const fooRes: ?string = \"HEY\";
|
||||
|
||||
|
||||
if (!fooRes) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
st = fooRes;
|
||||
}
|
||||
|
||||
return st;
|
||||
}
|
||||
"
|
||||
|
|
|
@ -35,8 +35,10 @@ function f() {
|
|||
return \"...\";
|
||||
}
|
||||
);
|
||||
|
||||
var x: number = array[0];
|
||||
}
|
||||
|
||||
var Foo = require(\"./genericfoo\");
|
||||
var foo = new Foo();
|
||||
|
||||
|
@ -47,7 +49,7 @@ function g() {
|
|||
}
|
||||
);
|
||||
var x: number = foo1.get();
|
||||
|
||||
|
||||
foo = foo1;
|
||||
}
|
||||
"
|
||||
|
|
|
@ -226,6 +226,7 @@ function e(x: { (): string; (x: number): string }): () => number {
|
|||
function a(f: { (): string; (x: number): string }): string {
|
||||
return f() + f(123);
|
||||
}
|
||||
|
||||
var b: { (): string; (x: number): string } = function(x?: number): string {
|
||||
return \"hi\";
|
||||
};
|
||||
|
@ -263,6 +264,7 @@ var b: { apply: Function } = function() {};
|
|||
var f = function() {};
|
||||
|
||||
f.myProp = 123;
|
||||
|
||||
var c: { myProp: number } = f;
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -53,15 +53,18 @@ var x = Boolean(4);
|
|||
function foo(fn: (value: any) => boolean) {}
|
||||
|
||||
foo(Boolean);
|
||||
|
||||
var dict: { [k: string]: any } = {};
|
||||
|
||||
dict();
|
||||
|
||||
interface ICall { (x: string): void }
|
||||
declare var icall: ICall;
|
||||
|
||||
icall(0);
|
||||
|
||||
icall.call(null, 0);
|
||||
|
||||
type Callable = { (x: string): void };
|
||||
declare var callable: Callable;
|
||||
|
||||
|
|
|
@ -82,22 +82,23 @@ class A {
|
|||
}
|
||||
|
||||
A.qux = function(x: string) {};
|
||||
|
||||
class B extends A {
|
||||
static x: string;
|
||||
static foo(x: string) {}
|
||||
static main() {
|
||||
B.x = 0;
|
||||
|
||||
|
||||
B.x = \"\";
|
||||
|
||||
|
||||
B.foo(0);
|
||||
|
||||
|
||||
B.foo(\"\");
|
||||
|
||||
|
||||
B.y = 0;
|
||||
|
||||
|
||||
B.bar(0);
|
||||
|
||||
|
||||
B.qux(0);
|
||||
}
|
||||
static create(): A {
|
||||
|
@ -117,7 +118,7 @@ class C<X> {
|
|||
class D extends C<string> {
|
||||
static main() {
|
||||
D.foo(0);
|
||||
|
||||
|
||||
D.bar(0);
|
||||
}
|
||||
}
|
||||
|
@ -126,10 +127,12 @@ var d: C<*> = D.create();
|
|||
(new A(): typeof A);
|
||||
|
||||
(B: typeof A);
|
||||
|
||||
class E {
|
||||
static x: number;
|
||||
static foo(): string {
|
||||
this.bar();
|
||||
|
||||
return this.x;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,9 +68,11 @@ class C<X> {
|
|||
}
|
||||
|
||||
function foo<X>(c: C<X>, x: X) {}
|
||||
|
||||
type O = { f: number };
|
||||
|
||||
foo((new C(): C<O>), { f_: 0 });
|
||||
|
||||
class D extends C<O> {
|
||||
bar() {
|
||||
this.x;
|
||||
|
|
|
@ -18,6 +18,7 @@ class A {}
|
|||
function foo(x: Class<A>): A {
|
||||
return new x();
|
||||
}
|
||||
|
||||
class B {
|
||||
constructor(_: any) {}
|
||||
}
|
||||
|
|
|
@ -136,11 +136,13 @@ x.b;
|
|||
x.c;
|
||||
|
||||
x.d;
|
||||
|
||||
var y: Foo = x;
|
||||
|
||||
y.b;
|
||||
|
||||
y.d;
|
||||
|
||||
class Test2Superclass {
|
||||
a: number;
|
||||
c: ?number;
|
||||
|
@ -263,6 +265,7 @@ C.p = \"hi\";
|
|||
(C: { p: string });
|
||||
|
||||
(C: { p: number });
|
||||
|
||||
declare var o: { p: number };
|
||||
|
||||
(o: Class<C>);
|
||||
|
|
|
@ -105,6 +105,7 @@ function local_meth() {
|
|||
// error
|
||||
// shouldn\'t pollute linear refinement
|
||||
function takes_string(_: string) {}
|
||||
|
||||
var global_x = \"hello\";
|
||||
|
||||
function global_f() {}
|
||||
|
@ -125,23 +126,24 @@ global_x = 42;
|
|||
|
||||
function local_func() {
|
||||
var local_x = \"hello\";
|
||||
|
||||
|
||||
function local_f() {}
|
||||
|
||||
|
||||
function local_g() {
|
||||
local_x = 42;
|
||||
}
|
||||
|
||||
|
||||
local_f();
|
||||
|
||||
|
||||
takes_string(local_x);
|
||||
|
||||
|
||||
local_g();
|
||||
|
||||
|
||||
takes_string(local_x);
|
||||
|
||||
|
||||
local_x = 42;
|
||||
}
|
||||
|
||||
var global_y = \"hello\";
|
||||
var global_o = {
|
||||
f: function() {},
|
||||
|
@ -168,15 +170,15 @@ function local_meth() {
|
|||
local_y = 42;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
local_o.f();
|
||||
|
||||
|
||||
takes_string(local_y);
|
||||
|
||||
|
||||
local_o.g();
|
||||
|
||||
|
||||
takes_string(local_y);
|
||||
|
||||
|
||||
local_y = 42;
|
||||
}
|
||||
"
|
||||
|
@ -204,14 +206,15 @@ function example(b: bool): number {
|
|||
// error, string ~/~> number (return type anno) TODO
|
||||
function example(b: boolean): number {
|
||||
var x = 0;
|
||||
|
||||
|
||||
function f() {
|
||||
x = \"\";
|
||||
}
|
||||
|
||||
|
||||
if (b) {
|
||||
f();
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
"
|
||||
|
@ -285,26 +288,27 @@ var call_me: () => void = () => {};
|
|||
|
||||
function g(x: ?number) {
|
||||
const const_x = x;
|
||||
|
||||
|
||||
if (const_x) {
|
||||
call_me = () => {
|
||||
var y: number = const_x;
|
||||
};
|
||||
}
|
||||
|
||||
var var_x = x;
|
||||
|
||||
|
||||
if (var_x) {
|
||||
call_me = () => {
|
||||
var y: number = var_x;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
var_x = null;
|
||||
}
|
||||
|
||||
function h(x: number | string | boolean) {
|
||||
const const_x = x;
|
||||
|
||||
|
||||
if (typeof const_x == \"number\") {
|
||||
call_me = () => {
|
||||
var y: number = const_x;
|
||||
|
@ -320,8 +324,9 @@ function h(x: number | string | boolean) {
|
|||
var y: boolean = const_x;
|
||||
};
|
||||
}
|
||||
|
||||
var var_x = x;
|
||||
|
||||
|
||||
if (typeof var_x == \"number\") {
|
||||
call_me = () => {
|
||||
var y: number = var_x;
|
||||
|
|
|
@ -50,12 +50,13 @@ class A {
|
|||
}
|
||||
|
||||
A._sProperty = 48;
|
||||
|
||||
class B extends A {
|
||||
_property1: string;
|
||||
static _sProperty: string;
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
|
||||
this._property1 = \"another string\";
|
||||
}
|
||||
_method1(): string {
|
||||
|
|
|
@ -50,12 +50,13 @@ class A {
|
|||
}
|
||||
|
||||
A._sProperty = 48;
|
||||
|
||||
class B extends A {
|
||||
_property1: string;
|
||||
static _sProperty: string;
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
|
||||
this._property1 = \"another string\";
|
||||
}
|
||||
_method1(): string {
|
||||
|
|
|
@ -42,6 +42,7 @@ Foo.prototype = {
|
|||
};
|
||||
|
||||
exports.Foo = Foo;
|
||||
|
||||
interface IFooPrototype { m(): number }
|
||||
interface IFoo extends IFooPrototype {
|
||||
static (): void;
|
||||
|
|
|
@ -51,27 +51,28 @@ let tests = [
|
|||
let tests = [
|
||||
function() {
|
||||
new Boolean();
|
||||
|
||||
|
||||
new Boolean(0);
|
||||
|
||||
|
||||
new Boolean(-0);
|
||||
|
||||
|
||||
new Boolean(null);
|
||||
|
||||
|
||||
new Boolean(false);
|
||||
|
||||
|
||||
new Boolean(NaN);
|
||||
|
||||
|
||||
new Boolean(undefined);
|
||||
|
||||
|
||||
new Boolean(\"\");
|
||||
},
|
||||
function() {
|
||||
true.toString();
|
||||
|
||||
let x: boolean = false;
|
||||
|
||||
|
||||
x.toString();
|
||||
|
||||
|
||||
new Boolean(true).toString();
|
||||
},
|
||||
function() {
|
||||
|
@ -79,19 +80,19 @@ let tests = [
|
|||
},
|
||||
function() {
|
||||
Boolean();
|
||||
|
||||
|
||||
Boolean(0);
|
||||
|
||||
|
||||
Boolean(-0);
|
||||
|
||||
|
||||
Boolean(null);
|
||||
|
||||
|
||||
Boolean(false);
|
||||
|
||||
|
||||
Boolean(NaN);
|
||||
|
||||
|
||||
Boolean(undefined);
|
||||
|
||||
|
||||
Boolean(\"\");
|
||||
}
|
||||
];
|
||||
|
@ -145,6 +146,7 @@ function* generator(): Iterable<[string, number]> {
|
|||
yield [ \"foo\", 123 ];
|
||||
}
|
||||
}
|
||||
|
||||
let tests = [
|
||||
function() {
|
||||
let w = new Map();
|
||||
|
@ -161,7 +163,7 @@ let tests = [
|
|||
},
|
||||
function(x: Map<string, number>) {
|
||||
(x.get(\"foo\"): boolean);
|
||||
|
||||
|
||||
x.get(123);
|
||||
}
|
||||
];
|
||||
|
@ -212,33 +214,33 @@ let tests = [
|
|||
let tests = [
|
||||
function() {
|
||||
new RegExp(\"foo\");
|
||||
|
||||
|
||||
new RegExp(/foo/);
|
||||
|
||||
|
||||
new RegExp(\"foo\", \"i\");
|
||||
|
||||
|
||||
new RegExp(\"foo\", \"ig\");
|
||||
|
||||
|
||||
new RegExp(/foo/, \"i\");
|
||||
|
||||
|
||||
new RegExp(/foo/g, \"i\");
|
||||
},
|
||||
function() {
|
||||
RegExp(\"foo\");
|
||||
|
||||
|
||||
RegExp(/foo/);
|
||||
|
||||
|
||||
RegExp(\"foo\", \"i\");
|
||||
|
||||
|
||||
RegExp(\"foo\", \"ig\");
|
||||
|
||||
|
||||
RegExp(/foo/, \"i\");
|
||||
|
||||
|
||||
RegExp(/foo/g, \"i\");
|
||||
},
|
||||
function() {
|
||||
RegExp(\"foo\", \"z\");
|
||||
|
||||
|
||||
new RegExp(\"foo\", \"z\");
|
||||
}
|
||||
];
|
||||
|
@ -307,6 +309,7 @@ ws.delete(window);
|
|||
ws.delete(obj);
|
||||
|
||||
ws.delete(dict);
|
||||
|
||||
let ws2 = new WeakSet([ obj, dict ]);
|
||||
let ws3 = new WeakSet([ 1, 2, 3 ]);
|
||||
|
||||
|
@ -315,6 +318,7 @@ function* generator(): Iterable<{ foo: string }> {
|
|||
yield { foo: \"bar\" };
|
||||
}
|
||||
}
|
||||
|
||||
let ws4 = new WeakSet(generator());
|
||||
|
||||
function* numbers(): Iterable<number> {
|
||||
|
@ -323,6 +327,7 @@ function* numbers(): Iterable<number> {
|
|||
yield i++;
|
||||
}
|
||||
}
|
||||
|
||||
let ws5 = new WeakSet(numbers());
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -91,6 +91,7 @@ var b: CovArrayVerbose<number, *> = [];
|
|||
var y: CovArrayVerbose<mixed, *> = b;
|
||||
|
||||
y[0] = \"\";
|
||||
|
||||
class NVerbose<E, I: E> {
|
||||
x: CovArrayVerbose<E, I>;
|
||||
foo(): CovArrayVerbose<mixed, I> {
|
||||
|
|
|
@ -70,9 +70,11 @@ var ExplicitDifferentName = require(\'ExplicitProvidesModuleDifferentName\');
|
|||
var Implicit = require(\"ImplicitProvidesModule\");
|
||||
|
||||
(Implicit.fun(): string);
|
||||
|
||||
var ExplicitSameName = require(\"ExplicitProvidesModuleSameName\");
|
||||
|
||||
(ExplicitSameName.fun(): string);
|
||||
|
||||
var ExplicitDifferentName = require(\"ExplicitProvidesModuleDifferentName\");
|
||||
|
||||
(ExplicitDifferentName.fun(): string);
|
||||
|
|
|
@ -95,9 +95,11 @@ var ExplicitDifferentName = require(\'ExplicitProvidesModuleDifferentName\');
|
|||
var Implicit = require(\"ImplicitProvidesModule\");
|
||||
|
||||
(Implicit.fun(): boolean);
|
||||
|
||||
var ExplicitSameName = require(\"ExplicitProvidesModuleSameName\");
|
||||
|
||||
(ExplicitSameName.fun(): boolean);
|
||||
|
||||
var ExplicitDifferentName = require(\"ExplicitProvidesModuleDifferentName\");
|
||||
|
||||
(ExplicitDifferentName.fun(): boolean);
|
||||
|
|
|
@ -72,36 +72,47 @@ var F = require(\'package_with_dir_main\');
|
|||
var B1 = require(\"B\");
|
||||
|
||||
(B1.fun(): boolean);
|
||||
|
||||
var B2 = require(\"B.js\");
|
||||
|
||||
(B2.fun(): boolean);
|
||||
|
||||
var C = require(\"package_with_full_main\");
|
||||
|
||||
(C.fun(): boolean);
|
||||
|
||||
var D = require(\"package_with_partial_main\");
|
||||
|
||||
(D.fun(): boolean);
|
||||
|
||||
var E = require(\"package_with_no_package_json\");
|
||||
|
||||
(E.fun(): boolean);
|
||||
|
||||
var F = require(\"package_with_dir_main\");
|
||||
|
||||
(F.fun(): boolean);
|
||||
|
||||
var B1 = require(\"B\");
|
||||
|
||||
(B1.fun(): boolean);
|
||||
|
||||
var B2 = require(\"B.js\");
|
||||
|
||||
(B2.fun(): boolean);
|
||||
|
||||
var C = require(\"package_with_full_main\");
|
||||
|
||||
(C.fun(): boolean);
|
||||
|
||||
var D = require(\"package_with_partial_main\");
|
||||
|
||||
(D.fun(): boolean);
|
||||
|
||||
var E = require(\"package_with_no_package_json\");
|
||||
|
||||
(E.fun(): boolean);
|
||||
|
||||
var F = require(\"package_with_dir_main\");
|
||||
|
||||
(F.fun(): boolean);
|
||||
|
|
|
@ -52,18 +52,23 @@ var F = require(\'package_with_dir_main\');
|
|||
var B1 = require(\"B\");
|
||||
|
||||
(B1.fun(): string);
|
||||
|
||||
var B2 = require(\"B.js\");
|
||||
|
||||
(B2.fun(): string);
|
||||
|
||||
var C = require(\"package_with_full_main\");
|
||||
|
||||
(C.fun(): string);
|
||||
|
||||
var D = require(\"package_with_partial_main\");
|
||||
|
||||
(D.fun(): string);
|
||||
|
||||
var E = require(\"package_with_no_package_json\");
|
||||
|
||||
(E.fun(): string);
|
||||
|
||||
var F = require(\"package_with_dir_main\");
|
||||
|
||||
(F.fun(): string);
|
||||
|
@ -94,9 +99,11 @@ var CJS = require(\'./CJS.js\');
|
|||
var A1 = require(\"./A\");
|
||||
|
||||
(A1.fun(): string);
|
||||
|
||||
var A2 = require(\"./A.js\");
|
||||
|
||||
(A2.fun(): string);
|
||||
|
||||
var CJS = require(\"./CJS.js\");
|
||||
|
||||
(CJS: string);
|
||||
|
|
|
@ -992,11 +992,13 @@ var e1: number = CJS_Clobb_Lit.numberValue3;
|
|||
var e2: string = CJS_Clobb_Lit.numberValue3;
|
||||
|
||||
CJS_Clobb_Lit.doesntExist;
|
||||
|
||||
import * as CJS_Clobb_Lit_NS from \"CommonJS_Clobbering_Lit\";
|
||||
var f1: number = CJS_Clobb_Lit_NS.numberValue4;
|
||||
var f2: number = CJS_Clobb_Lit_NS.default.numberValue4;
|
||||
|
||||
CJS_Clobb_Lit_NS.default.default;
|
||||
|
||||
var f3: string = CJS_Clobb_Lit_NS.numberValue4;
|
||||
var f4: string = CJS_Clobb_Lit_NS.default.numberValue5;
|
||||
import { doesntExist2 } from \"CommonJS_Clobbering_Class\";
|
||||
|
@ -1006,6 +1008,7 @@ import CJS_Clobb_Class from \"CommonJS_Clobbering_Class\";
|
|||
new CJS_Clobb_Class();
|
||||
|
||||
new CJS_Clobb_Class().doesntExist;
|
||||
|
||||
var h1: number = CJS_Clobb_Class.staticNumber2();
|
||||
var h2: string = CJS_Clobb_Class.staticNumber2();
|
||||
var h3: number = new CJS_Clobb_Class().instNumber1();
|
||||
|
@ -1013,6 +1016,7 @@ var h4: string = new CJS_Clobb_Class().instNumber1();
|
|||
import * as CJS_Clobb_Class_NS from \"CommonJS_Clobbering_Class\";
|
||||
|
||||
new CJS_Clobb_Class_NS();
|
||||
|
||||
var i1: number = CJS_Clobb_Class_NS.staticNumber3();
|
||||
var i2: number = new CJS_Clobb_Class_NS.default().instNumber2();
|
||||
var i3: string = new CJS_Clobb_Class_NS.default().instNumber2();
|
||||
|
@ -1028,6 +1032,7 @@ var l1: number = CJS_Named.numberValue1;
|
|||
var l2: string = CJS_Named.numberValue1;
|
||||
|
||||
CJS_Named.doesntExist;
|
||||
|
||||
import * as CJS_Named_NS from \"CommonJS_Named\";
|
||||
var m1: number = CJS_Named_NS.numberValue4;
|
||||
var m2: string = CJS_Named_NS.default.numberValue4;
|
||||
|
@ -1079,6 +1084,7 @@ var ac1: number = numberValue5;
|
|||
var ac2: string = numberValue5;
|
||||
|
||||
require(\"ES6_Default_AnonFunction2\").doesntExist;
|
||||
|
||||
var ES6_Def_AnonFunc2 = require(\"ES6_Default_AnonFunction2\").default;
|
||||
var ad1: number = ES6_Def_AnonFunc2();
|
||||
var ad2: string = ES6_Def_AnonFunc2();
|
||||
|
|
|
@ -40,17 +40,20 @@ import declare_module_exports from \"declare_module_exports\";
|
|||
(declare_module_exports: number);
|
||||
|
||||
(declare_module_exports: string);
|
||||
|
||||
import { str } from \"declare_m_e_with_other_value_declares\";
|
||||
import type { str2 } from \"declare_m_e_with_other_type_declares\";
|
||||
|
||||
(\"asdf\": str2);
|
||||
|
||||
(42: str2);
|
||||
|
||||
import DEPRECATED__declare_var_exports from \"DEPRECATED__declare_var_exports\";
|
||||
|
||||
(DEPRECATED__declare_var_exports: number);
|
||||
|
||||
(DEPRECATED__declare_var_exports: string);
|
||||
|
||||
import declare_m_e_with_declare_var_e from \"declare_m_e_with_declare_var_e\";
|
||||
|
||||
(declare_m_e_with_declare_var_e: number);
|
||||
|
|
|
@ -58,9 +58,10 @@ class B extends A {}
|
|||
|
||||
function subtyping(v1: Variance<A, B>, v2: Variance<B, A>) {
|
||||
(v1: Variance<B, A>);
|
||||
|
||||
|
||||
(v2: Variance<A, B>);
|
||||
}
|
||||
|
||||
class PropVariance<+Out, -In> {
|
||||
inv1: Out;
|
||||
inv2: In;
|
||||
|
|
|
@ -13,6 +13,7 @@ f(x);
|
|||
function f(x) {
|
||||
return 42 / x;
|
||||
}
|
||||
|
||||
var x = null;
|
||||
|
||||
f(x);
|
||||
|
|
|
@ -37,6 +37,7 @@ class A {
|
|||
function callback(x: string) {
|
||||
return x.length;
|
||||
}
|
||||
|
||||
var a = new A(42);
|
||||
|
||||
a.onLoad(callback);
|
||||
|
|
|
@ -31,6 +31,7 @@ let d = zs[1];
|
|||
(c: void);
|
||||
|
||||
(d: void);
|
||||
|
||||
let [ ...e ] = 0;
|
||||
"
|
||||
`;
|
||||
|
@ -52,10 +53,12 @@ var { [\"key\"]: val3, ...spread } = { key: \"val\" };
|
|||
var { [\"key\"]: val1 } = { key: \"val\" };
|
||||
|
||||
(val1: void);
|
||||
|
||||
var key: string = \"key\";
|
||||
var { [key]: val2 } = { key: \"val\" };
|
||||
|
||||
(val2: void);
|
||||
|
||||
var { [\"key\"]: val3, ...spread } = { key: \"val\" };
|
||||
|
||||
(spread.key: void);
|
||||
|
@ -201,7 +204,7 @@ obj_prop_fun({ p: { q: null } });
|
|||
|
||||
function obj_prop_var(o = { p: { q: \"\" } }) {
|
||||
var { p: { q = 0 } = { q: true } } = o;
|
||||
|
||||
|
||||
(q: void);
|
||||
}
|
||||
|
||||
|
@ -230,6 +233,7 @@ obj_rest({ p: { q: 0, r: null } });
|
|||
function obj_prop_annot({ p = true }: { p: string } = { p: 0 }) {
|
||||
(p: void);
|
||||
}
|
||||
|
||||
var { p = true }: { p: string } = { p: 0 };
|
||||
|
||||
(p: void);
|
||||
|
@ -348,9 +352,11 @@ declare var b: string;
|
|||
declare var c: string;
|
||||
|
||||
[ { a1: a, b }, c ] = [ { a1: 0, b: 1 }, 2 ];
|
||||
|
||||
var { m } = { m: 0 };
|
||||
|
||||
({ m } = { m: m });
|
||||
|
||||
var obj;
|
||||
|
||||
({ n: obj.x } = { n: 3 });
|
||||
|
@ -359,9 +365,9 @@ var obj;
|
|||
|
||||
function foo({ p, z: [ r ] }) {
|
||||
a = p;
|
||||
|
||||
|
||||
b = z;
|
||||
|
||||
|
||||
c = r;
|
||||
}
|
||||
|
||||
|
@ -374,6 +380,7 @@ function bar({ x, ...z }) {
|
|||
}
|
||||
|
||||
bar({ x: \"\", y: 0 });
|
||||
|
||||
var spread = { y: \"\" };
|
||||
var extend: { x: number; y: string; z: boolean } = { x: 0, ...spread };
|
||||
|
||||
|
@ -384,6 +391,7 @@ qux({ a: \"\" });
|
|||
function corge({ b }: { b: string }) {}
|
||||
|
||||
corge({ b: 0 });
|
||||
|
||||
var { n }: { n: number } = { n: \"\" };
|
||||
|
||||
function test() {
|
||||
|
@ -394,13 +402,14 @@ function test() {
|
|||
function test() {
|
||||
var x = { foo: \"abc\", bar: 123 };
|
||||
var { foo, ...rest } = x;
|
||||
|
||||
|
||||
(x.baz: string);
|
||||
|
||||
|
||||
(rest.baz: string);
|
||||
}
|
||||
|
||||
module.exports = corge;
|
||||
|
||||
class Base {
|
||||
baseprop1: number;
|
||||
baseprop2: number;
|
||||
|
@ -507,16 +516,19 @@ function arr_rest_pattern<X>([ _, ...a ] : ArrRest<X>) { // a: [X]
|
|||
// a: [X]
|
||||
// a: [X]
|
||||
function obj_pattern<X>({ prop }: { prop: X }) {}
|
||||
|
||||
type Prop<X> = { prop: X };
|
||||
|
||||
function obj_pattern2<X>({ prop }: Prop<X>) {}
|
||||
|
||||
function arr_pattern<X>([ elem ]: X[]) {}
|
||||
|
||||
type Elem<X> = X[];
|
||||
|
||||
function arr_pattern2<X>([ elem ]: Elem<X>) {}
|
||||
|
||||
function tup_pattern<X>([ proj ]: [X]) {}
|
||||
|
||||
type Proj<X> = [X];
|
||||
|
||||
function tup_pattern2<X>([ proj ]: Proj<X>) {}
|
||||
|
@ -528,6 +540,7 @@ function rest_pattern<X>(...r: X[]) {}
|
|||
function obj_rest_pattern<X>({ _, ...o }: { _: any; x: X }) {
|
||||
o.x;
|
||||
}
|
||||
|
||||
type ObjRest<X> = { _: any; x: X };
|
||||
|
||||
function obj_rest_pattern<X>({ _, ...o }: ObjRest<X>) {
|
||||
|
@ -537,6 +550,7 @@ function obj_rest_pattern<X>({ _, ...o }: ObjRest<X>) {
|
|||
function arr_rest_pattern<X>([ _, ...a ]: [any, X]) {
|
||||
a[0];
|
||||
}
|
||||
|
||||
type ArrRest<X> = [any, X];
|
||||
|
||||
function arr_rest_pattern<X>([ _, ...a ]: ArrRest<X>) {
|
||||
|
@ -574,12 +588,14 @@ var { x: o } = o;
|
|||
let foo = (i: number) => [ i ];
|
||||
const bar = (i: number) => {
|
||||
[ i ] = foo(i);
|
||||
|
||||
return [ i ];
|
||||
};
|
||||
|
||||
foo = (i: number) => {
|
||||
return bar(i);
|
||||
};
|
||||
|
||||
declare var o;
|
||||
var { x: o } = o;
|
||||
"
|
||||
|
@ -597,6 +613,7 @@ var { \"with-dash\": with_dash } = { \"with-dash\": \"motivating example\" };
|
|||
var { \"key\": val } = { key: \"val\" };
|
||||
|
||||
(val: void);
|
||||
|
||||
var { \"with-dash\": with_dash } = { \"with-dash\": \"motivating example\" };
|
||||
|
||||
(with_dash: \"motivating example\");
|
||||
|
|
|
@ -38,6 +38,7 @@ function foo0(x: Array<{ [key: string]: mixed }>): Array<{
|
|||
[key: string]: mixed
|
||||
}> {
|
||||
x[0].fooBar = \"foobar\";
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -511,23 +512,23 @@ function set_prop_to_string_key(o: { [k: string]: any }) {
|
|||
|
||||
function unsound_dict_has_every_key(o: { [k: string]: X }) {
|
||||
(o.p: X);
|
||||
|
||||
|
||||
(o[\"p\"]: X);
|
||||
}
|
||||
|
||||
function set_prop_covariant(o: { [k: string]: B }) {
|
||||
o.p = new A();
|
||||
|
||||
|
||||
o.p = new B();
|
||||
|
||||
|
||||
o.p = new C();
|
||||
}
|
||||
|
||||
function get_prop_contravariant(o: { [k: string]: B }) {
|
||||
(o.p: A);
|
||||
|
||||
|
||||
(o.p: B);
|
||||
|
||||
|
||||
(o.p: C);
|
||||
}
|
||||
|
||||
|
@ -541,11 +542,11 @@ function add_prop_to_nonstring_key_bracket(o: { [k: number]: any }) {
|
|||
|
||||
function mix_with_declared_props(o: { [k: number]: X; p: Y }, x: X, y: Y) {
|
||||
(o[0]: X);
|
||||
|
||||
|
||||
(o.p: Y);
|
||||
|
||||
|
||||
o[0] = x;
|
||||
|
||||
|
||||
o.p = y;
|
||||
}
|
||||
|
||||
|
@ -554,6 +555,7 @@ function object_prototype(o: { [k: string]: number }): {
|
|||
+toString: () => string
|
||||
} {
|
||||
(o.toString(): boolean);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
@ -565,21 +567,23 @@ function unsound_string_conversion_alias_declared_prop(
|
|||
|
||||
function unification_dict_values_invariant(x: Array<{ [k: string]: B }>) {
|
||||
let a: Array<{ [k: string]: A }> = x;
|
||||
|
||||
|
||||
a[0].p = new A();
|
||||
|
||||
let b: Array<{ [k: string]: B }> = x;
|
||||
let c: Array<{ [k: string]: C }> = x;
|
||||
|
||||
|
||||
(x[0].p: C);
|
||||
}
|
||||
|
||||
function subtype_dict_values_invariant(x: { [k: string]: B }) {
|
||||
let a: { [k: string]: A } = x;
|
||||
|
||||
|
||||
a.p = new A();
|
||||
|
||||
let b: { [k: string]: B } = x;
|
||||
let c: { [k: string]: C } = x;
|
||||
|
||||
|
||||
(x.p: C);
|
||||
}
|
||||
|
||||
|
@ -605,11 +609,12 @@ function unification_mix_with_declared_props_invariant_l(
|
|||
x: Array<{ [k: string]: B }>
|
||||
) {
|
||||
let a: Array<{ [k: string]: B; p: A }> = x;
|
||||
|
||||
|
||||
a[0].p = new A();
|
||||
|
||||
let b: Array<{ [k: string]: B; p: B }> = x;
|
||||
let c: Array<{ [k: string]: B; p: C }> = x;
|
||||
|
||||
|
||||
(x[0].p: C);
|
||||
}
|
||||
|
||||
|
@ -619,21 +624,23 @@ function unification_mix_with_declared_props_invariant_r(
|
|||
xc: Array<{ [k: string]: C; p: B }>
|
||||
) {
|
||||
let a: Array<{ [k: string]: A }> = xa;
|
||||
|
||||
|
||||
a[0].p = new A();
|
||||
|
||||
let b: Array<{ [k: string]: B }> = xb;
|
||||
let c: Array<{ [k: string]: C }> = xc;
|
||||
|
||||
|
||||
(xc[0].p: C);
|
||||
}
|
||||
|
||||
function subtype_mix_with_declared_props_invariant_l(x: { [k: string]: B }) {
|
||||
let a: { [k: string]: B; p: A } = x;
|
||||
|
||||
|
||||
a.p = new A();
|
||||
|
||||
let b: { [k: string]: B; p: B } = x;
|
||||
let c: { [k: string]: B; p: C } = x;
|
||||
|
||||
|
||||
(x.p: C);
|
||||
}
|
||||
|
||||
|
@ -643,11 +650,12 @@ function subtype_mix_with_declared_props_invariant_r(
|
|||
xc: { [k: string]: C; p: B }
|
||||
) {
|
||||
let a: { [k: string]: A } = xa;
|
||||
|
||||
|
||||
a.p = new A();
|
||||
|
||||
let b: { [k: string]: B } = xb;
|
||||
let c: { [k: string]: C } = xc;
|
||||
|
||||
|
||||
(xc.p: C);
|
||||
}
|
||||
|
||||
|
@ -665,21 +673,23 @@ function unification_obj_to_dict(x: Array<{ p: X }>): Array<{
|
|||
|
||||
function subtype_dict_to_obj(x: { [k: string]: B }) {
|
||||
let a: { p: A } = x;
|
||||
|
||||
|
||||
a.p = new A();
|
||||
|
||||
let b: { p: B } = x;
|
||||
let c: { p: C } = x;
|
||||
|
||||
|
||||
(x.p: C);
|
||||
}
|
||||
|
||||
function subtype_obj_to_dict(x: { p: B }) {
|
||||
let a: { [k: string]: A } = x;
|
||||
|
||||
|
||||
a.p = new A();
|
||||
|
||||
let b: { [k: string]: B } = x;
|
||||
let c: { [k: string]: C } = x;
|
||||
|
||||
|
||||
(x.p: C);
|
||||
}
|
||||
|
||||
|
@ -825,6 +835,7 @@ function foo2(x: Array<{ [key: string]: mixed }>): Array<{
|
|||
fooBar: string
|
||||
}> {
|
||||
x[0].fooBar = 123;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -853,7 +864,7 @@ function foo7(x: { [key: string]: number; bar: string }) {
|
|||
|
||||
function foo8(x: { [key: string]: number }) {
|
||||
(x.foo: string);
|
||||
|
||||
|
||||
(x.foo: number);
|
||||
}
|
||||
"
|
||||
|
|
|
@ -230,6 +230,7 @@ function getBinaryOp(
|
|||
throw new Error(\"Invalid binary operator: \" + op);
|
||||
}
|
||||
}
|
||||
|
||||
export function emitExpression(node: TypedNode): t.Expression {
|
||||
switch (node.exprNodeType) {
|
||||
case \"string_literal\":
|
||||
|
|
|
@ -44,7 +44,7 @@ let tests = [
|
|||
let tests = [
|
||||
function(document: Document) {
|
||||
const event = document.createEvent(\"CustomEvent\");
|
||||
|
||||
|
||||
event.initCustomEvent(\"butts\", true, false, { nice: 42 });
|
||||
}
|
||||
];
|
||||
|
@ -69,11 +69,11 @@ let tests = [
|
|||
let tests = [
|
||||
function(document: Document) {
|
||||
(document.createElement(\"canvas\"): HTMLCanvasElement);
|
||||
|
||||
|
||||
(document.createElement(\"link\"): HTMLLinkElement);
|
||||
|
||||
|
||||
(document.createElement(\"option\"): HTMLOptionElement);
|
||||
|
||||
|
||||
(document.createElement(\"select\"): HTMLSelectElement);
|
||||
}
|
||||
];
|
||||
|
@ -106,21 +106,21 @@ let tests = [
|
|||
let tests = [
|
||||
function(element: Element) {
|
||||
element.scrollIntoView();
|
||||
|
||||
|
||||
element.scrollIntoView(false);
|
||||
|
||||
|
||||
element.scrollIntoView({});
|
||||
|
||||
|
||||
element.scrollIntoView({ behavior: \"smooth\", block: \"end\" });
|
||||
|
||||
|
||||
element.scrollIntoView({ block: \"end\" });
|
||||
|
||||
|
||||
element.scrollIntoView({ behavior: \"smooth\" });
|
||||
|
||||
|
||||
element.scrollIntoView({ behavior: \"invalid\" });
|
||||
|
||||
|
||||
element.scrollIntoView({ block: \"invalid\" });
|
||||
|
||||
|
||||
element.scrollIntoView(1);
|
||||
}
|
||||
];
|
||||
|
@ -173,21 +173,21 @@ let tests = [
|
|||
let tests = [
|
||||
function(element: HTMLElement) {
|
||||
element.scrollIntoView();
|
||||
|
||||
|
||||
element.scrollIntoView(false);
|
||||
|
||||
|
||||
element.scrollIntoView({});
|
||||
|
||||
|
||||
element.scrollIntoView({ behavior: \"smooth\", block: \"end\" });
|
||||
|
||||
|
||||
element.scrollIntoView({ block: \"end\" });
|
||||
|
||||
|
||||
element.scrollIntoView({ behavior: \"smooth\" });
|
||||
|
||||
|
||||
element.scrollIntoView({ behavior: \"invalid\" });
|
||||
|
||||
|
||||
element.scrollIntoView({ block: \"invalid\" });
|
||||
|
||||
|
||||
element.scrollIntoView(1);
|
||||
}
|
||||
];
|
||||
|
@ -215,13 +215,13 @@ let tests = [
|
|||
let tests = [
|
||||
function(el: HTMLInputElement) {
|
||||
el.setRangeText(\"foo\");
|
||||
|
||||
|
||||
el.setRangeText(\"foo\", 123);
|
||||
|
||||
|
||||
el.setRangeText(\"foo\", 123, 234);
|
||||
|
||||
|
||||
el.setRangeText(\"foo\", 123, 234, \"select\");
|
||||
|
||||
|
||||
el.setRangeText(\"foo\", 123, 234, \"bogus\");
|
||||
}
|
||||
];
|
||||
|
@ -326,16 +326,16 @@ let listener: EventListener = function(event: Event): void {};
|
|||
let tests = [
|
||||
function() {
|
||||
let target = new EventTarget();
|
||||
|
||||
|
||||
(target.attachEvent(\"foo\", listener): void);
|
||||
|
||||
|
||||
(target.attachEvent && target.attachEvent(\"foo\", listener): void);
|
||||
},
|
||||
function() {
|
||||
let target = new EventTarget();
|
||||
|
||||
|
||||
(target.detachEvent(\"foo\", listener): void);
|
||||
|
||||
|
||||
(target.detachEvent && target.detachEvent(\"foo\", listener): void);
|
||||
},
|
||||
function() {
|
||||
|
@ -368,11 +368,11 @@ let tests = [
|
|||
let tests = [
|
||||
function() {
|
||||
let path = new Path2D();
|
||||
|
||||
|
||||
(path.arcTo(0, 0, 0, 0, 10): void);
|
||||
|
||||
|
||||
(path.arcTo(0, 0, 0, 0, 10, 20, 5): void);
|
||||
|
||||
|
||||
(path.arcTo(0, 0, 0, 0, 10, \"20\", 5): void);
|
||||
}
|
||||
];
|
||||
|
@ -737,12 +737,12 @@ let tests = [
|
|||
},
|
||||
function() {
|
||||
document.createNodeIterator(document.body);
|
||||
|
||||
|
||||
document.createNodeIterator({});
|
||||
},
|
||||
function() {
|
||||
document.createTreeWalker(document.body);
|
||||
|
||||
|
||||
document.createTreeWalker({});
|
||||
},
|
||||
function() {
|
||||
|
@ -904,21 +904,21 @@ let tests = [
|
|||
-1,
|
||||
node => NodeFilter.FILTER_ACCEPT
|
||||
);
|
||||
|
||||
|
||||
document.createNodeIterator(document.body, -1, node => \"accept\");
|
||||
|
||||
|
||||
document.createNodeIterator(
|
||||
document.body,
|
||||
-1,
|
||||
{ accept: node => NodeFilter.FILTER_ACCEPT }
|
||||
);
|
||||
|
||||
|
||||
document.createNodeIterator(
|
||||
document.body,
|
||||
-1,
|
||||
{ accept: node => \"accept\" }
|
||||
);
|
||||
|
||||
|
||||
document.createNodeIterator(document.body, -1, {});
|
||||
},
|
||||
function() {
|
||||
|
@ -927,17 +927,17 @@ let tests = [
|
|||
-1,
|
||||
node => NodeFilter.FILTER_ACCEPT
|
||||
);
|
||||
|
||||
|
||||
document.createTreeWalker(document.body, -1, node => \"accept\");
|
||||
|
||||
|
||||
document.createTreeWalker(
|
||||
document.body,
|
||||
-1,
|
||||
{ accept: node => NodeFilter.FILTER_ACCEPT }
|
||||
);
|
||||
|
||||
|
||||
document.createTreeWalker(document.body, -1, { accept: node => \"accept\" });
|
||||
|
||||
|
||||
document.createTreeWalker(document.body, -1, {});
|
||||
}
|
||||
];
|
||||
|
|
|
@ -46,11 +46,13 @@ var num = require(\"./import\");
|
|||
function foo(x) {}
|
||||
|
||||
foo(0);
|
||||
|
||||
var a: string = num;
|
||||
|
||||
function unannotated(x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
const nullToUndefined = val => (val === null ? undefined : val);
|
||||
|
||||
function f0(x: ?Object) {
|
||||
|
@ -68,6 +70,7 @@ function f2(x: ?string) {
|
|||
function f3(x: ?string) {
|
||||
return nullToUndefined(x);
|
||||
}
|
||||
|
||||
declare var idx: $Facebookism$Idx;
|
||||
declare var obj: { a?: { b: ?{ c: null | { d: number } } } };
|
||||
const idxResult = idx(obj, obj => obj.a.b.c.d);
|
||||
|
|
|
@ -41,6 +41,7 @@ class C1 {
|
|||
}
|
||||
|
||||
new C1().m();
|
||||
|
||||
class C2 {
|
||||
get m() {
|
||||
return 42;
|
||||
|
@ -49,12 +50,14 @@ class C2 {
|
|||
}
|
||||
|
||||
new C2().m();
|
||||
|
||||
class C3 {
|
||||
set m(x) {}
|
||||
m() {}
|
||||
}
|
||||
|
||||
new C3().m();
|
||||
|
||||
class C4 {
|
||||
get m() {
|
||||
return 42;
|
||||
|
@ -63,6 +66,7 @@ class C4 {
|
|||
}
|
||||
|
||||
new C4().m = new C4().m - 42;
|
||||
|
||||
class C5 {
|
||||
m() {}
|
||||
get m() {
|
||||
|
|
|
@ -28,11 +28,13 @@ function tag(strings, ...values) {
|
|||
var x: number = strings[0];
|
||||
return x;
|
||||
}
|
||||
|
||||
var s2 = tag\`l\${42}r\`;
|
||||
|
||||
function tag2(strings, ...values) {
|
||||
return { foo: \"\" };
|
||||
}
|
||||
|
||||
var s3 = tag2\`la la la\`;
|
||||
|
||||
(s3.foo: number);
|
||||
|
|
|
@ -36,6 +36,7 @@ function isActive(
|
|||
}
|
||||
|
||||
isActive({ state: \"PAUSE\" });
|
||||
|
||||
var MyStates = { PAUSED: \"PAUSED\", ACTIVE: \"ACTIVE\", DELETED: \"DELETED\" };
|
||||
|
||||
function isActive2(ad: { state: $Keys<typeof MyStates> }): boolean {
|
||||
|
@ -43,6 +44,7 @@ function isActive2(ad: { state: $Keys<typeof MyStates> }): boolean {
|
|||
}
|
||||
|
||||
isActive2({ state: \"PAUSE\" });
|
||||
|
||||
type Keys = $Keys<{ x: any; y: any }>;
|
||||
type Union = \"x\" | \"y\";
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ null == 1;
|
|||
1 == \"\";
|
||||
|
||||
\"\" == 1;
|
||||
|
||||
var x = (null: ?number);
|
||||
|
||||
x == 1;
|
||||
|
|
|
@ -1102,11 +1102,13 @@ var e1: number = CJS_Clobb_Lit.numberValue3;
|
|||
var e2: string = CJS_Clobb_Lit.numberValue3;
|
||||
|
||||
CJS_Clobb_Lit.doesntExist;
|
||||
|
||||
import * as CJS_Clobb_Lit_NS from \"CommonJS_Clobbering_Lit\";
|
||||
var f1: number = CJS_Clobb_Lit_NS.numberValue4;
|
||||
var f2: number = CJS_Clobb_Lit_NS.default.numberValue4;
|
||||
|
||||
CJS_Clobb_Lit_NS.default.default;
|
||||
|
||||
var f3: string = CJS_Clobb_Lit_NS.numberValue4;
|
||||
var f4: string = CJS_Clobb_Lit_NS.default.numberValue5;
|
||||
import { doesntExist2 } from \"CommonJS_Clobbering_Class\";
|
||||
|
@ -1116,6 +1118,7 @@ import CJS_Clobb_Class from \"CommonJS_Clobbering_Class\";
|
|||
new CJS_Clobb_Class();
|
||||
|
||||
new CJS_Clobb_Class().doesntExist;
|
||||
|
||||
var h1: number = CJS_Clobb_Class.staticNumber2();
|
||||
var h2: string = CJS_Clobb_Class.staticNumber2();
|
||||
var h3: number = new CJS_Clobb_Class().instNumber1();
|
||||
|
@ -1123,6 +1126,7 @@ var h4: string = new CJS_Clobb_Class().instNumber1();
|
|||
import * as CJS_Clobb_Class_NS from \"CommonJS_Clobbering_Class\";
|
||||
|
||||
new CJS_Clobb_Class_NS();
|
||||
|
||||
var i1: number = CJS_Clobb_Class_NS.staticNumber3();
|
||||
var i2: number = new CJS_Clobb_Class_NS.default().instNumber2();
|
||||
var i3: string = new CJS_Clobb_Class_NS.default().instNumber2();
|
||||
|
@ -1138,6 +1142,7 @@ var l1: number = CJS_Named.numberValue1;
|
|||
var l2: string = CJS_Named.numberValue1;
|
||||
|
||||
CJS_Named.doesntExist;
|
||||
|
||||
import * as CJS_Named_NS from \"CommonJS_Named\";
|
||||
var m1: number = CJS_Named_NS.numberValue4;
|
||||
var m2: string = CJS_Named_NS.default.numberValue4;
|
||||
|
@ -1198,6 +1203,7 @@ var ac1: number = numberValue5;
|
|||
var ac2: string = numberValue5;
|
||||
|
||||
require(\"ES6_Default_AnonFunction2\").doesntExist;
|
||||
|
||||
var ES6_Def_AnonFunc2 = require(\"ES6_Default_AnonFunction2\").default;
|
||||
var ad1: number = ES6_Def_AnonFunc2();
|
||||
var ad2: string = ES6_Def_AnonFunc2();
|
||||
|
@ -1352,38 +1358,46 @@ function testRequires() {
|
|||
import * as DefaultA from \"A\";
|
||||
|
||||
DefaultA.numberValue1 = 123;
|
||||
|
||||
import * as ES6_Named1 from \"ES6_Named1\";
|
||||
|
||||
ES6_Named1.varDeclNumber1 = 123;
|
||||
|
||||
import * as CommonJS_Star from \"CommonJS_Clobbering_Lit\";
|
||||
|
||||
CommonJS_Star.numberValue1 = 123;
|
||||
|
||||
CommonJS_Star.default.numberValue1 = 123;
|
||||
|
||||
import CommonJS_Clobbering_Lit from \"CommonJS_Clobbering_Lit\";
|
||||
|
||||
CommonJS_Clobbering_Lit.numberValue1 = 123;
|
||||
|
||||
import * as CommonJS_Frozen_Star from \"CommonJS_Clobbering_Frozen\";
|
||||
|
||||
CommonJS_Frozen_Star.numberValue1 = 123;
|
||||
|
||||
CommonJS_Frozen_Star.default.numberValue1 = 123;
|
||||
|
||||
import CommonJS_Clobbering_Frozen from \"CommonJS_Clobbering_Frozen\";
|
||||
|
||||
CommonJS_Clobbering_Frozen.numberValue1 = 123;
|
||||
|
||||
function testRequires() {
|
||||
var DefaultA = require(\"A\");
|
||||
|
||||
|
||||
DefaultA.numberValue1 = 123;
|
||||
|
||||
var ES6_Named1 = require(\"ES6_Named1\");
|
||||
|
||||
|
||||
ES6_Named1.numberValue = 123;
|
||||
|
||||
var CommonJS_Star = require(\"CommonJS_Clobbering_Lit\");
|
||||
|
||||
|
||||
CommonJS_Star.numberValue1 = 123;
|
||||
|
||||
var CommonJS_Frozen_Star = require(\"CommonJS_Clobbering_Frozen\");
|
||||
|
||||
|
||||
CommonJS_Frozen_Star.numberValue1 = 123;
|
||||
}
|
||||
"
|
||||
|
|
|
@ -70,28 +70,33 @@ import CJS_Named from \"CJS_Named\";
|
|||
(CJS_Named: { num1: number; str1: string });
|
||||
|
||||
(CJS_Named: number);
|
||||
|
||||
import { num2 } from \"CJS_Clobbered\";
|
||||
import { numExport } from \"CJS_Clobbered\";
|
||||
|
||||
(numExport: number);
|
||||
|
||||
(numExport: string);
|
||||
|
||||
import type { numType } from \"CJS_Clobbered\";
|
||||
|
||||
(42: numType);
|
||||
|
||||
(\"asdf\": numType);
|
||||
|
||||
import { strHidden } from \"ES\";
|
||||
import { str3 } from \"ES\";
|
||||
|
||||
(str3: string);
|
||||
|
||||
(str3: number);
|
||||
|
||||
import { num3 } from \"ES\";
|
||||
|
||||
(num3: number);
|
||||
|
||||
(num3: string);
|
||||
|
||||
import { C } from \"ES\";
|
||||
import type { C as CType } from \"ES\";
|
||||
|
||||
|
@ -102,12 +107,14 @@ import type { C as CType } from \"ES\";
|
|||
(new C(): CType);
|
||||
|
||||
(42: CType);
|
||||
|
||||
import { T } from \"ES\";
|
||||
import type { T as T2 } from \"ES\";
|
||||
|
||||
(42: T2);
|
||||
|
||||
(\"asdf\": T2);
|
||||
|
||||
import { exports as nope } from \"ES\";
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -20,9 +20,11 @@ var M = require(\"M\");
|
|||
var N = require(\"N\");
|
||||
|
||||
N.x = M(N.x);
|
||||
|
||||
var P = require(\"./P\");
|
||||
|
||||
N.y = P(N.y);
|
||||
|
||||
var Q = require(\"Q\");
|
||||
|
||||
N.z = Q(N.z);
|
||||
|
|
|
@ -63,9 +63,9 @@ let tests = [
|
|||
},
|
||||
function(copyProperties: Object$Assign) {
|
||||
let result = {};
|
||||
|
||||
|
||||
result.baz = false;
|
||||
|
||||
|
||||
(copyProperties(result, { foo: \"a\" }, { bar: 123 }): {
|
||||
foo: string;
|
||||
bar: number;
|
||||
|
@ -76,17 +76,17 @@ let tests = [
|
|||
const copyProperties = require(\"copyProperties\");
|
||||
let x = { foo: \"a\" };
|
||||
let y = { bar: 123 };
|
||||
|
||||
|
||||
(copyProperties({}, x, y): { foo: string; bar: number });
|
||||
},
|
||||
function(copyProperties: Object$Assign) {
|
||||
copyProperties();
|
||||
|
||||
|
||||
(copyProperties({ foo: \"a\" }): { foo: number });
|
||||
},
|
||||
function(copyProperties: Object$Assign) {
|
||||
function x(cb: Function) {}
|
||||
|
||||
|
||||
x(copyProperties);
|
||||
}
|
||||
];
|
||||
|
@ -114,14 +114,14 @@ let tests = [
|
|||
let tests = [
|
||||
function() {
|
||||
let x: ?string = null;
|
||||
|
||||
|
||||
invariant(x, \"truthy only\");
|
||||
},
|
||||
function(invariant: Function) {
|
||||
let x: ?string = null;
|
||||
|
||||
|
||||
invariant(x);
|
||||
|
||||
|
||||
(x: string);
|
||||
}
|
||||
];
|
||||
|
@ -202,17 +202,17 @@ let tests = [
|
|||
},
|
||||
function(mergeInto: $Facebookism$MergeInto) {
|
||||
let result = {};
|
||||
|
||||
|
||||
result.baz = false;
|
||||
|
||||
|
||||
(mergeInto(result, { foo: \"a\" }, { bar: 123 }): void);
|
||||
|
||||
|
||||
(result: { foo: string; bar: number; baz: boolean });
|
||||
},
|
||||
function() {
|
||||
const mergeInto = require(\"mergeInto\");
|
||||
let result: { foo?: string; bar?: number; baz: boolean } = { baz: false };
|
||||
|
||||
|
||||
(mergeInto(result, { foo: \"a\" }, { bar: 123 }): void);
|
||||
},
|
||||
function(mergeInto: $Facebookism$MergeInto) {
|
||||
|
@ -220,7 +220,7 @@ let tests = [
|
|||
},
|
||||
function(mergeInto: $Facebookism$MergeInto) {
|
||||
function x(cb: Function) {}
|
||||
|
||||
|
||||
x(mergeInto);
|
||||
}
|
||||
];
|
||||
|
@ -243,7 +243,7 @@ var mixin = require(\"mixin\");
|
|||
class Foo extends mixin(Bar) {
|
||||
m() {
|
||||
var x: string = this.x;
|
||||
|
||||
|
||||
this.y = \"\";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,6 +110,7 @@ e.set(\"Content-Type\", \"image/jpeg\");
|
|||
e.set(\"Content-Type\");
|
||||
|
||||
e.set({ \"Content-Type\", \"image/jpeg\" });
|
||||
|
||||
const f: Headers = e.append(\"Content-Type\", \"image/jpeg\");
|
||||
const g: string = e.get(\"Content-Type\");
|
||||
const h: number = e.get(\"Content-Type\");
|
||||
|
@ -412,6 +413,7 @@ e.set(\"key1\", \"value1\");
|
|||
e.set(\"key1\");
|
||||
|
||||
e.set({ \"key1\", \"value1\" });
|
||||
|
||||
const f: URLSearchParams = e.append(\"key1\", \"value1\");
|
||||
const g: string = e.get(\"key1\");
|
||||
const h: number = e.get(\"key1\");
|
||||
|
|
|
@ -14,6 +14,7 @@ import x from \'./req\';
|
|||
var x = require(\"./req\");
|
||||
|
||||
(x: string);
|
||||
|
||||
import x from \"./req\";
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -62,11 +62,13 @@ function mk_factorial() {
|
|||
if (eq(n, 1)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return mul(factorial(sub(n, 1)), n);
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
var factorial = mk_factorial();
|
||||
|
||||
factorial(\"...\");
|
||||
|
@ -103,7 +105,7 @@ function Y(f) {
|
|||
function g(x) {
|
||||
return f(x(x));
|
||||
}
|
||||
|
||||
|
||||
g(g);
|
||||
}
|
||||
|
||||
|
@ -111,6 +113,7 @@ function func1(f) {
|
|||
function fix_f(x: number): number {
|
||||
return f(x);
|
||||
}
|
||||
|
||||
return fix_f;
|
||||
}
|
||||
|
||||
|
@ -118,6 +121,7 @@ function func2(f) {
|
|||
function fix_f(x: string): string {
|
||||
return f(x);
|
||||
}
|
||||
|
||||
return fix_f;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,34 +50,35 @@ function corge(x: boolean) {
|
|||
/* @flow */
|
||||
function foo(x: boolean) {
|
||||
var max = 10;
|
||||
|
||||
|
||||
for (var ii = 0; ii < max; ii++) {
|
||||
if (x) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
function bar(x: boolean) {
|
||||
var max = 0;
|
||||
|
||||
|
||||
for (var ii = 0; ii < max; ii++) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
function baz(x: boolean) {
|
||||
var max = 0;
|
||||
|
||||
|
||||
for (var ii = 0; ii < max; ii++) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
|
@ -89,20 +90,20 @@ function bliffl(x: boolean) {
|
|||
for (var jj = 0; jj < max; jj++) {
|
||||
break loop1;
|
||||
}
|
||||
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
function corge(x: boolean) {
|
||||
var max = 0;
|
||||
|
||||
|
||||
for (var ii = 0; ii < max; ii++) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
"
|
||||
|
@ -154,14 +155,15 @@ function corge(x: boolean) {
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
function foo(x: boolean) {
|
||||
var obj = { a: 1, b: 2 };
|
||||
|
||||
|
||||
for (var prop in obj) {
|
||||
if (x) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
|
@ -169,7 +171,7 @@ function bar(x: boolean) {
|
|||
for (var prop in {}) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
|
@ -177,7 +179,7 @@ function baz(x: boolean) {
|
|||
for (var prop in {}) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
|
@ -189,10 +191,10 @@ function bliffl(x: boolean) {
|
|||
for (var prop2 in obj) {
|
||||
break loop1;
|
||||
}
|
||||
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
|
@ -200,7 +202,7 @@ function corge(x: boolean) {
|
|||
for (var prop in {}) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
"
|
||||
|
@ -252,14 +254,15 @@ function corge(x: boolean) {
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
function foo(x: boolean) {
|
||||
var arr = [ 1, 2, 3 ];
|
||||
|
||||
|
||||
for (var elem of arr) {
|
||||
if (x) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
|
@ -267,7 +270,7 @@ function bar(x: boolean) {
|
|||
for (var elem of []) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
|
@ -275,7 +278,7 @@ function baz(x: boolean) {
|
|||
for (var elem of []) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
|
@ -287,10 +290,10 @@ function bliffl(x: boolean) {
|
|||
for (var elem of arr) {
|
||||
break loop1;
|
||||
}
|
||||
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
|
||||
|
@ -298,7 +301,7 @@ function corge(x: boolean) {
|
|||
for (var elem of []) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
console.log(\"this is still reachable\");
|
||||
}
|
||||
"
|
||||
|
|
|
@ -91,7 +91,7 @@ function testString(str: string): void {
|
|||
function testMap1(map: Map<string, number>): void {
|
||||
for (var elem of map) {
|
||||
(elem: [string, number]);
|
||||
|
||||
|
||||
(elem: number);
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ function testMap1(map: Map<string, number>): void {
|
|||
function testMap2(map: Map<*, *>): void {
|
||||
for (var elem of map) {
|
||||
(elem: [number, string]);
|
||||
|
||||
|
||||
(elem: number);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,9 +123,9 @@ let tests = [
|
|||
let tests = [
|
||||
function(x: (a: string, b: string) => void) {
|
||||
let y = x.bind(x, \"foo\");
|
||||
|
||||
|
||||
y(\"bar\");
|
||||
|
||||
|
||||
y(123);
|
||||
}
|
||||
];
|
||||
|
@ -325,19 +325,21 @@ var c: Function = C;
|
|||
|
||||
function good(x: Function, MyThing: Function): number {
|
||||
var o: Object = x;
|
||||
|
||||
|
||||
x.foo = 123;
|
||||
|
||||
|
||||
x[\"foo\"] = 456;
|
||||
|
||||
|
||||
x();
|
||||
|
||||
|
||||
<MyThing/>;
|
||||
|
||||
var { ...something } = x;
|
||||
|
||||
|
||||
Object.assign(x, { hi: \"there\" });
|
||||
|
||||
|
||||
Object.keys(x);
|
||||
|
||||
return x.bar + x[\"bar\"] + x.lala();
|
||||
}
|
||||
|
||||
|
@ -346,39 +348,40 @@ function bad(x: Function, y: Object): void {
|
|||
var b: string = x;
|
||||
var c: Function = y;
|
||||
}
|
||||
|
||||
let tests = [
|
||||
function(y: () => void, z: Function) {
|
||||
function x() {}
|
||||
|
||||
|
||||
(x.length: void);
|
||||
|
||||
|
||||
(y.length: void);
|
||||
|
||||
|
||||
(z.length: void);
|
||||
|
||||
|
||||
(x.name: void);
|
||||
|
||||
|
||||
(y.name: void);
|
||||
|
||||
|
||||
(z.name: void);
|
||||
},
|
||||
function(y: () => void, z: Function) {
|
||||
function x() {}
|
||||
|
||||
|
||||
x.length = \"foo\";
|
||||
|
||||
|
||||
y.length = \"foo\";
|
||||
|
||||
|
||||
z.length = \"foo\";
|
||||
|
||||
|
||||
x.name = 123;
|
||||
|
||||
|
||||
y.name = 123;
|
||||
|
||||
|
||||
z.name = 123;
|
||||
|
||||
|
||||
(z.foo: number);
|
||||
|
||||
|
||||
(z.foo: string);
|
||||
}
|
||||
];
|
||||
|
|
|
@ -151,17 +151,18 @@ for (var x of examples.delegate_yield_iterable([])) {
|
|||
class GeneratorExamples {
|
||||
*stmt_yield(): Generator<number, void, void> {
|
||||
yield 0;
|
||||
|
||||
|
||||
yield \"\";
|
||||
}
|
||||
*stmt_next(): Generator<void, void, number> {
|
||||
var a = yield;
|
||||
|
||||
|
||||
if (a) {
|
||||
(a: number);
|
||||
}
|
||||
|
||||
var b = yield;
|
||||
|
||||
|
||||
if (b) {
|
||||
(b: string);
|
||||
}
|
||||
|
@ -178,7 +179,7 @@ class GeneratorExamples {
|
|||
}
|
||||
*widen_next() {
|
||||
var x = yield 0;
|
||||
|
||||
|
||||
if (typeof x === \"number\")
|
||||
{}
|
||||
else
|
||||
|
@ -190,29 +191,30 @@ else {
|
|||
}
|
||||
*widen_yield() {
|
||||
yield 0;
|
||||
|
||||
|
||||
yield \"\";
|
||||
|
||||
|
||||
yield true;
|
||||
}
|
||||
*delegate_next_generator() {
|
||||
function* inner() {
|
||||
var x: number = yield;
|
||||
}
|
||||
|
||||
|
||||
yield* inner();
|
||||
}
|
||||
*delegate_yield_generator() {
|
||||
function* inner() {
|
||||
yield \"\";
|
||||
}
|
||||
|
||||
|
||||
yield* inner();
|
||||
}
|
||||
*delegate_return_generator() {
|
||||
function* inner() {
|
||||
return \"\";
|
||||
}
|
||||
|
||||
var x: number = yield* inner();
|
||||
}
|
||||
*delegate_next_iterable(xs: Array<number>) {
|
||||
|
@ -239,6 +241,7 @@ var examples = new GeneratorExamples();
|
|||
for (var x of examples.infer_stmt()) {
|
||||
(x: string);
|
||||
}
|
||||
|
||||
var infer_stmt_next = examples.infer_stmt().next(0).value;
|
||||
|
||||
if (typeof infer_stmt_next === \"undefined\")
|
||||
|
@ -319,6 +322,7 @@ var examples = new GeneratorExamples();
|
|||
for (var x of examples.infer_stmt()) {
|
||||
(x: string);
|
||||
}
|
||||
|
||||
var infer_stmt_next = examples.infer_stmt().next(0).value;
|
||||
|
||||
if (typeof infer_stmt_next === \"undefined\")
|
||||
|
@ -484,18 +488,19 @@ if (multiple_return_result.done) {
|
|||
// error: number|string ~> void
|
||||
function* stmt_yield(): Generator<number, void, void> {
|
||||
yield 0;
|
||||
|
||||
|
||||
yield \"\";
|
||||
}
|
||||
|
||||
function* stmt_next(): Generator<void, void, number> {
|
||||
var a = yield;
|
||||
|
||||
|
||||
if (a) {
|
||||
(a: number);
|
||||
}
|
||||
|
||||
var b = yield;
|
||||
|
||||
|
||||
if (b) {
|
||||
(b: string);
|
||||
}
|
||||
|
@ -517,6 +522,7 @@ function* infer_stmt() {
|
|||
for (var x of infer_stmt()) {
|
||||
(x: string);
|
||||
}
|
||||
|
||||
var infer_stmt_next = infer_stmt().next(0).value;
|
||||
|
||||
if (typeof infer_stmt_next === \"undefined\")
|
||||
|
@ -530,7 +536,7 @@ else {
|
|||
|
||||
function* widen_next() {
|
||||
var x = yield 0;
|
||||
|
||||
|
||||
if (typeof x === \"number\")
|
||||
{}
|
||||
else
|
||||
|
@ -549,9 +555,9 @@ widen_next().next(true);
|
|||
|
||||
function* widen_yield() {
|
||||
yield 0;
|
||||
|
||||
|
||||
yield \"\";
|
||||
|
||||
|
||||
yield true;
|
||||
}
|
||||
|
||||
|
@ -570,7 +576,7 @@ function* delegate_next_generator() {
|
|||
function* inner() {
|
||||
var x: number = yield;
|
||||
}
|
||||
|
||||
|
||||
yield* inner();
|
||||
}
|
||||
|
||||
|
@ -580,7 +586,7 @@ function* delegate_yield_generator() {
|
|||
function* inner() {
|
||||
yield \"\";
|
||||
}
|
||||
|
||||
|
||||
yield* inner();
|
||||
}
|
||||
|
||||
|
@ -592,6 +598,7 @@ function* delegate_return_generator() {
|
|||
function* inner() {
|
||||
return \"\";
|
||||
}
|
||||
|
||||
var x: number = yield* inner();
|
||||
}
|
||||
|
||||
|
@ -632,6 +639,7 @@ function* multiple_return(b) {
|
|||
return \"foo\";
|
||||
}
|
||||
}
|
||||
|
||||
let multiple_return_result = multiple_return().next();
|
||||
|
||||
if (multiple_return_result.done) {
|
||||
|
@ -671,7 +679,7 @@ if (refuse_return_result.done) {
|
|||
// error: number | void ~> string
|
||||
function test1(gen: Generator<void, string, void>) {
|
||||
var ret = gen.return(0);
|
||||
|
||||
|
||||
(ret.value: void);
|
||||
}
|
||||
|
||||
|
@ -682,6 +690,7 @@ function* refuse_return() {
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
var refuse_return_gen = refuse_return();
|
||||
var refuse_return_result = refuse_return_gen.return(\"string\");
|
||||
|
||||
|
@ -727,6 +736,7 @@ function* catch_return() {
|
|||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
var catch_return_value = catch_return().throw(\"\").value;
|
||||
|
||||
if (catch_return_value !== undefined) {
|
||||
|
@ -736,11 +746,13 @@ if (catch_return_value !== undefined) {
|
|||
function* yield_return() {
|
||||
try {
|
||||
yield 0;
|
||||
|
||||
return;
|
||||
} catch (e) {
|
||||
yield e;
|
||||
}
|
||||
}
|
||||
|
||||
var yield_return_value = yield_return().throw(\"\").value;
|
||||
|
||||
if (yield_return_value !== undefined) {
|
||||
|
|
|
@ -63,8 +63,9 @@ class D<T> {
|
|||
x: T;
|
||||
m<S>(z: S, u: T, v): S {
|
||||
this.x = u;
|
||||
|
||||
|
||||
v.u = u;
|
||||
|
||||
return z;
|
||||
}
|
||||
}
|
||||
|
@ -76,6 +77,7 @@ var n: number = o.u;
|
|||
class E<X> extends C<X> {
|
||||
set(x: X): X {
|
||||
this.x = x;
|
||||
|
||||
return this.get();
|
||||
}
|
||||
}
|
||||
|
@ -92,6 +94,7 @@ class H<Z> extends G<Array<Z>> {
|
|||
var h1 = new H();
|
||||
|
||||
h1.foo([ \"...\" ]);
|
||||
|
||||
var h2: F<Array<Array<Array<number>>>> = h1;
|
||||
var obj: Object<string, string> = {};
|
||||
var fn: Function<string> = function() {
|
||||
|
|
|
@ -23,6 +23,7 @@ var lib = require(\"./library\");
|
|||
function add(a: number, b: number): number {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
var re = /^keynote (talk){2} (lightning){3,5} (talk){2} closing partytime!!!/;
|
||||
|
||||
add(lib.iTakeAString(42), 7);
|
||||
|
@ -48,11 +49,13 @@ things;
|
|||
import thing from \"./helpers/exports_default.js\";
|
||||
|
||||
thing;
|
||||
|
||||
import { foo, bar as baz } from \"./helpers/exports_named.js\";
|
||||
|
||||
foo;
|
||||
|
||||
baz;
|
||||
|
||||
import * as things from \"./helpers/exports_named.js\";
|
||||
|
||||
things;
|
||||
|
|
|
@ -50,17 +50,21 @@ let ParentFoo;
|
|||
({ ParentFoo } = Parent);
|
||||
|
||||
ParentFoo;
|
||||
|
||||
let ParentFoo2;
|
||||
|
||||
ParentFoo2 = Parent;
|
||||
|
||||
ParentFoo2;
|
||||
|
||||
let ParentFoo3 = Parent;
|
||||
|
||||
ParentFoo3;
|
||||
|
||||
let foo = require(\"./Parent\").ParentFoo.foo;
|
||||
|
||||
foo;
|
||||
|
||||
import type { Foo } from \"./types\";
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -121,6 +121,7 @@ foo.goodSetterWithAnnotation = 123;
|
|||
foo.goodSetterNoAnnotation = \"hello\";
|
||||
|
||||
foo.goodSetterWithAnnotation = \"hello\";
|
||||
|
||||
var testSubtypingGetterAndSetter: number = foo.propWithSubtypingGetterAndSetter;
|
||||
var testPropOverridenWithGetter: number = foo.propOverriddenWithGetter;
|
||||
|
||||
|
@ -259,9 +260,11 @@ obj.goodSetterWithAnnotation = 123;
|
|||
obj.goodSetterNoAnnotation = \"hello\";
|
||||
|
||||
obj.goodSetterWithAnnotation = \"hello\";
|
||||
|
||||
var testSubtypingGetterAndSetter: number = obj.propWithSubtypingGetterAndSetter;
|
||||
|
||||
obj.exampleOfOrderOfGetterAndSetter = new C();
|
||||
|
||||
var testExampleOrOrderOfGetterAndSetterReordered: number = obj.exampleOfOrderOfGetterAndSetterReordered;
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -303,23 +303,27 @@ var a1: ClassFoo1 = foo1Inst;
|
|||
var a2: number = foo1Inst;
|
||||
|
||||
new ClassFoo1();
|
||||
|
||||
import type { ClassFoo2 } from \"./ExportNamed_Class\";
|
||||
import { foo2Inst } from \"./ExportNamed_Class\";
|
||||
var b1: ClassFoo2 = foo2Inst;
|
||||
var b2: number = foo2Inst;
|
||||
|
||||
new ClassFoo2();
|
||||
|
||||
import type ClassFoo3T from \"./ExportCJSDefault_Class\";
|
||||
import ClassFoo3 from \"./ExportCJSDefault_Class\";
|
||||
var c1: ClassFoo3T = new ClassFoo3();
|
||||
|
||||
new ClassFoo3T();
|
||||
|
||||
import type { ClassFoo4, ClassFoo5 } from \"./ExportCJSNamed_Class\";
|
||||
import { foo4Inst, foo5Inst } from \"./ExportCJSNamed_Class\";
|
||||
var d1: ClassFoo4 = foo4Inst;
|
||||
var d2: number = foo4Inst;
|
||||
|
||||
new ClassFoo4();
|
||||
|
||||
var d3: typeof ClassFoo5 = foo5Inst;
|
||||
import type { AliasFoo3 } from \"./ExportNamed_Alias\";
|
||||
import { givesAFoo3Obj } from \"./ExportNamed_Alias\";
|
||||
|
|
|
@ -334,12 +334,14 @@ var a1: ClassFoo1T = ClassFoo1;
|
|||
var a2: ClassFoo1T = new ClassFoo1();
|
||||
|
||||
new ClassFoo1T();
|
||||
|
||||
import typeof { ClassFoo2 as ClassFoo2T } from \"./ExportNamed_Class\";
|
||||
import { ClassFoo2 } from \"./ExportNamed_Class\";
|
||||
var b1: ClassFoo2T = ClassFoo2;
|
||||
var b2: ClassFoo2T = new ClassFoo2();
|
||||
|
||||
new ClassFoo2T();
|
||||
|
||||
import typeof ClassFoo3T from \"./ExportCJSDefault_Class\";
|
||||
import ClassFoo3 from \"./ExportCJSDefault_Class\";
|
||||
var c1: ClassFoo3T = ClassFoo3;
|
||||
|
|
|
@ -60,7 +60,7 @@ function _if(b: () => boolean) {
|
|||
if (b()) {
|
||||
var f = function() {};
|
||||
}
|
||||
|
||||
|
||||
f();
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ function _while(b: () => boolean) {
|
|||
while (b()) {
|
||||
var f = function() {};
|
||||
}
|
||||
|
||||
|
||||
f();
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ function _do_while(b: () => boolean) {
|
|||
do {
|
||||
var f = function() {};
|
||||
} while (b());
|
||||
|
||||
|
||||
f();
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ function _for(n: number) {
|
|||
for (var i = 0; i < n; i++) {
|
||||
var f = function() {};
|
||||
}
|
||||
|
||||
|
||||
f();
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ function _for_in(obj: Object) {
|
|||
for (var p in obj) {
|
||||
var f = function() {};
|
||||
}
|
||||
|
||||
|
||||
f();
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ function _for_of(arr: Array<number>) {
|
|||
for (var x of arr) {
|
||||
var f = function() {};
|
||||
}
|
||||
|
||||
|
||||
f();
|
||||
}
|
||||
"
|
||||
|
@ -432,8 +432,9 @@ function for_in_post_init() {
|
|||
// error
|
||||
function linear_deferred_init() {
|
||||
var x: number;
|
||||
|
||||
|
||||
x = 0;
|
||||
|
||||
var y: number = x;
|
||||
}
|
||||
|
||||
|
@ -459,7 +460,7 @@ function if_else_partial_init(b) {
|
|||
|
||||
function if_pre_init(b) {
|
||||
var y: number = x;
|
||||
|
||||
|
||||
if (b) {
|
||||
var x: number = 0;
|
||||
}
|
||||
|
@ -469,6 +470,7 @@ function if_partial_post_init(b) {
|
|||
if (b) {
|
||||
var x: number = 0;
|
||||
}
|
||||
|
||||
var y: number = x;
|
||||
}
|
||||
|
||||
|
@ -478,26 +480,29 @@ function if_post_init(b) {
|
|||
} else {
|
||||
var x: number = 1;
|
||||
}
|
||||
|
||||
var y: number = x;
|
||||
}
|
||||
|
||||
function if_partial_post_init(b) {
|
||||
var x: number;
|
||||
|
||||
|
||||
if (b) {
|
||||
x = 0;
|
||||
}
|
||||
|
||||
var y: number = x;
|
||||
}
|
||||
|
||||
function if_post_init(b) {
|
||||
var x: number;
|
||||
|
||||
|
||||
if (b) {
|
||||
x = 0;
|
||||
} else {
|
||||
x = 1;
|
||||
}
|
||||
|
||||
var y: number = x;
|
||||
}
|
||||
|
||||
|
@ -505,12 +510,14 @@ function switch_partial_post_init(i) {
|
|||
var x: number;
|
||||
switch (i) {
|
||||
case 0:
|
||||
|
||||
|
||||
x = 0;
|
||||
|
||||
break;
|
||||
case 1:
|
||||
|
||||
|
||||
x = 1;
|
||||
|
||||
break;
|
||||
}
|
||||
var y: number = x;
|
||||
|
@ -520,16 +527,19 @@ function switch_post_init(i) {
|
|||
var x: number;
|
||||
switch (i) {
|
||||
case 0:
|
||||
|
||||
|
||||
x = 0;
|
||||
|
||||
break;
|
||||
case 1:
|
||||
|
||||
|
||||
x = 1;
|
||||
|
||||
break;
|
||||
default:
|
||||
|
||||
|
||||
x = 2;
|
||||
|
||||
}
|
||||
var y: number = x;
|
||||
}
|
||||
|
@ -618,7 +628,7 @@ function for_scoped_init(b) {
|
|||
|
||||
function for_pre_init(b) {
|
||||
var y: number = x;
|
||||
|
||||
|
||||
for (; b; ) {
|
||||
var x: number = 0;
|
||||
}
|
||||
|
@ -628,6 +638,7 @@ function for_post_init(b) {
|
|||
for (; b; ) {
|
||||
var x: number = 0;
|
||||
}
|
||||
|
||||
var y: number = x;
|
||||
}
|
||||
|
||||
|
@ -640,7 +651,7 @@ function for_in_scoped_init() {
|
|||
|
||||
function for_in_pre_init() {
|
||||
var y: number = x;
|
||||
|
||||
|
||||
for (var p in { a: 1, b: 2 }) {
|
||||
var x: number = 0;
|
||||
}
|
||||
|
@ -650,6 +661,7 @@ function for_in_post_init() {
|
|||
for (var p in { a: 1, b: 2 }) {
|
||||
var x: number = 0;
|
||||
}
|
||||
|
||||
var y: number = x;
|
||||
}
|
||||
|
||||
|
@ -662,7 +674,7 @@ function for_of_scoped_init() {
|
|||
|
||||
function for_in_pre_init() {
|
||||
var y: number = x;
|
||||
|
||||
|
||||
for (var x of [ 1, 2, 3 ]) {
|
||||
var x: number = 0;
|
||||
}
|
||||
|
@ -672,6 +684,7 @@ function for_in_post_init() {
|
|||
for (var x of [ 1, 2, 3 ]) {
|
||||
var x: number = 0;
|
||||
}
|
||||
|
||||
var y: number = x;
|
||||
}
|
||||
"
|
||||
|
@ -873,8 +886,9 @@ function sub_closure_init_reference() {
|
|||
// TDZ (...even though this is weird...)
|
||||
function linear_deferred_init() {
|
||||
let x: number;
|
||||
|
||||
|
||||
x = 0;
|
||||
|
||||
let y: number = x;
|
||||
}
|
||||
|
||||
|
@ -882,8 +896,9 @@ function linear_pre_init() {
|
|||
let x: number;
|
||||
let y: ?number = x;
|
||||
let z: number = x;
|
||||
|
||||
|
||||
x = 0;
|
||||
|
||||
let w: number = x;
|
||||
}
|
||||
|
||||
|
@ -893,21 +908,23 @@ function self_init() {
|
|||
|
||||
function if_partial_post_init(b) {
|
||||
let x: number;
|
||||
|
||||
|
||||
if (b) {
|
||||
x = 0;
|
||||
}
|
||||
|
||||
var y: number = x;
|
||||
}
|
||||
|
||||
function if_post_init(b) {
|
||||
let x: number;
|
||||
|
||||
|
||||
if (b) {
|
||||
x = 0;
|
||||
} else {
|
||||
x = 1;
|
||||
}
|
||||
|
||||
var y: number = x;
|
||||
}
|
||||
|
||||
|
@ -915,12 +932,14 @@ function switch_partial_post_init(i) {
|
|||
let x: number;
|
||||
switch (i) {
|
||||
case 0:
|
||||
|
||||
|
||||
x = 0;
|
||||
|
||||
break;
|
||||
case 1:
|
||||
|
||||
|
||||
x = 1;
|
||||
|
||||
break;
|
||||
}
|
||||
var y: number = x;
|
||||
|
@ -930,16 +949,19 @@ function switch_post_init(i) {
|
|||
let x: number;
|
||||
switch (i) {
|
||||
case 0:
|
||||
|
||||
|
||||
x = 0;
|
||||
|
||||
break;
|
||||
case 1:
|
||||
|
||||
|
||||
x = 1;
|
||||
|
||||
break;
|
||||
default:
|
||||
|
||||
|
||||
x = 2;
|
||||
|
||||
}
|
||||
var y: number = x;
|
||||
}
|
||||
|
@ -971,19 +993,21 @@ function do_while_post_init(b) {
|
|||
|
||||
function for_in_post_init() {
|
||||
var x: number;
|
||||
|
||||
|
||||
for (var p in {}) {
|
||||
x = 0;
|
||||
}
|
||||
|
||||
var y: number = x;
|
||||
}
|
||||
|
||||
function for_of_post_init() {
|
||||
var x: number;
|
||||
|
||||
|
||||
for (var x of []) {
|
||||
x = 0;
|
||||
}
|
||||
|
||||
var y: number = x;
|
||||
}
|
||||
|
||||
|
@ -991,8 +1015,9 @@ function switch_post_init2(i): number {
|
|||
let bar;
|
||||
switch (i) {
|
||||
case 1:
|
||||
|
||||
|
||||
bar = 3;
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new Error(\"Invalid state\");
|
||||
|
@ -1004,8 +1029,9 @@ function switch_post_init2(i): number {
|
|||
let bar;
|
||||
switch (i) {
|
||||
case 1:
|
||||
|
||||
|
||||
bar = 3;
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new Error(\"Invalid state\");
|
||||
|
|
|
@ -110,7 +110,7 @@ function x(b) {
|
|||
|
||||
function consumer1(b) {
|
||||
var g = x(b);
|
||||
|
||||
|
||||
if (g instanceof X2)
|
||||
g.foo = \"1337\";
|
||||
else
|
||||
|
@ -119,10 +119,11 @@ else
|
|||
|
||||
function consumer2(b) {
|
||||
var g = x(b);
|
||||
|
||||
|
||||
if (g instanceof X1)
|
||||
g.foo = \"1337\";
|
||||
}
|
||||
|
||||
class Y1 {
|
||||
bar: X1;
|
||||
}
|
||||
|
@ -136,7 +137,7 @@ function y(b) {
|
|||
|
||||
function consumer3(b) {
|
||||
var g = y(b);
|
||||
|
||||
|
||||
if (g.bar instanceof X2)
|
||||
g.bar.foo = \"1337\";
|
||||
else
|
||||
|
@ -145,10 +146,11 @@ else
|
|||
|
||||
function consumer4(b) {
|
||||
var g = y(b);
|
||||
|
||||
|
||||
if (g.bar instanceof X1)
|
||||
g.bar.foo = \"1337\";
|
||||
}
|
||||
|
||||
class Z1 {
|
||||
baz: Y1;
|
||||
}
|
||||
|
@ -162,7 +164,7 @@ function z(b) {
|
|||
|
||||
function consumer5(b) {
|
||||
var g = z(b);
|
||||
|
||||
|
||||
if (g.baz.bar instanceof X2)
|
||||
g.baz.bar.foo = \"1337\";
|
||||
else
|
||||
|
@ -171,10 +173,11 @@ else
|
|||
|
||||
function consumer6(b) {
|
||||
var g = z(b);
|
||||
|
||||
|
||||
if (g.baz.bar instanceof X1)
|
||||
g.baz.bar.foo = \"1337\";
|
||||
}
|
||||
|
||||
class C {
|
||||
m() {
|
||||
if (this instanceof D)
|
||||
|
@ -187,7 +190,7 @@ class D extends C {
|
|||
s: string;
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
|
||||
this.s = \"yup\";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ var i = new I();
|
|||
|
||||
function testInterfaceName(o: I) {
|
||||
(o.name: string);
|
||||
|
||||
|
||||
(o.constructor.name: string);
|
||||
}
|
||||
"
|
||||
|
@ -97,6 +97,7 @@ var k: K = { x: \"\", y: \"\" };
|
|||
(k.x: string);
|
||||
|
||||
(k.y: string);
|
||||
|
||||
declare class C { x: number }
|
||||
declare class D extends C, Other {}
|
||||
interface A<Y> { y: Y }
|
||||
|
@ -134,18 +135,19 @@ interface L extends J, K { y: string }
|
|||
|
||||
function foo(l: L) {
|
||||
l.x;
|
||||
|
||||
|
||||
l.y;
|
||||
|
||||
|
||||
l.z;
|
||||
}
|
||||
|
||||
type M = { y: string } & J & { z: boolean };
|
||||
|
||||
function bar(m: M) {
|
||||
m.x;
|
||||
|
||||
|
||||
m.y;
|
||||
|
||||
|
||||
m.z;
|
||||
}
|
||||
"
|
||||
|
@ -169,7 +171,7 @@ interface K extends I, J { x: string }
|
|||
|
||||
function foo(k: K) {
|
||||
(k.x: number);
|
||||
|
||||
|
||||
(k.y: number);
|
||||
}
|
||||
"
|
||||
|
@ -191,6 +193,7 @@ new C().bar((x: string) => { }); // error, number ~/~> string
|
|||
interface I { foo(x: number): void }
|
||||
|
||||
(function foo(x: number) {}: I);
|
||||
|
||||
declare class C { bar(i: I): void; bar(f: (x: number) => void): void }
|
||||
|
||||
new C().bar((x: string) => {});
|
||||
|
|
|
@ -150,6 +150,7 @@ type FG = (_: ObjA | ObjB) => void;
|
|||
declare var fun1: F & G;
|
||||
|
||||
(fun1: FG);
|
||||
|
||||
var fun2: FG = fun1;
|
||||
declare var f: ((_: number) => void) & ((_: string) => void);
|
||||
var g: (_: number | string) => void = f;
|
||||
|
|
|
@ -54,16 +54,19 @@ for (var i = 0; i < 3; i++) {
|
|||
for (var k in a) {
|
||||
foo(a[k]);
|
||||
}
|
||||
|
||||
var b = (null: ?{ [key: string]: string });
|
||||
|
||||
for (var j in b) {
|
||||
foo(b[j]);
|
||||
}
|
||||
|
||||
var c;
|
||||
|
||||
for (var m in c = b) {
|
||||
foo(c[m]);
|
||||
}
|
||||
|
||||
var d;
|
||||
|
||||
for (var n in d = a) {
|
||||
|
|
|
@ -89,6 +89,7 @@ function foo(strs: Iterable<string>): void {
|
|||
console.log(s);
|
||||
}
|
||||
}
|
||||
|
||||
var m: Map<string, number> = new Map();
|
||||
|
||||
foo(m.keys());
|
||||
|
@ -137,7 +138,7 @@ function makeIterator(coin_flip: () => boolean): Iterator<string> {
|
|||
},
|
||||
next(): IteratorResult<string, void> {
|
||||
var done = coin_flip();
|
||||
|
||||
|
||||
if (!done) {
|
||||
return { done, value: \"still going...\" };
|
||||
} else {
|
||||
|
@ -154,7 +155,7 @@ function makeIterator(coin_flip: () => boolean): Iterator<string> {
|
|||
},
|
||||
next(): IteratorResult<string, void> {
|
||||
var done = coin_flip();
|
||||
|
||||
|
||||
if (done) {
|
||||
return { done, value: \"still going...\" };
|
||||
} else {
|
||||
|
|
|
@ -31,6 +31,7 @@ var b: React.Element<{ prop1: string }> = <CustomComponent prop=\"asdf\"/>;
|
|||
<div id=\"asdf\"/>;
|
||||
|
||||
<div id={42}/>;
|
||||
|
||||
var c: React.Element<{ id: string }> = <div id=\"asdf\"/>;
|
||||
var d: React.Element<{ id: number }> = <div id=\"asdf\"/>;
|
||||
"
|
||||
|
|
|
@ -65,54 +65,57 @@ function testKeysOfOtherObj(str: string, lit: \'hi\') {
|
|||
// Error: number -> keys of ObjLit
|
||||
function testKeysOfObject(str: string, lit: \"hi\") {
|
||||
(str: $Keys<Object>);
|
||||
|
||||
|
||||
if (str) {
|
||||
(str: $Keys<Object>);
|
||||
}
|
||||
|
||||
|
||||
(\"hi\": $Keys<Object>);
|
||||
|
||||
|
||||
(123: $Keys<Object>);
|
||||
}
|
||||
|
||||
type StrDict = { [key: string]: mixed };
|
||||
|
||||
function testKeysOfStrDict(str: string, lit: \"hi\") {
|
||||
(str: $Keys<StrDict>);
|
||||
|
||||
|
||||
if (str) {
|
||||
(str: $Keys<StrDict>);
|
||||
}
|
||||
|
||||
|
||||
(\"hi\": $Keys<StrDict>);
|
||||
|
||||
|
||||
(123: $Keys<StrDict>);
|
||||
}
|
||||
|
||||
type StrLitDict = { [key: \"hi\"]: mixed };
|
||||
|
||||
function testKeysOfStrLitDict(str: string, lit: \"hi\") {
|
||||
(str: $Keys<StrLitDict>);
|
||||
|
||||
|
||||
if (str) {
|
||||
(str: $Keys<StrLitDict>);
|
||||
}
|
||||
|
||||
|
||||
(\"hi\": $Keys<StrLitDict>);
|
||||
|
||||
|
||||
(\"bye\": $Keys<StrLitDict>);
|
||||
|
||||
|
||||
(123: $Keys<StrLitDict>);
|
||||
}
|
||||
|
||||
type ObjLit = { hi: mixed };
|
||||
|
||||
function testKeysOfOtherObj(str: string, lit: \"hi\") {
|
||||
(str: $Keys<ObjLit>);
|
||||
|
||||
|
||||
if (str) {
|
||||
(str: $Keys<ObjLit>);
|
||||
}
|
||||
|
||||
|
||||
(\"hi\": $Keys<ObjLit>);
|
||||
|
||||
|
||||
(123: $Keys<ObjLit>);
|
||||
}
|
||||
"
|
||||
|
|
|
@ -88,6 +88,7 @@ class C {
|
|||
(new C().bar: boolean);
|
||||
|
||||
(new C().qux: boolean);
|
||||
|
||||
const o = {
|
||||
foo(): number {
|
||||
return 0;
|
||||
|
|
|
@ -18,6 +18,7 @@ var w: string = parseInt(\"...\");
|
|||
var a = new Map();
|
||||
|
||||
a.delete(\"foobar\");
|
||||
|
||||
var b = undefined;
|
||||
|
||||
if (undefined)
|
||||
|
|
|
@ -56,11 +56,13 @@ function bar(x: $Keys<{ age: number }>) {}
|
|||
bar(APIKeys.AGE);
|
||||
|
||||
bar(APIKeys.NAME);
|
||||
|
||||
var object = {};
|
||||
|
||||
object[APIKeys.AGE] = 123;
|
||||
|
||||
object[APIKeys.NAME] = \"FOO\";
|
||||
|
||||
var age: number = object[APIKeys.AGE];
|
||||
var name: number = object[APIKeys.NAME];
|
||||
var indices = { red: 0, green: 1, blue: 2 };
|
||||
|
@ -108,15 +110,17 @@ function test3(x: number, flip_times: number): number {
|
|||
for (var i = 0; i < flip_times; i++) {
|
||||
x = -x;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
function test4(flip_times: number): number {
|
||||
var x = 1;
|
||||
|
||||
|
||||
for (var i = 0; i < flip_times; i++) {
|
||||
x = -x;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
"
|
||||
|
|
|
@ -78,14 +78,15 @@ function switch_scope(x: mixed) {
|
|||
switch (x) {
|
||||
case \"foo\":
|
||||
let a;
|
||||
|
||||
|
||||
a = 0;
|
||||
|
||||
|
||||
b = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
(a: string);
|
||||
|
||||
|
||||
(b: string);
|
||||
}
|
||||
|
||||
|
@ -94,63 +95,63 @@ function try_scope_finally() {
|
|||
let b;
|
||||
try {
|
||||
a = \"\";
|
||||
|
||||
|
||||
b = \"\";
|
||||
} finally {
|
||||
let a;
|
||||
|
||||
|
||||
a = 0;
|
||||
|
||||
|
||||
b = 0;
|
||||
}
|
||||
|
||||
|
||||
(a: string);
|
||||
|
||||
|
||||
(b: string);
|
||||
}
|
||||
|
||||
function for_scope() {
|
||||
let a = \"\";
|
||||
let b = \"\";
|
||||
|
||||
|
||||
for (let a; ; ) {
|
||||
a = 0;
|
||||
|
||||
|
||||
b = 0;
|
||||
}
|
||||
|
||||
|
||||
(a: string);
|
||||
|
||||
|
||||
(b: string);
|
||||
}
|
||||
|
||||
function for_in_scope(o: Object) {
|
||||
let a = 0;
|
||||
let b = 0;
|
||||
|
||||
|
||||
for (let a in o) {
|
||||
a = \"\";
|
||||
|
||||
|
||||
b = \"\";
|
||||
}
|
||||
|
||||
|
||||
(a: number);
|
||||
|
||||
|
||||
(b: number);
|
||||
}
|
||||
|
||||
function for_of_scope(xs: number[]) {
|
||||
let a = \"\";
|
||||
let b = \"\";
|
||||
|
||||
|
||||
for (let a of xs) {
|
||||
a = 0;
|
||||
|
||||
|
||||
b = 0;
|
||||
}
|
||||
|
||||
|
||||
(a: string);
|
||||
|
||||
|
||||
(b: string);
|
||||
}
|
||||
"
|
||||
|
@ -194,16 +195,17 @@ function sorry(really: boolean) {
|
|||
} else {
|
||||
var x: boolean = true;
|
||||
}
|
||||
|
||||
|
||||
foo(x);
|
||||
}
|
||||
|
||||
function foo0(b: boolean): number {
|
||||
var x = 0;
|
||||
|
||||
|
||||
if (b) {
|
||||
var x = \"\";
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
"
|
||||
|
|
|
@ -920,10 +920,11 @@ function logical10c(x: number, y: string): Array<any> {
|
|||
|
||||
function logical11a(): number {
|
||||
var y = 1;
|
||||
|
||||
|
||||
for (var x = 0; x < 5; x++) {
|
||||
y = y || true;
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
|
@ -931,18 +932,20 @@ function logical11b(y: number): number {
|
|||
for (var x = 0; x < 5; x++) {
|
||||
y = y || true;
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
function logical12a(): number {
|
||||
var y = 1;
|
||||
var z = true;
|
||||
|
||||
|
||||
for (var x = 0; x < 5; x++) {
|
||||
y = z && y;
|
||||
|
||||
|
||||
z = false;
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
|
@ -950,6 +953,7 @@ function logical12b(y: number): number {
|
|||
for (var x = 0; x < 5; x++) {
|
||||
y = y && true;
|
||||
}
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ var export_o: { x: number } = o;
|
|||
function f(u, v?): number {
|
||||
return u;
|
||||
}
|
||||
|
||||
var export_f: (u: number) => number = f;
|
||||
|
||||
module.exports = export_f;
|
||||
|
|
|
@ -49,6 +49,7 @@ C.x;
|
|||
new C().foo.x;
|
||||
|
||||
C.bar.x;
|
||||
|
||||
import { Foo } from \"./exports_optional_prop\";
|
||||
const foo = new Foo();
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ f(A.x); // A.x is now a string, by def assign
|
|||
/* @providesModule A */
|
||||
// A.x is now a string, by def assign
|
||||
module.exports = {};
|
||||
|
||||
var A = { x: true, ...{} };
|
||||
|
||||
module.exports.cls = A;
|
||||
|
@ -91,11 +92,11 @@ var f = require(\"A\").fn;
|
|||
|
||||
function C() {
|
||||
var o = new B();
|
||||
|
||||
|
||||
f(o.b);
|
||||
|
||||
|
||||
f(o.s);
|
||||
|
||||
|
||||
o.fn();
|
||||
}
|
||||
|
||||
|
@ -125,9 +126,11 @@ var f = require(\"A\").fn;
|
|||
function g(): string {
|
||||
return this.i;
|
||||
}
|
||||
|
||||
var o = { fn: g, ...{} };
|
||||
|
||||
o.i = true;
|
||||
|
||||
var i = o.fn();
|
||||
|
||||
f(i);
|
||||
|
@ -150,6 +153,7 @@ module.exports = {obj: o};
|
|||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @providesModule E */
|
||||
function h(x: number) {}
|
||||
|
||||
var proto = { fn: h };
|
||||
var o = Object.create(proto);
|
||||
|
||||
|
@ -193,6 +197,7 @@ var a = { length: \"duck\" };
|
|||
a.length = 123;
|
||||
|
||||
a.length();
|
||||
|
||||
var b = [ 123 ];
|
||||
|
||||
b.length = \"duck\";
|
||||
|
|
|
@ -43,6 +43,7 @@ function g(x: string) {}
|
|||
|
||||
function f(x: number): number {
|
||||
g(x);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ function Foo() {
|
|||
}
|
||||
|
||||
Foo.prototype.m = function() {};
|
||||
|
||||
var o1: { x: number; m(): void } = new Foo();
|
||||
var o2: Foo = new Foo();
|
||||
"
|
||||
|
|
|
@ -27,11 +27,12 @@ class Bar {
|
|||
self: Bar;
|
||||
constructor(y: number) {
|
||||
this.y = y;
|
||||
|
||||
|
||||
this.self = this;
|
||||
}
|
||||
bar(z: string, u: string): string {
|
||||
new Qux().w = \"?\";
|
||||
|
||||
return z;
|
||||
}
|
||||
}
|
||||
|
@ -78,10 +79,12 @@ class Foo extends Qux {
|
|||
}
|
||||
foo(y: string, z): number {
|
||||
this.x = y;
|
||||
|
||||
var u = new Foo(\"...\").qux();
|
||||
var v = new Bar(y);
|
||||
|
||||
|
||||
v.self = v;
|
||||
|
||||
return v.bar(z, u);
|
||||
}
|
||||
fooqux(x: string) {
|
||||
|
|
|
@ -45,6 +45,7 @@ var foo1 = function<T>(x: T): T {
|
|||
function foo2<T, S>(x: T): S {
|
||||
return x;
|
||||
}
|
||||
|
||||
var foo3 = function<T>(x: T): T {
|
||||
return foo3(x);
|
||||
};
|
||||
|
@ -52,11 +53,13 @@ var foo3 = function<T>(x: T): T {
|
|||
function foo4<T, S>(x: T): S {
|
||||
return foo4(x);
|
||||
}
|
||||
|
||||
var x = [];
|
||||
|
||||
function foo5<T>(): Array<T> {
|
||||
return x;
|
||||
}
|
||||
|
||||
var foo6 = function<R>(x: R): R {
|
||||
return foo1(x);
|
||||
};
|
||||
|
@ -67,8 +70,9 @@ function foo7<R>(x: R): R {
|
|||
|
||||
function foo8<U>(x: U, y): U {
|
||||
var z = foo8(x, x);
|
||||
|
||||
|
||||
y();
|
||||
|
||||
return x;
|
||||
}
|
||||
"
|
||||
|
|
|
@ -67,6 +67,7 @@ function f(x: number) {}
|
|||
function g() {
|
||||
return 42 || \"hello\";
|
||||
}
|
||||
|
||||
var x = g();
|
||||
|
||||
if (typeof x === \"string\") {
|
||||
|
@ -74,11 +75,13 @@ if (typeof x === \"string\") {
|
|||
}
|
||||
|
||||
f(x);
|
||||
|
||||
class A {}
|
||||
|
||||
function h() {
|
||||
return 42 || new A();
|
||||
}
|
||||
|
||||
var y = h();
|
||||
|
||||
if (y instanceof A) {
|
||||
|
@ -88,15 +91,16 @@ if (y instanceof A) {
|
|||
function bar() {
|
||||
return true;
|
||||
}
|
||||
|
||||
class C {
|
||||
qux() {}
|
||||
}
|
||||
|
||||
function foo() {
|
||||
var c = \"...\";
|
||||
|
||||
|
||||
c = new C();
|
||||
|
||||
|
||||
if (bar()) {
|
||||
c.qux();
|
||||
}
|
||||
|
@ -104,7 +108,7 @@ function foo() {
|
|||
|
||||
function goofy() {
|
||||
var x = g();
|
||||
|
||||
|
||||
if (typeof x == \"function\") {
|
||||
x();
|
||||
} else
|
||||
|
@ -113,12 +117,13 @@ function goofy() {
|
|||
|
||||
function goofy2() {
|
||||
var o = { x: 0 };
|
||||
|
||||
|
||||
if (typeof o.x == \"function\") {
|
||||
o.x();
|
||||
}
|
||||
|
||||
var y = o.x;
|
||||
|
||||
|
||||
if (typeof y == \"function\") {
|
||||
y();
|
||||
} else
|
||||
|
@ -148,9 +153,9 @@ function check(x: string) {}
|
|||
|
||||
function FlowSA() {
|
||||
var x = 0;
|
||||
|
||||
|
||||
x = \"...\";
|
||||
|
||||
|
||||
check(x);
|
||||
}
|
||||
|
||||
|
@ -219,7 +224,7 @@ class C extends B {
|
|||
function bar(x: B) {
|
||||
if (x instanceof A) {
|
||||
x.a();
|
||||
|
||||
|
||||
x.c();
|
||||
} else {
|
||||
x++;
|
||||
|
@ -229,18 +234,19 @@ function bar(x: B) {
|
|||
function foo(x: A) {
|
||||
if (x instanceof C) {
|
||||
x.a();
|
||||
|
||||
|
||||
x.b();
|
||||
|
||||
|
||||
x.c();
|
||||
|
||||
|
||||
x.d();
|
||||
} else {
|
||||
x.a();
|
||||
|
||||
|
||||
x.c();
|
||||
}
|
||||
}
|
||||
|
||||
class D {
|
||||
d() {}
|
||||
}
|
||||
|
@ -282,6 +288,7 @@ function test(obj: BaseClass): string {
|
|||
if (obj instanceof ChildClass) {
|
||||
return obj.childProp_TYPO;
|
||||
}
|
||||
|
||||
return obj.baseProp;
|
||||
}
|
||||
"
|
||||
|
|
|
@ -36,6 +36,7 @@ type Map<X, Y> = (x: X) => Y;
|
|||
function bar<U, V>(x: U, f: Map<U, V>): V {
|
||||
return f(x);
|
||||
}
|
||||
|
||||
var y: number = bar(0, x => \"\");
|
||||
type Seq = number | Array<Seq>;
|
||||
var s1: Seq = [ 0, [ 0 ] ];
|
||||
|
|
|
@ -84,6 +84,7 @@ buffer[1];
|
|||
buffer.copyWithin(0, 0);
|
||||
|
||||
buffer.copyWithin(0, 0, 0);
|
||||
|
||||
const it1: Iterator<[number, number]> = buffer.entries();
|
||||
|
||||
bool = buffer.every((element: number) => false);
|
||||
|
@ -136,6 +137,7 @@ num = buffer.indexOf(3);
|
|||
num = buffer.indexOf(3, 4);
|
||||
|
||||
buffer = Buffer.from([ 98, 117, 102, 102, 101, 114 ]);
|
||||
|
||||
const typedArray = new Uint8Array([ 52 ]);
|
||||
|
||||
buffer = Buffer.from(
|
||||
|
|
|
@ -213,7 +213,7 @@ ls.on(
|
|||
if (code !== 0) {
|
||||
console.warn(\"\`ls\` exited with code %s\", code);
|
||||
}
|
||||
|
||||
|
||||
wc.stdin.end();
|
||||
}
|
||||
);
|
||||
|
|
|
@ -52,43 +52,43 @@ const crypto = require(\"crypto\");
|
|||
let tests = [
|
||||
function() {
|
||||
const hmac = crypto.createHmac(\"sha256\", \"a secret\");
|
||||
|
||||
|
||||
hmac.on(
|
||||
\"readable\",
|
||||
() => {
|
||||
(hmac.read(): ?(string | Buffer));
|
||||
|
||||
|
||||
(hmac.read(): number);
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
hmac.write(\"some data to hash\");
|
||||
|
||||
|
||||
hmac.write(123);
|
||||
|
||||
|
||||
hmac.end();
|
||||
},
|
||||
function(buf: Buffer) {
|
||||
const hmac = crypto.createHmac(\"sha256\", \"a secret\");
|
||||
|
||||
|
||||
hmac.update(\"some data to hash\");
|
||||
|
||||
|
||||
hmac.update(\"foo\", \"utf8\");
|
||||
|
||||
|
||||
hmac.update(\"foo\", \"bogus\");
|
||||
|
||||
|
||||
hmac.update(buf);
|
||||
|
||||
|
||||
hmac.update(buf, \"utf8\");
|
||||
|
||||
|
||||
(hmac.update(\"some data to hash\").update(buf).digest(): Buffer);
|
||||
|
||||
|
||||
(hmac.digest(\"hex\"): string);
|
||||
|
||||
|
||||
(hmac.digest(): Buffer);
|
||||
|
||||
|
||||
(hmac.digest(\"hex\"): void);
|
||||
|
||||
|
||||
(hmac.digest(): void);
|
||||
}
|
||||
];
|
||||
|
|
|
@ -43,12 +43,15 @@ let data = require(\"./package/index.json\");
|
|||
(data.foo.bar: void);
|
||||
|
||||
(data.abc: boolean);
|
||||
|
||||
let data2 = require(\"./package\");
|
||||
|
||||
(data2.baz: void);
|
||||
|
||||
let data3 = require(\"./package2\");
|
||||
|
||||
(data3.foo: void);
|
||||
|
||||
let data4 = require(\"./json_array\");
|
||||
|
||||
(data4: Array<number>);
|
||||
|
|
|
@ -25,11 +25,13 @@ var u1 = os.userInfo();
|
|||
(u1.username: string);
|
||||
|
||||
(u1.username: Buffer);
|
||||
|
||||
var u2 = os.userInfo({ encoding: \"utf8\" });
|
||||
|
||||
(u2.username: string);
|
||||
|
||||
(u2.username: Buffer);
|
||||
|
||||
var u3 = os.userInfo({ encoding: \"buffer\" });
|
||||
|
||||
(u3.username: string);
|
||||
|
|
|
@ -57,9 +57,11 @@ ls.stdin.end(data, \"utf-8\");
|
|||
ls.stdin.end(data, () => {});
|
||||
|
||||
ls.stdin.end(data, \"utf-8\", () => {});
|
||||
|
||||
var ws = fs.createWriteStream(\"/dev/null\");
|
||||
|
||||
ls.stdout.pipe(ws).end();
|
||||
|
||||
class MyReadStream extends stream.Readable {}
|
||||
class MyWriteStream extends stream.Writable {}
|
||||
class MyDuplex extends stream.Duplex {}
|
||||
|
|
|
@ -49,6 +49,7 @@ function bar(): ?string {
|
|||
function qux(x: string) {}
|
||||
|
||||
function corge(x: number) {}
|
||||
|
||||
var x = bar();
|
||||
|
||||
if (x != null)
|
||||
|
@ -63,9 +64,10 @@ function grault() {
|
|||
|
||||
if (x != null) {
|
||||
grault();
|
||||
|
||||
|
||||
qux(x);
|
||||
}
|
||||
|
||||
var array_of_nullable: Array<?number> = [ null, 3 ];
|
||||
"
|
||||
`;
|
||||
|
|
|
@ -77,6 +77,7 @@ b.f(); // error, property \`p\` not found
|
|||
function f() {
|
||||
return this.p;
|
||||
}
|
||||
|
||||
var a = { p: 0, f };
|
||||
var b = { f };
|
||||
|
||||
|
@ -118,7 +119,7 @@ function foo() {
|
|||
|
||||
function bar(f: () => void) {
|
||||
f();
|
||||
|
||||
|
||||
({ f }).f();
|
||||
}
|
||||
|
||||
|
|
|
@ -107,6 +107,7 @@ class C {
|
|||
(Object.create(new C()): C);
|
||||
|
||||
({ foo: \"foo\" }: C);
|
||||
|
||||
type O = { foo: string };
|
||||
declare var o: O;
|
||||
|
||||
|
@ -133,7 +134,7 @@ class Bar extends Foo {}
|
|||
let tests = [
|
||||
function() {
|
||||
const x = new Bar();
|
||||
|
||||
|
||||
(Object.getPrototypeOf(x): Foo);
|
||||
}
|
||||
];
|
||||
|
@ -188,6 +189,7 @@ var sealed = { one: \"one\", two: \"two\" };
|
|||
(Object.keys(sealed): Array<\"one\" | \"two\">);
|
||||
|
||||
(Object.keys(sealed): void);
|
||||
|
||||
var unsealed = {};
|
||||
|
||||
Object.keys(unsealed).forEach(
|
||||
|
@ -195,6 +197,7 @@ Object.keys(unsealed).forEach(
|
|||
(k: number);
|
||||
}
|
||||
);
|
||||
|
||||
var dict: { [k: number]: string } = {};
|
||||
|
||||
Object.keys(dict).forEach(
|
||||
|
@ -202,15 +205,18 @@ Object.keys(dict).forEach(
|
|||
(k: number);
|
||||
}
|
||||
);
|
||||
|
||||
var any: Object = {};
|
||||
|
||||
(Object.keys(any): Array<number>);
|
||||
|
||||
class Foo {
|
||||
prop: string;
|
||||
foo() {}
|
||||
}
|
||||
|
||||
(Object.keys(new Foo()): Array<\"error\">);
|
||||
|
||||
class Bar extends Foo {
|
||||
bar_prop: string;
|
||||
bar() {}
|
||||
|
@ -476,6 +482,7 @@ function takesAString(x: string) {}
|
|||
function takesANumber(x: number) {}
|
||||
|
||||
function takesAnObject(x: Object) {}
|
||||
|
||||
class Foo {}
|
||||
var a = { foo: \"bar\" };
|
||||
var b = { foo: \"bar\", ...{} };
|
||||
|
@ -492,6 +499,7 @@ var y = new Foo();
|
|||
takesAString(a.toString());
|
||||
|
||||
d.toString();
|
||||
|
||||
var aToString: () => string = a.toString;
|
||||
var aToString2 = a.toString;
|
||||
|
||||
|
@ -504,11 +512,13 @@ b.toString = function(): string {
|
|||
c.toString = function(): number {
|
||||
return 123;
|
||||
};
|
||||
|
||||
var cToString: () => number = c.toString;
|
||||
var xToString: number = x.toString;
|
||||
var xToString2: () => number = x.toString;
|
||||
|
||||
takesAString(x.toString());
|
||||
|
||||
var yToString: number = y.toString;
|
||||
|
||||
takesAString(y.toString());
|
||||
|
@ -526,6 +536,7 @@ takesAString(y.toString());
|
|||
(123).toString(null);
|
||||
|
||||
takesABool(a.hasOwnProperty(\"foo\"));
|
||||
|
||||
var aHasOwnProperty: (prop: string) => boolean = a.hasOwnProperty;
|
||||
var aHasOwnProperty2 = a.hasOwnProperty;
|
||||
|
||||
|
@ -534,15 +545,18 @@ takesABool(aHasOwnProperty2(\"bar\"));
|
|||
b.hasOwnProperty = function() {
|
||||
return false;
|
||||
};
|
||||
|
||||
var xHasOwnProperty: number = x.hasOwnProperty;
|
||||
var xHasOwnProperty2: (prop: string) => number = x.hasOwnProperty;
|
||||
|
||||
takesABool(x.hasOwnProperty(\"foo\"));
|
||||
|
||||
var yHasOwnProperty: number = y.hasOwnProperty;
|
||||
|
||||
takesABool(y.hasOwnProperty(\"foo\"));
|
||||
|
||||
takesABool(a.propertyIsEnumerable(\"foo\"));
|
||||
|
||||
var aPropertyIsEnumerable: (prop: string) => boolean = a.propertyIsEnumerable;
|
||||
var aPropertyIsEnumerable2 = a.propertyIsEnumerable;
|
||||
|
||||
|
@ -551,15 +565,18 @@ takesABool(aPropertyIsEnumerable2(\"bar\"));
|
|||
b.propertyIsEnumerable = function() {
|
||||
return false;
|
||||
};
|
||||
|
||||
var xPropertyIsEnumerable: number = x.propertyIsEnumerable;
|
||||
var xPropertyIsEnumerable2: (prop: string) => number = x.propertyIsEnumerable;
|
||||
|
||||
takesABool(x.propertyIsEnumerable(\"foo\"));
|
||||
|
||||
var yPropertyIsEnumerable: number = y.propertyIsEnumerable;
|
||||
|
||||
takesABool(y.propertyIsEnumerable(\"foo\"));
|
||||
|
||||
takesAnObject(a.valueOf());
|
||||
|
||||
var aValueOf: () => Object = a.valueOf;
|
||||
var aValueOf2 = a.valueOf;
|
||||
|
||||
|
@ -568,17 +585,21 @@ takesAnObject(aValueOf2());
|
|||
b.valueOf = function() {
|
||||
return {};
|
||||
};
|
||||
|
||||
var xValueOf: number = x.valueOf;
|
||||
|
||||
takesANumber(x.valueOf());
|
||||
|
||||
var yValueOf: number = y.valueOf;
|
||||
|
||||
takesAnObject(y.valueOf());
|
||||
|
||||
var strValueOf: string = \"foo\".valueOf();
|
||||
var numValueOf: number = (123).valueOf();
|
||||
var boolValueOf: boolean = true.valueOf();
|
||||
|
||||
takesAString(a.toLocaleString());
|
||||
|
||||
var aToLocaleString: () => string = a.toLocaleString;
|
||||
var aToLocaleString2 = a.toLocaleString;
|
||||
|
||||
|
@ -587,13 +608,16 @@ takesAString(aToLocaleString2());
|
|||
b.toLocaleString = function() {
|
||||
return \"derp\";
|
||||
};
|
||||
|
||||
var xToLocaleString: number = x.toLocaleString;
|
||||
var xToLocaleString2: () => number = x.toLocaleString;
|
||||
|
||||
takesAString(x.toLocaleString());
|
||||
|
||||
var yToLocaleString: number = y.toLocaleString;
|
||||
|
||||
takesAString(y.toLocaleString());
|
||||
|
||||
var k: Object = a.constructor;
|
||||
|
||||
(123).constructor;
|
||||
|
|
|
@ -33,6 +33,7 @@ var foo = Object.freeze({ bar: \"12345\" });
|
|||
foo.bar = \"23456\";
|
||||
|
||||
Object.assign(foo, { bar: \"12345\" });
|
||||
|
||||
var baz = { baz: 12345 };
|
||||
var bliffl = Object.freeze({ bar: \"12345\", ...baz });
|
||||
|
||||
|
@ -47,6 +48,7 @@ bliffl.constructor = baz;
|
|||
bliffl.toString = function() {};
|
||||
|
||||
baz.baz = 0;
|
||||
|
||||
var x: number = Object.freeze(123);
|
||||
var xx: { x: number } = Object.freeze({ x: \"error\" });
|
||||
"
|
||||
|
|
|
@ -37,6 +37,7 @@ Object.is(0, -0);
|
|||
Object.is(NaN, NaN);
|
||||
|
||||
Object.is({}, {});
|
||||
|
||||
var emptyObject = {};
|
||||
var emptyArray = [];
|
||||
|
||||
|
@ -45,9 +46,11 @@ Object.is(emptyObject, emptyObject);
|
|||
Object.is(emptyArray, emptyArray);
|
||||
|
||||
Object.is(emptyObject, emptyArray);
|
||||
|
||||
var squared = x => x * x;
|
||||
|
||||
Object.is(squared, squared);
|
||||
|
||||
var a: boolean = Object.is(\"a\", \"a\");
|
||||
var b: string = Object.is(\"a\", \"a\");
|
||||
var c: boolean = Object.is(\"a\");
|
||||
|
|
|
@ -37,12 +37,15 @@ var z = Object(123); // error (next line makes this not match any signatures)
|
|||
(Object(void 0): {});
|
||||
|
||||
(Object(undefined): Number);
|
||||
|
||||
var x = Object(null);
|
||||
|
||||
x.foo = \"bar\";
|
||||
|
||||
var y = Object(\"123\");
|
||||
|
||||
(y.charAt(0): string);
|
||||
|
||||
var z = Object(123);
|
||||
|
||||
(z.charAt(0): string);
|
||||
|
@ -101,6 +104,7 @@ x[123] = false;
|
|||
x[\"foo\" + \"bar\"] = \"derp\";
|
||||
|
||||
(x[\`foo\`]: string);
|
||||
|
||||
var y: { foo: string } = { foo: \"bar\" };
|
||||
|
||||
y[\"foo\"] = 123;
|
||||
|
@ -159,17 +163,17 @@ var glob: { x: string } = { x: \"hey\" };
|
|||
|
||||
function assign_then_alias() {
|
||||
var obj: { x: string | number };
|
||||
|
||||
|
||||
obj = { x: \"hey\" };
|
||||
|
||||
|
||||
glob = obj;
|
||||
}
|
||||
|
||||
function assign_then_widen() {
|
||||
var obj: { x: string | number };
|
||||
|
||||
|
||||
obj = { x: \"hey\" };
|
||||
|
||||
|
||||
obj.x = 10;
|
||||
}
|
||||
"
|
||||
|
|
|
@ -33,7 +33,7 @@ var o = keyMirror({ FOO: null, BAR: null });
|
|||
promiseAllByKey({ foo: Promise.resolve(0), bar: \"bar\" }).then(
|
||||
o => {
|
||||
(o.foo: string);
|
||||
|
||||
|
||||
(o.bar: \"bar\");
|
||||
}
|
||||
);
|
||||
|
|
|
@ -28,6 +28,7 @@ class C {
|
|||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
function x<T>(x: T = 0) {}
|
||||
|
||||
class C {
|
||||
x<T>(x: T = 0) {}
|
||||
}
|
||||
|
@ -170,12 +171,14 @@ function bar(x?, y?) {
|
|||
}
|
||||
|
||||
bar(0);
|
||||
|
||||
var foo: (x?: number) => void = bar;
|
||||
|
||||
foo();
|
||||
|
||||
function qux(x = \"hello\", ...y): string {
|
||||
foo(x);
|
||||
|
||||
return y[0];
|
||||
}
|
||||
|
||||
|
@ -229,6 +232,7 @@ function foo(x?: string): string {
|
|||
if (x == null) {
|
||||
return \"foo\";
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -236,6 +240,7 @@ function bar(obj: { x?: string }): string {
|
|||
if (obj.x == null) {
|
||||
return \"foo\";
|
||||
}
|
||||
|
||||
return obj.x;
|
||||
}
|
||||
|
||||
|
@ -243,6 +248,7 @@ function baz(bar?) {
|
|||
if (!bar) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return bar.duck;
|
||||
}
|
||||
|
||||
|
@ -250,6 +256,7 @@ function testOptionalNullable(x?: ?string): string {
|
|||
if (x == null) {
|
||||
return \"foo\";
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -257,6 +264,7 @@ function testOptionalNullableDefault(x?: ?string = \"hi\"): string {
|
|||
if (x == null) {
|
||||
return \"foo\";
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
@ -264,12 +272,13 @@ function testOptionalNullableProperty(obj: { x?: ?string }): string {
|
|||
if (obj.x == null) {
|
||||
return \"foo\";
|
||||
}
|
||||
|
||||
return obj.x;
|
||||
}
|
||||
|
||||
function testOptionalNullableFlowingToNullable(x?: ?string): ?string {
|
||||
var f = function(y: ?string) {};
|
||||
|
||||
|
||||
f(x);
|
||||
}
|
||||
"
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue