Lots of bug fixes (will do smaller commits from now on)
This commit is contained in:
1 parent
88dc2681f6
commit
11a01552a4
286 files changed
+8410
-10878
No files matched your search
@@ -77,7 +77,7 @@ var bar: (str: number, i: number) => string = foo;
|
||||
var qux = function(str: string, i: number): number {
|
||||
return foo(str, i);
|
||||
};
|
||||
var obj: { str: string, i: number, j: boolean } = {
|
||||
var obj: { str: string; i: number; j: boolean } = {
|
||||
str: \"...\",
|
||||
i: \"...\",
|
||||
k: false
|
||||
@@ -89,15 +89,15 @@ var matrix_parens: number[][] = matrix;
|
||||
var nullable_array: ?number[] = null;
|
||||
var nullable_array_parens: ?number[] = nullable_array;
|
||||
var array_of_nullable: ?number[] = [ null, 3 ];
|
||||
var array_of_tuple: [numberstring][] = [ [ 0, \"foo\" ], [ 1, \"bar\" ] ];
|
||||
var array_of_tuple_parens: [numberstring][] = array_of_tuple;
|
||||
type ObjType = { \"bar-foo\": string, \"foo-bar\": number };
|
||||
var array_of_tuple: [number, string][] = [ [ 0, \"foo\" ], [ 1, \"bar\" ] ];
|
||||
var array_of_tuple_parens: [number, string][] = array_of_tuple;
|
||||
type ObjType = { \"bar-foo\": string; \"foo-bar\": number };
|
||||
var test_obj: ObjType = { \"bar-foo\": \"23\" };
|
||||
function param_anno(n: number): void {
|
||||
n = \"hey\";
|
||||
}
|
||||
function param_anno2(
|
||||
batchRequests: Array<{ method: string, path: string, params: ?Object }>
|
||||
batchRequests: Array<{ method: string; path: string; params: ?Object }>
|
||||
): void {
|
||||
batchRequests = batchRequests.map(
|
||||
request => {
|
||||
@@ -249,16 +249,16 @@ class Foo<A> {
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// hypothetical immutable map
|
||||
type Merge<T> = : (a: T, b: T) => T;
|
||||
declare class Map {
|
||||
(): Map<K, V>,
|
||||
insertWith: : (fn: Merge<V>, k: K, v: V) => Map<K, V>
|
||||
type Merge<T> = (a: T, b: T) => T;
|
||||
declare class Map<K, V> {
|
||||
(): Map<K, V>;
|
||||
insertWith(fn: Merge<V>, k: K, v: V): Map<K, V>
|
||||
}
|
||||
declare function foldr(fn: (a: A, b: B) => B, b: B, as: A[]): B;
|
||||
declare function foldr<A, B>(fn: (a: A, b: B) => B, b: B, as: A[]): B;
|
||||
function insertMany<K, V>(
|
||||
merge: Merge<V>, vs: [KV][], m: Map<K, V>
|
||||
merge: Merge<V>, vs: [K, V][], m: Map<K, V>
|
||||
): Map<K, V> {
|
||||
function f([ k, v ], m: Map<K, V>): Map<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);
|
||||
@@ -266,7 +266,7 @@ function insertMany<K, V>(
|
||||
class Foo<A> {
|
||||
bar<B>() {
|
||||
return function(a: A, b: B, c: C): void {
|
||||
([ a, b, c ]: [ABC]);
|
||||
([ a, b, c ]: [A, B, C]);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,14 +20,14 @@ export default class {
|
||||
`;
|
||||
|
||||
exports[`test B.js 1`] = `
|
||||
"import A from \"./A\"
|
||||
"import A from "./A"
|
||||
|
||||
class B extends A {
|
||||
p: string; // OK, string ~> any
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// OK, string ~> any
|
||||
import A from \"./A\";
|
||||
import A from "./A";
|
||||
class B extends A {
|
||||
p: string;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ exports[`test A.js 1`] = `
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import type T from \"T\";
|
||||
import type T from "T";
|
||||
|
||||
export default class {
|
||||
p: T;
|
||||
@@ -18,7 +18,7 @@ export default class {
|
||||
* @providesModule A
|
||||
* @flow
|
||||
*/
|
||||
import type T from \"T\";
|
||||
import type T from "T";
|
||||
export default class {
|
||||
p: T;
|
||||
constructor() {
|
||||
@@ -33,7 +33,7 @@ exports[`test B.js 1`] = `
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import A from \"A\"
|
||||
import A from "A"
|
||||
|
||||
class B extends A {
|
||||
p: string; // OK, string ~> any
|
||||
@@ -43,7 +43,7 @@ class B extends A {
|
||||
* @flow
|
||||
*/
|
||||
// OK, string ~> any
|
||||
import A from \"A\";
|
||||
import A from "A";
|
||||
class B extends A {
|
||||
p: string;
|
||||
}
|
||||
|
||||
@@ -156,14 +156,14 @@ function foo(c: C, x: any): string {
|
||||
return c.bar(0, y); // should be able to select first case and error
|
||||
}
|
||||
|
||||
var any_fun1 = require(\'./nonflowfile\');
|
||||
var any_fun1 = require('./nonflowfile');
|
||||
function bar1(x: mixed) {
|
||||
if (any_fun1(x)) {
|
||||
(x: boolean);
|
||||
}
|
||||
}
|
||||
|
||||
var any_fun2 = require(\'./anyexportflowfile\');
|
||||
var any_fun2 = require('./anyexportflowfile');
|
||||
function bar2(x: mixed) {
|
||||
if (any_fun2(x)) {
|
||||
(x: boolean);
|
||||
@@ -173,20 +173,20 @@ function bar2(x: mixed) {
|
||||
// @flow
|
||||
// should be able to select first case and error
|
||||
declare class C {
|
||||
bar: : (n1: number, n2: number) => number,
|
||||
bar: : (s1: string, s2: string) => string
|
||||
bar(n1: number, n2: number): number;
|
||||
bar(s1: string, s2: string): string
|
||||
}
|
||||
function foo(c: C, x: any): string {
|
||||
let y = x.y;
|
||||
return c.bar(0, y);
|
||||
}
|
||||
var any_fun1 = require(\"./nonflowfile\");
|
||||
var any_fun1 = require("./nonflowfile");
|
||||
function bar1(x: mixed) {
|
||||
if (any_fun1(x)) {
|
||||
(x: boolean);
|
||||
}
|
||||
}
|
||||
var any_fun2 = require(\"./anyexportflowfile\");
|
||||
var any_fun2 = require("./anyexportflowfile");
|
||||
function bar2(x: mixed) {
|
||||
if (any_fun2(x)) {
|
||||
(x: boolean);
|
||||
|
||||
@@ -154,16 +154,16 @@ function bar0(x: ?number, y: number) {
|
||||
function bar1(x: number, y: ?number) {
|
||||
num(x + y);
|
||||
}
|
||||
function bar2(x: number, y: number) {
|
||||
function bar2(x?: number, y: number) {
|
||||
num(x + y);
|
||||
}
|
||||
function bar3(x: number, y: number) {
|
||||
function bar3(x: number, y?: number) {
|
||||
num(x + y);
|
||||
}
|
||||
function bar4(x: ?number, y: number) {
|
||||
function bar4(x?: ?number, y: number) {
|
||||
num(x + y);
|
||||
}
|
||||
function bar5(x: number, y: ?number) {
|
||||
function bar5(x: number, y?: ?number) {
|
||||
num(x + y);
|
||||
}
|
||||
num(null + null);
|
||||
|
||||
@@ -24,7 +24,7 @@ exports[`test test2.js 1`] = `
|
||||
|
||||
function filterItems(items: Array<string|number>): Array<string|number> {
|
||||
return items.map(item => {
|
||||
if (typeof item === \'string\') {
|
||||
if (typeof item === 'string') {
|
||||
return item.length > 2 ? item : null;
|
||||
} else {
|
||||
return item*10;
|
||||
@@ -32,7 +32,7 @@ function filterItems(items: Array<string|number>): Array<string|number> {
|
||||
}).filter(Boolean);
|
||||
}
|
||||
|
||||
const filteredItems = filterItems([\'foo\', \'b\', 1, 2]);
|
||||
const filteredItems = filterItems(['foo', 'b', 1, 2]);
|
||||
|
||||
console.log(filteredItems);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -40,7 +40,7 @@ console.log(filteredItems);
|
||||
function filterItems(items: Array<string | number>): Array<string | number> {
|
||||
return items.map(
|
||||
item => {
|
||||
if (typeof item === \"string\") {
|
||||
if (typeof item === "string") {
|
||||
return (item.length > 2 ? item : null);
|
||||
} else {
|
||||
return item * 10;
|
||||
@@ -48,7 +48,7 @@ function filterItems(items: Array<string | number>): Array<string | number> {
|
||||
}
|
||||
).filter(Boolean);
|
||||
}
|
||||
const filteredItems = filterItems([ \"foo\", \"b\", 1, 2 ]);
|
||||
const filteredItems = filterItems([ "foo", "b", 1, 2 ]);
|
||||
console.log(filteredItems);
|
||||
"
|
||||
`;
|
||||
@@ -5,15 +5,15 @@ 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];
|
||||
var x: Array<string> = ['1', '2'];
|
||||
var y: Array<string> = ['3', ...x];
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var A = [ 1, 2, 3 ];
|
||||
var B = [ ...A ];
|
||||
var C = [ 1, 2, 3 ];
|
||||
B.sort((a, b) => a - b);
|
||||
C.sort((a, b) => a - b);
|
||||
var x: Array<string> = [ \"1\", \"2\" ];
|
||||
var y: Array<string> = [ \"3\", ...x ];
|
||||
var x: Array<string> = [ "1", "2" ];
|
||||
var y: Array<string> = [ "3", ...x ];
|
||||
"
|
||||
`;
|
||||
@@ -3,23 +3,23 @@ exports[`test array_lib.js 1`] = `
|
||||
function foo(x:string) { }
|
||||
|
||||
var a = [0];
|
||||
var b = a.map(function (x) { foo(x); return \"\" + x; });
|
||||
var b = a.map(function (x) { foo(x); return "" + x; });
|
||||
|
||||
var c: number = a[0];
|
||||
var d: number = b[0];
|
||||
|
||||
var e:Array<string> = a.reverse();
|
||||
|
||||
var f = [\"\"];
|
||||
var f = [""];
|
||||
var g:number = f.map(function () { return 0; })[0];
|
||||
|
||||
var h: Array<number> = [1,2,3];
|
||||
var i: Array<string> = [\'a\', \'b\', \'c\'];
|
||||
var i: Array<string> = ['a', 'b', 'c'];
|
||||
var j: Array<number | string> = h.concat(i);
|
||||
var k: Array<number> = h.concat(h);
|
||||
var l: Array<number> = h.concat(1,2,3);
|
||||
var m: Array<number | string> = h.concat(\'a\', \'b\', \'c\');
|
||||
var n: Array<number> = h.concat(\'a\', \'b\', \'c\'); // Error
|
||||
var m: Array<number | string> = h.concat('a', 'b', 'c');
|
||||
var n: Array<number> = h.concat('a', 'b', 'c'); // Error
|
||||
|
||||
function reduce_test() {
|
||||
/* Adapted from the following source:
|
||||
@@ -44,13 +44,13 @@ function reduce_test() {
|
||||
/* Added later, because the above is insufficient */
|
||||
|
||||
// acc is element type of array when no init is provided
|
||||
[\"\"].reduce((acc, str) => acc * str.length); // error, string ~> number
|
||||
[\"\"].reduceRight((acc, str) => acc * str.length); // error, string ~> number
|
||||
[""].reduce((acc, str) => acc * str.length); // error, string ~> number
|
||||
[""].reduceRight((acc, str) => acc * str.length); // error, string ~> number
|
||||
}
|
||||
|
||||
function from_test() {
|
||||
var a: Array<string> = Array.from([1, 2, 3], function(val, index) {
|
||||
return index % 2 ? \"foo\" : String(val);
|
||||
return index % 2 ? "foo" : String(val);
|
||||
});
|
||||
var b: Array<string> = Array.from([1, 2, 3], function(val) {
|
||||
return String(val);
|
||||
@@ -73,25 +73,25 @@ var a = [ 0 ];
|
||||
var b = a.map(
|
||||
function(x) {
|
||||
foo(x);
|
||||
return \"\" + x;
|
||||
return "" + x;
|
||||
}
|
||||
);
|
||||
var c: number = a[0];
|
||||
var d: number = b[0];
|
||||
var e: Array<string> = a.reverse();
|
||||
var f = [ \"\" ];
|
||||
var f = [ "" ];
|
||||
var g: number = f.map(
|
||||
function() {
|
||||
return 0;
|
||||
}
|
||||
)[0];
|
||||
var h: Array<number> = [ 1, 2, 3 ];
|
||||
var i: Array<string> = [ \"a\", \"b\", \"c\" ];
|
||||
var i: Array<string> = [ "a", "b", "c" ];
|
||||
var j: Array<number | string> = h.concat(i);
|
||||
var k: Array<number> = h.concat(h);
|
||||
var l: Array<number> = h.concat(1, 2, 3);
|
||||
var m: Array<number | string> = h.concat(\"a\", \"b\", \"c\");
|
||||
var n: Array<number> = h.concat(\"a\", \"b\", \"c\");
|
||||
var m: Array<number | string> = h.concat("a", "b", "c");
|
||||
var n: Array<number> = h.concat("a", "b", "c");
|
||||
function reduce_test() {
|
||||
[ 0, 1, 2, 3, 4 ].reduce(
|
||||
function(previousValue, currentValue, index, array) {
|
||||
@@ -114,14 +114,14 @@ function reduce_test() {
|
||||
return a.concat(b);
|
||||
}
|
||||
);
|
||||
[ \"\" ].reduce((acc, str) => acc * str.length);
|
||||
[ \"\" ].reduceRight((acc, str) => acc * str.length);
|
||||
[ "" ].reduce((acc, str) => acc * str.length);
|
||||
[ "" ].reduceRight((acc, str) => acc * str.length);
|
||||
}
|
||||
function from_test() {
|
||||
var a: Array<string> = Array.from(
|
||||
[ 1, 2, 3 ],
|
||||
function(val, index) {
|
||||
return (index % 2 ? \"foo\" : String(val));
|
||||
return (index % 2 ? "foo" : String(val));
|
||||
}
|
||||
);
|
||||
var b: Array<string> = Array.from(
|
||||
|
||||
@@ -6,7 +6,7 @@ function foo(x:string) { }
|
||||
|
||||
var a = [];
|
||||
a[0] = 1;
|
||||
a[1] = \"...\";
|
||||
a[1] = "...";
|
||||
|
||||
foo(a[1]);
|
||||
var y;
|
||||
@@ -32,12 +32,12 @@ var abig2: Array<{x:number; y:number}> = [
|
||||
{x:0, y:0},
|
||||
{x:0, y:0},
|
||||
{x:0, y:0, a:true},
|
||||
{x:0, y:0, b:\"hey\"},
|
||||
{x:0, y:0, b:"hey"},
|
||||
{x:0, y:0, c:1},
|
||||
{x:0, y:0, c:\"hey\"}
|
||||
{x:0, y:0, c:"hey"}
|
||||
];
|
||||
|
||||
module.exports = \"arrays\";
|
||||
module.exports = "arrays";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @providesModule Arrays */
|
||||
// for literals, composite element type is union of individuals
|
||||
@@ -47,13 +47,13 @@ function foo(x: string) {
|
||||
}
|
||||
var a = [ ];
|
||||
a[0] = 1;
|
||||
a[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 }> = [
|
||||
var abig2: Array<{ x: number; y: number }> = [
|
||||
{ x: 0, y: 0 },
|
||||
{ x: 0, y: 0 },
|
||||
{ x: 0, y: 0 },
|
||||
@@ -68,11 +68,11 @@ var abig2: Array<{ x: number, y: number }> = [
|
||||
{ x: 0, y: 0 },
|
||||
{ x: 0, y: 0 },
|
||||
{ x: 0, y: 0, a: true },
|
||||
{ x: 0, y: 0, b: \"hey\" },
|
||||
{ x: 0, y: 0, b: "hey" },
|
||||
{ x: 0, y: 0, c: 1 },
|
||||
{ x: 0, y: 0, c: \"hey\" }
|
||||
{ x: 0, y: 0, c: "hey" }
|
||||
];
|
||||
module.exports = \"arrays\";
|
||||
module.exports = "arrays";
|
||||
"
|
||||
`;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ var bad = (x: number): string => x; // Error!
|
||||
|
||||
var ident = <T>(x: T): T => x;
|
||||
(ident(1): number);
|
||||
(ident(\"hi\"): number); // Error
|
||||
(ident("hi"): number); // Error
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/**
|
||||
* @flow
|
||||
@@ -20,7 +20,7 @@ var add = (x: number, y: number): number => x + y;
|
||||
var bad = (x: number): string => x;
|
||||
var ident = <T>(x: T): T => x;
|
||||
(ident(1): number);
|
||||
(ident(\"hi\"): number);
|
||||
(ident("hi"): number);
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -31,7 +31,7 @@ exports[`test arrows.js 1`] = `
|
||||
): Image {
|
||||
var maxPixelWidth = maxWidth;
|
||||
//images = images.sort(function (a, b) { return a.width - b.width });
|
||||
images = images.sort((a, b) => (a.width - b.width) + \"\");
|
||||
images = images.sort((a, b) => (a.width - b.width) + "");
|
||||
return images.find(image => image.width >= maxPixelWidth) ||
|
||||
images[images.length - 1];
|
||||
}
|
||||
@@ -41,7 +41,7 @@ function selectBestEffortImageForWidth(
|
||||
maxWidth: number, images: Array<Image>
|
||||
): Image {
|
||||
var maxPixelWidth = maxWidth;
|
||||
images = images.sort((a, b) => a.width - b.width + \"\");
|
||||
images = images.sort((a, b) => a.width - b.width + "");
|
||||
return images.find(image => image.width >= maxPixelWidth) ||
|
||||
images[images.length - 1];
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
exports[`test foo.js 1`] = `
|
||||
"// Regex literals require a lexer mode change
|
||||
/asdf/g;
|
||||
|
||||
// JSX also requires a lexer mode change
|
||||
<div attr1=\'42\' attr2={\'asdf\'} >asdf</div>;
|
||||
|
||||
// Async arrow functions require backtracking
|
||||
var a = async () => 42;
|
||||
|
||||
// Type annotations have a special lex mode
|
||||
var a: number = 42;
|
||||
|
||||
// Token stream should continue even with parse errors
|
||||
var var
|
||||
a;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* Regex literals require a lexer mode change*/
|
||||
/* JSX also requires a lexer mode change*/
|
||||
// Async arrow functions require backtracking
|
||||
// Type annotations have a special lex mode
|
||||
// Token stream should continue even with parse errors
|
||||
/asdf/g;
|
||||
<div attr1=\"42\" attr2={\"asdf\"}>asdf</div>;
|
||||
var a = async () => 42;
|
||||
var a: number = 42;
|
||||
var var;
|
||||
a;
|
||||
"
|
||||
`;
|
||||
@@ -1,15 +0,0 @@
|
||||
// Regex literals require a lexer mode change
|
||||
/asdf/g;
|
||||
|
||||
// JSX also requires a lexer mode change
|
||||
<div attr1='42' attr2={'asdf'} >asdf</div>;
|
||||
|
||||
// Async arrow functions require backtracking
|
||||
var a = async () => 42;
|
||||
|
||||
// Type annotations have a special lex mode
|
||||
var a: number = 42;
|
||||
|
||||
// Token stream should continue even with parse errors
|
||||
var var
|
||||
a;
|
||||
@@ -1 +0,0 @@
|
||||
run_spec(__dirname);
|
||||
@@ -438,57 +438,6 @@ async function baz() {
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test await_not_in_async.js 1`] = `
|
||||
"// note: currently, await-within-async enforcement is a
|
||||
// done by the parser, which bails after a single error.
|
||||
|
||||
function f() {
|
||||
await 1;
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// note: currently, await-within-async enforcement is a
|
||||
// done by the parser, which bails after a single error.
|
||||
function f() {
|
||||
await;
|
||||
1;
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test await_not_in_async2.js 1`] = `
|
||||
"// note: currently, await-within-async enforcement is a
|
||||
// done by the parser, which bails after a single error.
|
||||
|
||||
function f(x) { return x; }
|
||||
|
||||
f(await 1);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// note: currently, await-within-async enforcement is a
|
||||
// done by the parser, which bails after a single error.
|
||||
function f(x) {
|
||||
return x;
|
||||
}
|
||||
f(await);
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test await_not_in_async3.js 1`] = `
|
||||
"// note: currently, await-within-async enforcement is a
|
||||
// done by the parser, which bails after a single error.
|
||||
|
||||
async function f(x) { return x; }
|
||||
|
||||
f(await 1);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// note: currently, await-within-async enforcement is a
|
||||
// done by the parser, which bails after a single error.
|
||||
async function f(x) {
|
||||
return x;
|
||||
}
|
||||
f(await);
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test await_parse.js 1`] = `
|
||||
"async function f() { await 1; }
|
||||
async function ft<T>(a: T) { await 1; }
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
// note: currently, await-within-async enforcement is a
|
||||
// done by the parser, which bails after a single error.
|
||||
|
||||
function f() {
|
||||
await 1;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
// note: currently, await-within-async enforcement is a
|
||||
// done by the parser, which bails after a single error.
|
||||
|
||||
function f(x) { return x; }
|
||||
|
||||
f(await 1);
|
||||
@@ -1,6 +0,0 @@
|
||||
// note: currently, await-within-async enforcement is a
|
||||
// done by the parser, which bails after a single error.
|
||||
|
||||
async function f(x) { return x; }
|
||||
|
||||
f(await 1);
|
||||
@@ -78,17 +78,13 @@ async function* readLines(path) {
|
||||
}
|
||||
|
||||
async function f() {
|
||||
for await (const line of readLines(\"/path/to/file\")) {
|
||||
for await (const line of readLines("/path/to/file")) {
|
||||
(line: void); // error: string ~> void
|
||||
}
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// error: string ~> void
|
||||
interface File extends {
|
||||
readLine: : () => Promise<string>,
|
||||
close: : () => void,
|
||||
EOF: boolean
|
||||
}
|
||||
interface File { readLine(): Promise<string>; close(): void; EOF: boolean }
|
||||
declare function fileOpen(path: string): Promise<File>;
|
||||
async function* readLines(path) {
|
||||
let file: File = await fileOpen(path);
|
||||
@@ -101,7 +97,7 @@ async function* readLines(path) {
|
||||
}
|
||||
}
|
||||
async function f() {
|
||||
for await (const line of readLines(\"/path/to/file\")) {
|
||||
for await (const line of readLines("/path/to/file")) {
|
||||
(line: void);
|
||||
}
|
||||
}
|
||||
@@ -111,13 +107,13 @@ async function f() {
|
||||
exports[`test return.js 1`] = `
|
||||
"declare var gen: AsyncGenerator<void,string,void>;
|
||||
|
||||
// You can pass whatever you like to return, it doesn\'t need to be related to
|
||||
// the AsyncGenerator\'s return type
|
||||
// You can pass whatever you like to return, it doesn't need to be related to
|
||||
// the AsyncGenerator's return type
|
||||
gen.return(0).then(result => {
|
||||
(result.value: void); // error: string | number ~> void
|
||||
});
|
||||
|
||||
// However, a generator can \"refuse\" the return by catching an exception and
|
||||
// However, a generator can "refuse" the return by catching an exception and
|
||||
// yielding or returning internally.
|
||||
async function *refuse_return() {
|
||||
try {
|
||||
@@ -126,16 +122,16 @@ async function *refuse_return() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
refuse_return().return(\"string\").then(result => {
|
||||
refuse_return().return("string").then(result => {
|
||||
if (result.done) {
|
||||
(result.value: string); // error: number | void ~> string
|
||||
}
|
||||
});
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// You can pass whatever you like to return, it doesn\'t need to be related to
|
||||
// the AsyncGenerator\'s return type
|
||||
// You can pass whatever you like to return, it doesn't need to be related to
|
||||
// the AsyncGenerator's return type
|
||||
// error: string | number ~> void
|
||||
// However, a generator can \"refuse\" the return by catching an exception and
|
||||
// However, a generator can "refuse" the return by catching an exception and
|
||||
// yielding or returning internally.
|
||||
// error: number | void ~> string
|
||||
declare var gen: AsyncGenerator<void, string, void>;
|
||||
@@ -151,7 +147,7 @@ async function* refuse_return() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
refuse_return().return(\"string\").then(
|
||||
refuse_return().return("string").then(
|
||||
result => {
|
||||
if (result.done) {
|
||||
(result.value: string);
|
||||
@@ -171,7 +167,7 @@ exports[`test throw.js 1`] = `
|
||||
}
|
||||
|
||||
(async () => {
|
||||
catch_return().throw(\"\").then(({value}) => {
|
||||
catch_return().throw("").then(({value}) => {
|
||||
if (value !== undefined) {
|
||||
(value: void); // error: number ~> void
|
||||
}
|
||||
@@ -188,7 +184,7 @@ async function *yield_return() {
|
||||
}
|
||||
|
||||
(async () => {
|
||||
yield_return().throw(\"\").then(({value}) => {
|
||||
yield_return().throw("").then(({value}) => {
|
||||
if (value !== undefined) {
|
||||
(value: void); // error: number ~> void
|
||||
}
|
||||
@@ -205,7 +201,7 @@ async function* catch_return() {
|
||||
}
|
||||
}
|
||||
async () => {
|
||||
catch_return().throw(\"\").then(
|
||||
catch_return().throw("").then(
|
||||
({ value }) => {
|
||||
if (value !== undefined) {
|
||||
(value: void);
|
||||
@@ -222,7 +218,7 @@ async function* yield_return() {
|
||||
}
|
||||
}
|
||||
async () => {
|
||||
yield_return().throw(\"\").then(
|
||||
yield_return().throw("").then(
|
||||
({ value }) => {
|
||||
if (value !== undefined) {
|
||||
(value: void);
|
||||
|
||||
@@ -1,25 +1,3 @@
|
||||
exports[`test bar.js 1`] = `
|
||||
"// @flow
|
||||
|
||||
var o = require(\'./unknown\');
|
||||
o.x.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
var o = require(\"./unknown\");
|
||||
o.x.;
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test bool.js 1`] = `
|
||||
"// @flow
|
||||
|
||||
true.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
true.;
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test customfun.js 1`] = `
|
||||
"// @flow
|
||||
|
||||
@@ -45,360 +23,6 @@ m;
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test foo.js 1`] = `
|
||||
"/**
|
||||
* @flow
|
||||
*/
|
||||
|
||||
var obj = {
|
||||
num: 123,
|
||||
str: \'hello\',
|
||||
};
|
||||
|
||||
obj.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/**
|
||||
* @flow
|
||||
*/
|
||||
var obj = { num: 123, str: \"hello\" };
|
||||
obj.;
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test foo_parse_fail.js 1`] = `
|
||||
"/**
|
||||
* @flow
|
||||
*/
|
||||
|
||||
var obj = {
|
||||
num: 123,
|
||||
str: \'hello\',
|
||||
};
|
||||
|
||||
console.log(obj.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/**
|
||||
* @flow
|
||||
*/
|
||||
var obj = { num: 123, str: \"hello\" };
|
||||
console.log(obj.);
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test fun.js 1`] = `
|
||||
"/* @flow */
|
||||
|
||||
function foo(f: () => number) {
|
||||
f.
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
function foo(f: () => number) {
|
||||
f.};
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test function_builtins.js 1`] = `
|
||||
"/* @flow */
|
||||
|
||||
function foo(f: Function) {
|
||||
f.
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
function foo(f: Function) {
|
||||
f.};
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test generics.js 1`] = `
|
||||
"// @flow
|
||||
|
||||
class C<X> { }
|
||||
|
||||
function foo(o: { cn: C<number> }) {
|
||||
o.
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
class C<X> {}
|
||||
function foo(o: { cn: C<number> }) {
|
||||
o.};
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test if.js 1`] = `
|
||||
"// @flow
|
||||
const x = \'\';
|
||||
if (x.)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
const x = \"\";
|
||||
if (x.))
|
||||
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test issue-1368.js 1`] = `
|
||||
"/* @flow */
|
||||
class Test {
|
||||
prop: number;
|
||||
|
||||
constructor(prop: number) {
|
||||
this.prop = prop;
|
||||
}
|
||||
}
|
||||
|
||||
class ExtendTest extends Test {
|
||||
extended: string;
|
||||
|
||||
constructor(extended: string) {
|
||||
super(10);
|
||||
this.extended = extended;
|
||||
}
|
||||
|
||||
method() {
|
||||
this.prop = 12;
|
||||
this./* here */
|
||||
}
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
/* here */
|
||||
class Test {
|
||||
prop: number;
|
||||
constructor(prop: number) {
|
||||
this.prop = prop;
|
||||
}
|
||||
}
|
||||
class ExtendTest extends Test {
|
||||
extended: string;
|
||||
constructor(extended: string) {
|
||||
super(10);
|
||||
this.extended = extended;
|
||||
}
|
||||
method() {
|
||||
this.prop = 12;
|
||||
this.};
|
||||
}
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test jsx1.js 1`] = `
|
||||
"// @flow
|
||||
|
||||
var React = require(\'react\');
|
||||
|
||||
class C extends React.Component {
|
||||
props: { x: number };
|
||||
}
|
||||
<C
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
var React = require(\"react\");
|
||||
class C extends React.Component {
|
||||
props: { x: number };
|
||||
}
|
||||
<C>;
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test jsx2.js 1`] = `
|
||||
"// @flow
|
||||
|
||||
var React = require(\'react\');
|
||||
|
||||
class C extends React.Component {
|
||||
props: { x: number, y: string };
|
||||
}
|
||||
<C x = 0,
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
var React = require(\"react\");
|
||||
class C extends React.Component {
|
||||
props: { x: number, y: string };
|
||||
}
|
||||
<C x=\"\" 0 ,>;
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test num.js 1`] = `
|
||||
"// @flow
|
||||
|
||||
var num = 123;
|
||||
num.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
var num = 123;
|
||||
num.;
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test object_builtins.js 1`] = `
|
||||
"/* @flow */
|
||||
|
||||
function foo(o: Object) {
|
||||
o.
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
function foo(o: Object) {
|
||||
o.};
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test optional.js 1`] = `
|
||||
"// @flow
|
||||
|
||||
function foo(obj: { x?: string, f: (x?: string) => void, o: { x?: string } }) {
|
||||
return obj.
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
function foo(
|
||||
obj: { x?: string, f: : (x?: string) => void, o: { x?: string } }
|
||||
) {
|
||||
return obj.};
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test override.js 1`] = `
|
||||
"// @flow
|
||||
|
||||
class C {
|
||||
override(): number | string { return 0; }
|
||||
}
|
||||
|
||||
class D extends C {
|
||||
foo() { return this.override() }
|
||||
override(): string { return \"\"; }
|
||||
bar() { this.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
class C {
|
||||
override(): number | string {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
class D extends C {
|
||||
foo() {
|
||||
return this.override();
|
||||
}
|
||||
override(): string {
|
||||
return \"\";
|
||||
}
|
||||
bar() {
|
||||
this.;
|
||||
}
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test qux.js 1`] = `
|
||||
"// @flow
|
||||
|
||||
class C { x: number; }
|
||||
|
||||
var c: C = new C;
|
||||
c.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
class C {
|
||||
x: number;
|
||||
}
|
||||
var c: C = new C();
|
||||
c.;
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test str.js 1`] = `
|
||||
"// @flow
|
||||
|
||||
\"hello\".
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
\"hello\".;
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test this.js 1`] = `
|
||||
"/* @flow */
|
||||
|
||||
// issue #1197
|
||||
class Foo {
|
||||
baz: string;
|
||||
bar() {}
|
||||
hello() {
|
||||
this.
|
||||
}
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
// issue #1197
|
||||
class Foo {
|
||||
baz: string;
|
||||
bar() {
|
||||
|
||||
}
|
||||
hello() {
|
||||
this.};
|
||||
}
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test typeparams.js 1`] = `
|
||||
"// @flow
|
||||
|
||||
class Bounds<N: number, F: () => N> {
|
||||
foo: F;
|
||||
bar() {
|
||||
this.foo().
|
||||
}
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
class Bounds<N: number, F: () => N> {
|
||||
foo: F;
|
||||
bar() {
|
||||
this.foo().};
|
||||
}
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test union.js 1`] = `
|
||||
"/* @flow */
|
||||
|
||||
function foo(a: boolean, x: { bar: string }, y: Object) {
|
||||
var z;
|
||||
if (a) {
|
||||
z = x;
|
||||
} else {
|
||||
z = y;
|
||||
}
|
||||
z.
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
function foo(a: boolean, x: { bar: string }, y: Object) {
|
||||
var z;
|
||||
if (a) {
|
||||
z = x;
|
||||
} else {
|
||||
z = y;
|
||||
}
|
||||
z.};
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test unknown.js 1`] = `
|
||||
"// @noflow
|
||||
module.exports = { x: { y: \"\" } };
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
// @flow
|
||||
|
||||
var o = require('./unknown');
|
||||
o.x.
|
||||
@@ -1,3 +0,0 @@
|
||||
// @flow
|
||||
|
||||
true.
|
||||
@@ -1,10 +0,0 @@
|
||||
/**
|
||||
* @flow
|
||||
*/
|
||||
|
||||
var obj = {
|
||||
num: 123,
|
||||
str: 'hello',
|
||||
};
|
||||
|
||||
obj.
|
||||
@@ -1,10 +0,0 @@
|
||||
/**
|
||||
* @flow
|
||||
*/
|
||||
|
||||
var obj = {
|
||||
num: 123,
|
||||
str: 'hello',
|
||||
};
|
||||
|
||||
console.log(obj.
|
||||
@@ -1,5 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
function foo(f: () => number) {
|
||||
f.
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
function foo(f: Function) {
|
||||
f.
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
// @flow
|
||||
|
||||
class C<X> { }
|
||||
|
||||
function foo(o: { cn: C<number> }) {
|
||||
o.
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
// @flow
|
||||
const x = '';
|
||||
if (x.)
|
||||
@@ -1,22 +0,0 @@
|
||||
/* @flow */
|
||||
class Test {
|
||||
prop: number;
|
||||
|
||||
constructor(prop: number) {
|
||||
this.prop = prop;
|
||||
}
|
||||
}
|
||||
|
||||
class ExtendTest extends Test {
|
||||
extended: string;
|
||||
|
||||
constructor(extended: string) {
|
||||
super(10);
|
||||
this.extended = extended;
|
||||
}
|
||||
|
||||
method() {
|
||||
this.prop = 12;
|
||||
this./* here */
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
// @flow
|
||||
|
||||
var React = require('react');
|
||||
|
||||
class C extends React.Component {
|
||||
props: { x: number };
|
||||
}
|
||||
<C
|
||||
@@ -1,8 +0,0 @@
|
||||
// @flow
|
||||
|
||||
var React = require('react');
|
||||
|
||||
class C extends React.Component {
|
||||
props: { x: number, y: string };
|
||||
}
|
||||
<C x = 0,
|
||||
@@ -1,4 +0,0 @@
|
||||
// @flow
|
||||
|
||||
var num = 123;
|
||||
num.
|
||||
@@ -1,5 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
function foo(o: Object) {
|
||||
o.
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
// @flow
|
||||
|
||||
function foo(obj: { x?: string, f: (x?: string) => void, o: { x?: string } }) {
|
||||
return obj.
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
// @flow
|
||||
|
||||
class C {
|
||||
override(): number | string { return 0; }
|
||||
}
|
||||
|
||||
class D extends C {
|
||||
foo() { return this.override() }
|
||||
override(): string { return ""; }
|
||||
bar() { this.
|
||||
@@ -1,6 +0,0 @@
|
||||
// @flow
|
||||
|
||||
class C { x: number; }
|
||||
|
||||
var c: C = new C;
|
||||
c.
|
||||
@@ -1,3 +0,0 @@
|
||||
// @flow
|
||||
|
||||
"hello".
|
||||
@@ -1,10 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
// issue #1197
|
||||
class Foo {
|
||||
baz: string;
|
||||
bar() {}
|
||||
hello() {
|
||||
this.
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
// @flow
|
||||
|
||||
class Bounds<N: number, F: () => N> {
|
||||
foo: F;
|
||||
bar() {
|
||||
this.foo().
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
function foo(a: boolean, x: { bar: string }, y: Object) {
|
||||
var z;
|
||||
if (a) {
|
||||
z = x;
|
||||
} else {
|
||||
z = y;
|
||||
}
|
||||
z.
|
||||
}
|
||||
@@ -4,31 +4,31 @@ exports[`test in.js 1`] = `
|
||||
let tests = [
|
||||
// objects on RHS
|
||||
function() {
|
||||
(\'foo\' in {});
|
||||
(\'foo\' in { foo: null });
|
||||
('foo' in {});
|
||||
('foo' in { foo: null });
|
||||
(0 in {});
|
||||
(0 in { \"0\": null });
|
||||
(0 in { "0": null });
|
||||
},
|
||||
|
||||
// arrays on RHS
|
||||
function() {
|
||||
(\'foo\' in []);
|
||||
('foo' in []);
|
||||
(0 in []);
|
||||
(\'length\' in []);
|
||||
('length' in []);
|
||||
},
|
||||
|
||||
// primitive classes on RHS
|
||||
function() {
|
||||
(\'foo\' in new String(\'bar\'));
|
||||
(\'foo\' in new Number(123));
|
||||
('foo' in new String('bar'));
|
||||
('foo' in new Number(123));
|
||||
},
|
||||
|
||||
// primitives on RHS
|
||||
function() {
|
||||
(\'foo\' in 123); // error
|
||||
(\'foo\' in \'bar\'); // error
|
||||
(\'foo\' in void 0); // error
|
||||
(\'foo\' in null); // error
|
||||
('foo' in 123); // error
|
||||
('foo' in 'bar'); // error
|
||||
('foo' in void 0); // error
|
||||
('foo' in null); // error
|
||||
},
|
||||
|
||||
// bogus stuff on LHS
|
||||
@@ -42,15 +42,15 @@ let tests = [
|
||||
|
||||
// in predicates
|
||||
function() {
|
||||
if (\'foo\' in 123) {} // error
|
||||
if (!\'foo\' in {}) {} // error, !\'foo\' is a boolean
|
||||
if (!(\'foo\' in {})) {}
|
||||
if ('foo' in 123) {} // error
|
||||
if (!'foo' in {}) {} // error, !'foo' is a boolean
|
||||
if (!('foo' in {})) {}
|
||||
},
|
||||
|
||||
// annotations on RHS
|
||||
function(x: Object, y: mixed) {
|
||||
(\'foo\' in x); // ok
|
||||
(\'foo\' in y); // error
|
||||
('foo' in x); // ok
|
||||
('foo' in y); // error
|
||||
},
|
||||
]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -71,31 +71,31 @@ let tests = [
|
||||
// error
|
||||
// in predicates
|
||||
// error
|
||||
// error, !\'foo\' is a boolean
|
||||
// error, !'foo' is a boolean
|
||||
// annotations on RHS
|
||||
// ok
|
||||
// error
|
||||
let tests = [
|
||||
function() {
|
||||
\"foo\" in {};
|
||||
\"foo\" in { foo: null };
|
||||
"foo" in {};
|
||||
"foo" in { foo: null };
|
||||
0 in {};
|
||||
0 in { \"0\": null };
|
||||
0 in { "0": null };
|
||||
},
|
||||
function() {
|
||||
\"foo\" in [ ];
|
||||
"foo" in [ ];
|
||||
0 in [ ];
|
||||
\"length\" in [ ];
|
||||
"length" in [ ];
|
||||
},
|
||||
function() {
|
||||
\"foo\" in new String(\"bar\");
|
||||
\"foo\" in new Number(123);
|
||||
"foo" in new String("bar");
|
||||
"foo" in new Number(123);
|
||||
},
|
||||
function() {
|
||||
\"foo\" in 123;
|
||||
\"foo\" in \"bar\";
|
||||
\"foo\" in void 0;
|
||||
\"foo\" in null;
|
||||
"foo" in 123;
|
||||
"foo" in "bar";
|
||||
"foo" in void 0;
|
||||
"foo" in null;
|
||||
},
|
||||
function() {
|
||||
null in {};
|
||||
@@ -105,19 +105,19 @@ let tests = [
|
||||
false in [ ];
|
||||
},
|
||||
function() {
|
||||
if (\"foo\" in 123) {
|
||||
if ("foo" in 123) {
|
||||
|
||||
}
|
||||
if (!\"foo\" in {}) {
|
||||
if (!"foo" in {}) {
|
||||
|
||||
}
|
||||
if (!(\"foo\" in {})) {
|
||||
if (!("foo" in {})) {
|
||||
|
||||
}
|
||||
},
|
||||
function(x: Object, y: mixed) {
|
||||
\"foo\" in x;
|
||||
\"foo\" in y;
|
||||
"foo" in x;
|
||||
"foo" in y;
|
||||
}
|
||||
];
|
||||
"
|
||||
|
||||
@@ -173,19 +173,19 @@ for (let x: string | File of a.values()) {
|
||||
for (let x: string | File | Blob of a.values()) {
|
||||
|
||||
}
|
||||
for (let [ x, y ] of a.entries()) {
|
||||
for (let [ x, y ]: [string, string | File] of a.entries()) {
|
||||
|
||||
}
|
||||
for (let [ x, y ] of a.entries()) {
|
||||
for (let [ x, y ]: [string, string | File | Blob] of a.entries()) {
|
||||
|
||||
}
|
||||
for (let [ x, y ] of a.entries()) {
|
||||
for (let [ x, y ]: [number, string] of a.entries()) {
|
||||
|
||||
}
|
||||
for (let [ x, y ] of a.entries()) {
|
||||
for (let [ x, y ]: [string, number] of a.entries()) {
|
||||
|
||||
}
|
||||
for (let [ x, y ] of a.entries()) {
|
||||
for (let [ x, y ]: [number, number] of a.entries()) {
|
||||
|
||||
}
|
||||
"
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
exports[`test scope.js 1`] = `
|
||||
"function foo<X, Y:X>(x:X, y:Y):void { }
|
||||
foo(0, \"\");
|
||||
foo(0, "");
|
||||
|
||||
function bar<X:number, Y:X>(x:X, y:Y): number { return y*0; }
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
function foo<X, Y: X>(x: X, y: Y): void {
|
||||
|
||||
}
|
||||
foo(0, \"\");
|
||||
foo(0, "");
|
||||
function bar<X: number, Y: X>(x: X, y: Y): number {
|
||||
return y * 0;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ 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 obj1: {x: number; y: string} = example({x: 0, y: ""});
|
||||
var obj2: {x: number} = example({x: 0});
|
||||
|
||||
var c: C<string> = new C; // error, since T = string is incompatible with number
|
||||
@@ -70,7 +70,7 @@ function example<T: { x: number }>(o: T): T {
|
||||
o.x = 0;
|
||||
return o;
|
||||
}
|
||||
var obj1: { x: number, y: string } = example({ x: 0, y: \"\" });
|
||||
var obj1: { x: number; y: string } = example({ x: 0, y: "" });
|
||||
var obj2: { x: number } = example({ x: 0 });
|
||||
var c: C<string> = new C();
|
||||
var q: number = c.qux(0);
|
||||
|
||||
@@ -3,7 +3,7 @@ exports[`test break.js 1`] = `
|
||||
var x = b ? null: false;
|
||||
var z;
|
||||
while(b) {
|
||||
if (x == null) { z = \"\"; break; }
|
||||
if (x == null) { z = ""; break; }
|
||||
var y:number = x; // error: boolean !~> number
|
||||
}
|
||||
var w:number = z; // 2 errors: ?string !~> number
|
||||
@@ -12,10 +12,10 @@ exports[`test break.js 1`] = `
|
||||
function bar(b) {
|
||||
var x = b ? null: false;
|
||||
if (x == null) return;
|
||||
switch (\"\") {
|
||||
switch ("") {
|
||||
case 0:
|
||||
var y:number = x; // error: boolean !~> number
|
||||
x = \"\";
|
||||
x = "";
|
||||
case 1:
|
||||
var z:number = x; // 2 errors: (boolean | string) !~> number
|
||||
break;
|
||||
@@ -27,10 +27,10 @@ function bar(b) {
|
||||
function bar2(b) {
|
||||
var x = b ? null: false;
|
||||
if (x == null) return;
|
||||
switch (\"\") {
|
||||
switch ("") {
|
||||
case 0: {
|
||||
let y:number = x; // error: boolean !~> number
|
||||
x = \"\";
|
||||
x = "";
|
||||
}
|
||||
case 1: {
|
||||
let z:number = x; // 2 errors: (boolean | string) !~> number
|
||||
@@ -45,7 +45,7 @@ function qux(b) {
|
||||
var z = 0;
|
||||
while(b) {
|
||||
var y:number = z;
|
||||
if (b) { z = \"\"; continue; } // error: string !~> number
|
||||
if (b) { z = ""; continue; } // error: string !~> number
|
||||
z = 0;
|
||||
}
|
||||
var w:number = z; // error: string !~> number
|
||||
@@ -54,10 +54,10 @@ function qux(b) {
|
||||
// same basic test as foo(), but with const. probes the
|
||||
// logic that still uses havoc to do env resets.
|
||||
function test_const() {
|
||||
let st: string = \'abc\';
|
||||
let st: string = 'abc';
|
||||
|
||||
for (let i = 1; i < 100; i++) {
|
||||
const fooRes: ?string = \"HEY\";
|
||||
const fooRes: ?string = "HEY";
|
||||
if (!fooRes) {
|
||||
break;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ function foo(b) {
|
||||
var z;
|
||||
while (b) {
|
||||
if (x == null) {
|
||||
z = \"\";
|
||||
z = "";
|
||||
break;
|
||||
}
|
||||
var y: number = x;
|
||||
@@ -97,10 +97,10 @@ function bar(b) {
|
||||
var x = (b ? null : false);
|
||||
if (x == null)
|
||||
return;
|
||||
switch (\"\") {
|
||||
switch ("") {
|
||||
case 0:
|
||||
var y: number = x;
|
||||
x = \"\";
|
||||
x = "";
|
||||
case 1:
|
||||
var z: number = x;
|
||||
break;
|
||||
@@ -112,11 +112,11 @@ function bar2(b) {
|
||||
var x = (b ? null : false);
|
||||
if (x == null)
|
||||
return;
|
||||
switch (\"\") {
|
||||
switch ("") {
|
||||
case 0:
|
||||
{
|
||||
let y: number = x;
|
||||
x = \"\";
|
||||
x = "";
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
@@ -132,7 +132,7 @@ function qux(b) {
|
||||
while (b) {
|
||||
var y: number = z;
|
||||
if (b) {
|
||||
z = \"\";
|
||||
z = "";
|
||||
continue;
|
||||
}
|
||||
z = 0;
|
||||
@@ -140,9 +140,9 @@ function qux(b) {
|
||||
var w: number = z;
|
||||
}
|
||||
function test_const() {
|
||||
let st: string = \"abc\";
|
||||
let st: string = "abc";
|
||||
for (let i = 1; i < 100; i++) {
|
||||
const fooRes: ?string = \"HEY\";
|
||||
const fooRes: ?string = "HEY";
|
||||
if (!fooRes) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@ module.exports = o;
|
||||
`;
|
||||
|
||||
exports[`test test2.js 1`] = `
|
||||
"var o = require(\'./test\');
|
||||
"var o = require('./test');
|
||||
(o.foo: string);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var o = require(\"./test\");
|
||||
var o = require("./test");
|
||||
(o.foo: string);
|
||||
"
|
||||
`;
|
||||
@@ -216,19 +216,19 @@ function e(x: { (): string; (x: number): string }): () => number {
|
||||
// ...but should notice when a function doesn\'t satisfy them all
|
||||
// Only one call property needs to match the function
|
||||
// ...but you need at least one
|
||||
function a(f: { (): string, (x: number): string }): string {
|
||||
function a(f: { (): string; (x: number): string }): string {
|
||||
return f() + f(123);
|
||||
}
|
||||
var b: { (): string, (x: number): string } = function(x: number): string {
|
||||
var b: { (): string; (x: number): string } = function(x?: number): string {
|
||||
return \"hi\";
|
||||
};
|
||||
var c: { (): string, (x: number): string } = function(x: number): string {
|
||||
var c: { (): string; (x: number): string } = function(x: number): string {
|
||||
return \"hi\";
|
||||
};
|
||||
function d(x: { (): string, (x: number): string }): () => string {
|
||||
function d(x: { (): string; (x: number): string }): () => string {
|
||||
return x;
|
||||
}
|
||||
function e(x: { (): string, (x: number): string }): () => number {
|
||||
function e(x: { (): string; (x: number): string }): () => number {
|
||||
return x;
|
||||
}
|
||||
"
|
||||
|
||||
@@ -10,7 +10,7 @@ function f(x) {
|
||||
|
||||
(f: F);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
type F = { (x: string): number, p?: string };
|
||||
type F = { (x: string): number; p?: string };
|
||||
function f(x) {
|
||||
return x.length;
|
||||
}
|
||||
@@ -53,7 +53,7 @@ function foo(fn: (value: any) => boolean) {
|
||||
foo(Boolean);
|
||||
var dict: { [k: string]: any } = {};
|
||||
dict();
|
||||
interface ICall extends { (x: string): void }
|
||||
interface ICall { (x: string): void }
|
||||
declare var icall: ICall;
|
||||
icall(0);
|
||||
icall.call(null, 0);
|
||||
|
||||
@@ -4,13 +4,3 @@ exports[`test not_flow.js 1`] = `
|
||||
1 * \"foo\";
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test syntax_error.js 1`] = `
|
||||
"/* @flow */
|
||||
|
||||
(
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
null;
|
||||
"
|
||||
`;
|
||||
@@ -1,3 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
(
|
||||
@@ -1,637 +0,0 @@
|
||||
exports[`test base_class.js 1`] = `
|
||||
"// @flow
|
||||
|
||||
class Base {
|
||||
unannotatedField;
|
||||
annotatedField: number;
|
||||
initializedField = 42;
|
||||
initializedFieldWithThis = this.initializedField;
|
||||
annotatedInitializedFieldValid: ?number = 42;
|
||||
annotatedInitializedFieldInvalid: number = \'asdf\'; // Error: string ~> number
|
||||
|
||||
static unannotatedField;
|
||||
static annotatedField: number;
|
||||
static initializedField = \'asdf\';
|
||||
static initializedFieldWithThis = this.initializedField;
|
||||
static annotatedInitializedFieldValid: ?number = 42;
|
||||
static annotatedInitializedFieldInvalid: number = \'asdf\'; // Error: string ~> number
|
||||
}
|
||||
|
||||
var o = new Base();
|
||||
|
||||
/**
|
||||
* Unannotated fields are open.
|
||||
*/
|
||||
(o.unannotatedField: string);
|
||||
(o.unannotatedField: number);
|
||||
(Base.unannotatedField: string);
|
||||
(Base.unannotatedField: number);
|
||||
|
||||
/**
|
||||
* Annotated (but uninitialized) fields still have a type.
|
||||
*/
|
||||
(o.annotatedField: number);
|
||||
(o.annotatedField: string); // Error: number ~> string
|
||||
(Base.annotatedField: number);
|
||||
(Base.annotatedField: string); // Error: number ~> string
|
||||
|
||||
/**
|
||||
* Initialized (but unannotated) fields assume the type of their initializer.
|
||||
*/
|
||||
(o.initializedField: number);
|
||||
(o.initializedField: string); // Error: number ~> string
|
||||
(Base.initializedField: string);
|
||||
(Base.initializedField: number); // Error: string ~> number
|
||||
|
||||
/**
|
||||
* Initialized fields can reference \`this\`.
|
||||
*/
|
||||
(o.initializedFieldWithThis: number);
|
||||
(o.initializedFieldWithThis: string); // Error: number ~> string
|
||||
(Base.initializedFieldWithThis: string);
|
||||
(Base.initializedFieldWithThis: number); // Error: string ~> number
|
||||
|
||||
/**
|
||||
* Initialized + annotated fields take the type of the annotation.
|
||||
* (Note that this matters when the annotation is more general than the type of
|
||||
* the initializer)
|
||||
*/
|
||||
(o.annotatedInitializedFieldValid: ?number);
|
||||
(o.annotatedInitializedFieldValid: number); // Error: ?number ~> number
|
||||
(Base.annotatedInitializedFieldValid: ?number);
|
||||
(Base.annotatedInitializedFieldValid: number); // Error: ?number ~> number
|
||||
|
||||
/**
|
||||
* Initialized + annotated fields where the init/annot combo is a mismatch
|
||||
* should assume the type of the annotation.
|
||||
*
|
||||
* (This happens in addition to erroring at the site of initialization)
|
||||
*/
|
||||
(o.annotatedInitializedFieldInvalid: number);
|
||||
(o.annotatedInitializedFieldInvalid: string); // Error: number ~> string
|
||||
(Base.annotatedInitializedFieldInvalid: number);
|
||||
(Base.annotatedInitializedFieldInvalid: string); // Error: number ~> string
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
// Error: string ~> number
|
||||
// Error: string ~> number
|
||||
/**
|
||||
* Unannotated fields are open.
|
||||
*/
|
||||
/**
|
||||
* Annotated (but uninitialized) fields still have a type.
|
||||
*/
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
/**
|
||||
* Initialized (but unannotated) fields assume the type of their initializer.
|
||||
*/
|
||||
// Error: number ~> string
|
||||
// Error: string ~> number
|
||||
/**
|
||||
* Initialized fields can reference \`this\`.
|
||||
*/
|
||||
// Error: number ~> string
|
||||
// Error: string ~> number
|
||||
/**
|
||||
* Initialized + annotated fields take the type of the annotation.
|
||||
* (Note that this matters when the annotation is more general than the type of
|
||||
* the initializer)
|
||||
*/
|
||||
// Error: ?number ~> number
|
||||
// Error: ?number ~> number
|
||||
/**
|
||||
* Initialized + annotated fields where the init/annot combo is a mismatch
|
||||
* should assume the type of the annotation.
|
||||
*
|
||||
* (This happens in addition to erroring at the site of initialization)
|
||||
*/
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
class Base {
|
||||
unannotatedField;
|
||||
annotatedField: number;
|
||||
initializedField;
|
||||
=(;,
|
||||
=,
|
||||
.,
|
||||
;,
|
||||
:,
|
||||
=,
|
||||
;,
|
||||
:,
|
||||
=,
|
||||
;,
|
||||
unannotatedField,
|
||||
static,
|
||||
:,
|
||||
;,
|
||||
initializedField = \"asdf\",
|
||||
static,
|
||||
=,
|
||||
.,
|
||||
;,
|
||||
annotatedInitializedFieldValid: ?number = 42,
|
||||
static,
|
||||
:,
|
||||
=,
|
||||
;,
|
||||
var,
|
||||
=,
|
||||
Base) {
|
||||
(o.unannotatedField: string);
|
||||
(o.unannotatedField: number);
|
||||
(Base.unannotatedField: string);
|
||||
(Base.unannotatedField: number);
|
||||
(o.annotatedField: number);
|
||||
(o.annotatedField: string);
|
||||
(Base.annotatedField: number);
|
||||
(Base.annotatedField: string);
|
||||
(o.initializedField: number);
|
||||
(o.initializedField: string);
|
||||
(Base.initializedField: string);
|
||||
(Base.initializedField: number);
|
||||
(o.initializedFieldWithThis: number);
|
||||
(o.initializedFieldWithThis: string);
|
||||
(Base.initializedFieldWithThis: string);
|
||||
(Base.initializedFieldWithThis: number);
|
||||
(o.annotatedInitializedFieldValid: ?number);
|
||||
(o.annotatedInitializedFieldValid: number);
|
||||
(Base.annotatedInitializedFieldValid: ?number);
|
||||
(Base.annotatedInitializedFieldValid: number);
|
||||
(o.annotatedInitializedFieldInvalid: number);
|
||||
(o.annotatedInitializedFieldInvalid: string);
|
||||
(Base.annotatedInitializedFieldInvalid: number);
|
||||
(Base.annotatedInitializedFieldInvalid: string);
|
||||
}
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test derived_class.js 1`] = `
|
||||
"// @flow
|
||||
|
||||
class Base {
|
||||
base_unannotatedField;
|
||||
base_annotatedField: number;
|
||||
base_initializedField = 42;
|
||||
base_initializedFieldWithThis = this.base_initializedField;
|
||||
base_annotatedInitializedFieldValid: ?number = 42;
|
||||
base_annotatedInitializedFieldInvalid: number = \'asdf\'; // Error: string ~> number
|
||||
|
||||
static base_unannotatedField;
|
||||
static base_annotatedField: number;
|
||||
static base_initializedField = \'asdf\';
|
||||
static base_initializedFieldWithThis = this.base_initializedField;
|
||||
static base_annotatedInitializedFieldValid: ?number = 42;
|
||||
static base_annotatedInitializedFieldInvalid: number = \'asdf\'; // Error: string ~> number
|
||||
|
||||
inherited_initializer = 42;
|
||||
static inherited_initializer = 42;
|
||||
}
|
||||
|
||||
class Child extends Base {
|
||||
child_unannotatedField;
|
||||
child_annotatedField: number;
|
||||
child_initializedField = 42;
|
||||
child_initializedFieldWithThis = this.child_initializedField;
|
||||
child_annotatedInitializedFieldValid: ?number = 42;
|
||||
child_annotatedInitializedFieldInvalid: number = \'asdf\'; // Error: string ~> number
|
||||
|
||||
static child_unannotatedField;
|
||||
static child_annotatedField: number;
|
||||
static child_initializedField = \'asdf\';
|
||||
static child_initializedFieldWithThis = this.child_initializedField;
|
||||
static child_annotatedInitializedFieldValid: ?number = 42;
|
||||
static child_annotatedInitializedFieldInvalid: number = \'asdf\'; // Error: string ~> number
|
||||
|
||||
inherited_initializer;
|
||||
static inherited_initializer;
|
||||
}
|
||||
|
||||
var o = new Child();
|
||||
|
||||
/**
|
||||
* Unannotated fields are open.
|
||||
*/
|
||||
(o.base_unannotatedField: string);
|
||||
(o.base_unannotatedField: number);
|
||||
(Child.base_unannotatedField: string);
|
||||
(Child.base_unannotatedField: number);
|
||||
|
||||
(o.child_unannotatedField: string);
|
||||
(o.child_unannotatedField: number);
|
||||
(Child.child_unannotatedField: string);
|
||||
(Child.child_unannotatedField: number);
|
||||
|
||||
|
||||
/**
|
||||
* Annotated (but uninitialized) fields still have a type.
|
||||
*/
|
||||
(o.base_annotatedField: number);
|
||||
(o.base_annotatedField: string); // Error: number ~> string
|
||||
(Child.base_annotatedField: number);
|
||||
(Child.base_annotatedField: string); // Error: number ~> string
|
||||
|
||||
(o.child_annotatedField: number);
|
||||
(o.child_annotatedField: string); // Error: number ~> string
|
||||
(Child.child_annotatedField: number);
|
||||
(Child.child_annotatedField: string); // Error: number ~> string
|
||||
|
||||
/**
|
||||
* Initialized (but unannotated) fields assume the type of their initializer.
|
||||
*/
|
||||
(o.base_initializedField: number);
|
||||
(o.base_initializedField: string); // Error: number ~> string
|
||||
(Child.base_initializedField: string);
|
||||
(Child.base_initializedField: number); // Error: string ~> number
|
||||
|
||||
(o.child_initializedField: number);
|
||||
(o.child_initializedField: string); // Error: number ~> string
|
||||
(Child.child_initializedField: string);
|
||||
(Child.child_initializedField: number); // Error: string ~> number
|
||||
|
||||
/**
|
||||
* Initialized fields can reference \`this\`.
|
||||
*/
|
||||
(o.base_initializedFieldWithThis: number);
|
||||
(o.base_initializedFieldWithThis: string); // Error: number ~> string
|
||||
(Child.base_initializedFieldWithThis: string);
|
||||
(Child.base_initializedFieldWithThis: number); // Error: string ~> number
|
||||
|
||||
(o.child_initializedFieldWithThis: number);
|
||||
(o.child_initializedFieldWithThis: string); // Error: number ~> string
|
||||
(Child.child_initializedFieldWithThis: string);
|
||||
(Child.child_initializedFieldWithThis: number); // Error: string ~> number
|
||||
|
||||
/**
|
||||
* Initialized + annotated fields take the type of the annotation.
|
||||
* (Note that this matters when the annotation is more general than the type of
|
||||
* the initializer)
|
||||
*/
|
||||
(o.base_annotatedInitializedFieldValid: ?number);
|
||||
(o.base_annotatedInitializedFieldValid: number); // Error: ?number ~> number
|
||||
(Child.base_annotatedInitializedFieldValid: ?number);
|
||||
(Child.base_annotatedInitializedFieldValid: number); // Error: ?number ~> number
|
||||
|
||||
(o.child_annotatedInitializedFieldValid: ?number);
|
||||
(o.child_annotatedInitializedFieldValid: number); // Error: ?number ~> number
|
||||
(Child.child_annotatedInitializedFieldValid: ?number);
|
||||
(Child.child_annotatedInitializedFieldValid: number); // Error: ?number ~> number
|
||||
|
||||
/**
|
||||
* Initialized + annotated fields where the init/annot combo is a mismatch
|
||||
* should assume the type of the annotation.
|
||||
*
|
||||
* (This happens in addition to erroring at the site of initialization)
|
||||
*/
|
||||
(o.base_annotatedInitializedFieldInvalid: number);
|
||||
(o.base_annotatedInitializedFieldInvalid: string); // Error: number ~> string
|
||||
(Child.base_annotatedInitializedFieldInvalid: number);
|
||||
(Child.base_annotatedInitializedFieldInvalid: string); // Error: number ~> string
|
||||
|
||||
(o.child_annotatedInitializedFieldInvalid: number);
|
||||
(o.child_annotatedInitializedFieldInvalid: string); // Error: number ~> string
|
||||
(Child.child_annotatedInitializedFieldInvalid: number);
|
||||
(Child.child_annotatedInitializedFieldInvalid: string); // Error: number ~> string
|
||||
|
||||
/**
|
||||
* Derived fields without an initializer that shadow base fields *with* an
|
||||
* initializer should have the type of the base field.
|
||||
*/
|
||||
(o.inherited_initializer: number);
|
||||
(o.inherited_initializer: string); // Error: number ~> string
|
||||
(Child.inherited_initializer: number);
|
||||
(Child.inherited_initializer: string); // Error: number ~> string
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
// Error: string ~> number
|
||||
// Error: string ~> number
|
||||
// Error: string ~> number
|
||||
// Error: string ~> number
|
||||
/**
|
||||
* Unannotated fields are open.
|
||||
*/
|
||||
/**
|
||||
* Annotated (but uninitialized) fields still have a type.
|
||||
*/
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
/**
|
||||
* Initialized (but unannotated) fields assume the type of their initializer.
|
||||
*/
|
||||
// Error: number ~> string
|
||||
// Error: string ~> number
|
||||
// Error: number ~> string
|
||||
// Error: string ~> number
|
||||
/**
|
||||
* Initialized fields can reference \`this\`.
|
||||
*/
|
||||
// Error: number ~> string
|
||||
// Error: string ~> number
|
||||
// Error: number ~> string
|
||||
// Error: string ~> number
|
||||
/**
|
||||
* Initialized + annotated fields take the type of the annotation.
|
||||
* (Note that this matters when the annotation is more general than the type of
|
||||
* the initializer)
|
||||
*/
|
||||
// Error: ?number ~> number
|
||||
// Error: ?number ~> number
|
||||
// Error: ?number ~> number
|
||||
// Error: ?number ~> number
|
||||
/**
|
||||
* Initialized + annotated fields where the init/annot combo is a mismatch
|
||||
* should assume the type of the annotation.
|
||||
*
|
||||
* (This happens in addition to erroring at the site of initialization)
|
||||
*/
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
/**
|
||||
* Derived fields without an initializer that shadow base fields *with* an
|
||||
* initializer should have the type of the base field.
|
||||
*/
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
class Base {
|
||||
base_unannotatedField;
|
||||
base_annotatedField: number;
|
||||
base_initializedField;
|
||||
=(;,
|
||||
=,
|
||||
.,
|
||||
;,
|
||||
:,
|
||||
=,
|
||||
;,
|
||||
:,
|
||||
=,
|
||||
;,
|
||||
base_unannotatedField,
|
||||
static,
|
||||
:,
|
||||
;,
|
||||
base_initializedField = \"asdf\",
|
||||
static,
|
||||
=,
|
||||
.,
|
||||
;,
|
||||
base_annotatedInitializedFieldValid: ?number = 42,
|
||||
static,
|
||||
:,
|
||||
=,
|
||||
;,
|
||||
=,
|
||||
;,
|
||||
inherited_initializer = 42,
|
||||
},
|
||||
Child,
|
||||
Base,
|
||||
child_unannotatedField,
|
||||
child_annotatedField: number,
|
||||
child_initializedField = 42,
|
||||
child_initializedFieldWithThis = this.child_initializedField,
|
||||
child_annotatedInitializedFieldValid: ?number = 42,
|
||||
child_annotatedInitializedFieldInvalid: number = \"asdf\",
|
||||
static,
|
||||
;,
|
||||
child_annotatedField: number,
|
||||
static,
|
||||
=,
|
||||
;,
|
||||
child_initializedFieldWithThis = this.child_initializedField,
|
||||
static,
|
||||
:,
|
||||
=,
|
||||
;,
|
||||
child_annotatedInitializedFieldInvalid: number = \"asdf\",
|
||||
inherited_initializer,
|
||||
static,
|
||||
;,
|
||||
var,
|
||||
=,
|
||||
Child) {
|
||||
(o.base_unannotatedField: string);
|
||||
(o.base_unannotatedField: number);
|
||||
(Child.base_unannotatedField: string);
|
||||
(Child.base_unannotatedField: number);
|
||||
(o.child_unannotatedField: string);
|
||||
(o.child_unannotatedField: number);
|
||||
(Child.child_unannotatedField: string);
|
||||
(Child.child_unannotatedField: number);
|
||||
(o.base_annotatedField: number);
|
||||
(o.base_annotatedField: string);
|
||||
(Child.base_annotatedField: number);
|
||||
(Child.base_annotatedField: string);
|
||||
(o.child_annotatedField: number);
|
||||
(o.child_annotatedField: string);
|
||||
(Child.child_annotatedField: number);
|
||||
(Child.child_annotatedField: string);
|
||||
(o.base_initializedField: number);
|
||||
(o.base_initializedField: string);
|
||||
(Child.base_initializedField: string);
|
||||
(Child.base_initializedField: number);
|
||||
(o.child_initializedField: number);
|
||||
(o.child_initializedField: string);
|
||||
(Child.child_initializedField: string);
|
||||
(Child.child_initializedField: number);
|
||||
(o.base_initializedFieldWithThis: number);
|
||||
(o.base_initializedFieldWithThis: string);
|
||||
(Child.base_initializedFieldWithThis: string);
|
||||
(Child.base_initializedFieldWithThis: number);
|
||||
(o.child_initializedFieldWithThis: number);
|
||||
(o.child_initializedFieldWithThis: string);
|
||||
(Child.child_initializedFieldWithThis: string);
|
||||
(Child.child_initializedFieldWithThis: number);
|
||||
(o.base_annotatedInitializedFieldValid: ?number);
|
||||
(o.base_annotatedInitializedFieldValid: number);
|
||||
(Child.base_annotatedInitializedFieldValid: ?number);
|
||||
(Child.base_annotatedInitializedFieldValid: number);
|
||||
(o.child_annotatedInitializedFieldValid: ?number);
|
||||
(o.child_annotatedInitializedFieldValid: number);
|
||||
(Child.child_annotatedInitializedFieldValid: ?number);
|
||||
(Child.child_annotatedInitializedFieldValid: number);
|
||||
(o.base_annotatedInitializedFieldInvalid: number);
|
||||
(o.base_annotatedInitializedFieldInvalid: string);
|
||||
(Child.base_annotatedInitializedFieldInvalid: number);
|
||||
(Child.base_annotatedInitializedFieldInvalid: string);
|
||||
(o.child_annotatedInitializedFieldInvalid: number);
|
||||
(o.child_annotatedInitializedFieldInvalid: string);
|
||||
(Child.child_annotatedInitializedFieldInvalid: number);
|
||||
(Child.child_annotatedInitializedFieldInvalid: string);
|
||||
(o.inherited_initializer: number);
|
||||
(o.inherited_initializer: string);
|
||||
(Child.inherited_initializer: number);
|
||||
(Child.inherited_initializer: string);
|
||||
}
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test generic_class.js 1`] = `
|
||||
"// @flow
|
||||
|
||||
/**
|
||||
* Fields annotated with a generic should assume a type once the type param
|
||||
* is instantiated.
|
||||
*/
|
||||
class ClassAnnotated<T> {
|
||||
p: T;
|
||||
static p: T;
|
||||
}
|
||||
|
||||
var o1 = new ClassAnnotated();
|
||||
o1.p = 42;
|
||||
(o1.p: number);
|
||||
(o1.p: string); // Error: number ~> string
|
||||
ClassAnnotated.p = 42;
|
||||
(ClassAnnotated.p: number);
|
||||
(ClassAnnotated.p: string); // Error: number ~> string
|
||||
|
||||
|
||||
/**
|
||||
* It\'s always an error to initialized a generically-typed field with an
|
||||
* expression of any type other than the generic itself.
|
||||
*/
|
||||
class ClassGenericInitialized<T, U> {
|
||||
invalid: T = 42; // Error: number ~> Generic<T>
|
||||
valid: T = ((42:any):T);
|
||||
|
||||
static invalid: T = 42; // Error: number ~> Generic<T>
|
||||
static valid: T = ((42:any):T);
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
/**
|
||||
* Fields annotated with a generic should assume a type once the type param
|
||||
* is instantiated.
|
||||
*/
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
/**
|
||||
* It\'s always an error to initialized a generically-typed field with an
|
||||
* expression of any type other than the generic itself.
|
||||
*/
|
||||
// Error: number ~> Generic<T>
|
||||
// Error: number ~> Generic<T>
|
||||
class ClassAnnotated<T> {
|
||||
p: T;
|
||||
static p: T;
|
||||
}
|
||||
var o1 = new ClassAnnotated();
|
||||
o1.p = 42;
|
||||
(o1.p: number);
|
||||
(o1.p: string);
|
||||
ClassAnnotated.p = 42;
|
||||
(ClassAnnotated.p: number);
|
||||
(ClassAnnotated.p: string);
|
||||
class ClassGenericInitialized<T, U> {
|
||||
invalid: T;
|
||||
=(;, :, =, (, :): T {
|
||||
static;
|
||||
invalid:
|
||||
T = 42;
|
||||
static;
|
||||
valid:
|
||||
T = ((42: any): T);
|
||||
}
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test scoping.js 1`] = `
|
||||
"// @flow
|
||||
|
||||
var someVar = 42;
|
||||
|
||||
class Foo {
|
||||
outer = someVar;
|
||||
selfTyped: Foo;
|
||||
selfTypedInit = new Foo();
|
||||
|
||||
static outer = someVar;
|
||||
static selfTyped: Foo;
|
||||
static selfTypedInit = new Foo();
|
||||
|
||||
constructor() {
|
||||
var someVar = \'asdf\';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Field initializers execute in a scope immediately under the scope outside the
|
||||
* class definition.
|
||||
*/
|
||||
(new Foo().outer: number);
|
||||
(new Foo().outer: string); // Error: number ~> string
|
||||
(Foo.outer: number);
|
||||
(Foo.outer: string); // Error: number ~> string
|
||||
|
||||
/**
|
||||
* Field initializers should be able to refer to the class type in their type
|
||||
* annotations.
|
||||
*/
|
||||
(new Foo().selfTyped: Foo);
|
||||
(new Foo().selfTyped: number); // Error: Foo ~> number
|
||||
(Foo.selfTyped: Foo);
|
||||
(Foo.selfTyped: number); // Error: Foo ~> number
|
||||
|
||||
(new Foo().selfTypedInit: Foo);
|
||||
(new Foo().selfTypedInit: number); // Error: Foo ~> number
|
||||
(Foo.selfTypedInit: Foo);
|
||||
(Foo.selfTypedInit: number); // Error: Foo ~> number
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
/**
|
||||
* Field initializers execute in a scope immediately under the scope outside the
|
||||
* class definition.
|
||||
*/
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
/**
|
||||
* Field initializers should be able to refer to the class type in their type
|
||||
* annotations.
|
||||
*/
|
||||
// Error: Foo ~> number
|
||||
// Error: Foo ~> number
|
||||
// Error: Foo ~> number
|
||||
// Error: Foo ~> number
|
||||
var someVar = 42;
|
||||
class Foo {
|
||||
outer;
|
||||
=(;, :, ;, =, Foo) {
|
||||
static;
|
||||
outer = someVar;
|
||||
static;
|
||||
selfTyped:
|
||||
Foo;
|
||||
static;
|
||||
selfTypedInit = new Foo();
|
||||
constructor();
|
||||
{
|
||||
var someVar = \"asdf\";
|
||||
}
|
||||
}
|
||||
((Foo) {
|
||||
outer:
|
||||
number;
|
||||
(new Foo().outer: string);
|
||||
(Foo.outer: number);
|
||||
(Foo.outer: string);
|
||||
(new Foo().selfTyped: Foo);
|
||||
(new Foo().selfTyped: number);
|
||||
(Foo.selfTyped: Foo);
|
||||
(Foo.selfTyped: number);
|
||||
(new Foo().selfTypedInit: Foo);
|
||||
(new Foo().selfTypedInit: number);
|
||||
(Foo.selfTypedInit: Foo);
|
||||
(Foo.selfTypedInit: number);
|
||||
}
|
||||
}
|
||||
"
|
||||
`;
|
||||
@@ -1,72 +0,0 @@
|
||||
// @flow
|
||||
|
||||
class Base {
|
||||
unannotatedField;
|
||||
annotatedField: number;
|
||||
initializedField = 42;
|
||||
initializedFieldWithThis = this.initializedField;
|
||||
annotatedInitializedFieldValid: ?number = 42;
|
||||
annotatedInitializedFieldInvalid: number = 'asdf'; // Error: string ~> number
|
||||
|
||||
static unannotatedField;
|
||||
static annotatedField: number;
|
||||
static initializedField = 'asdf';
|
||||
static initializedFieldWithThis = this.initializedField;
|
||||
static annotatedInitializedFieldValid: ?number = 42;
|
||||
static annotatedInitializedFieldInvalid: number = 'asdf'; // Error: string ~> number
|
||||
}
|
||||
|
||||
var o = new Base();
|
||||
|
||||
/**
|
||||
* Unannotated fields are open.
|
||||
*/
|
||||
(o.unannotatedField: string);
|
||||
(o.unannotatedField: number);
|
||||
(Base.unannotatedField: string);
|
||||
(Base.unannotatedField: number);
|
||||
|
||||
/**
|
||||
* Annotated (but uninitialized) fields still have a type.
|
||||
*/
|
||||
(o.annotatedField: number);
|
||||
(o.annotatedField: string); // Error: number ~> string
|
||||
(Base.annotatedField: number);
|
||||
(Base.annotatedField: string); // Error: number ~> string
|
||||
|
||||
/**
|
||||
* Initialized (but unannotated) fields assume the type of their initializer.
|
||||
*/
|
||||
(o.initializedField: number);
|
||||
(o.initializedField: string); // Error: number ~> string
|
||||
(Base.initializedField: string);
|
||||
(Base.initializedField: number); // Error: string ~> number
|
||||
|
||||
/**
|
||||
* Initialized fields can reference `this`.
|
||||
*/
|
||||
(o.initializedFieldWithThis: number);
|
||||
(o.initializedFieldWithThis: string); // Error: number ~> string
|
||||
(Base.initializedFieldWithThis: string);
|
||||
(Base.initializedFieldWithThis: number); // Error: string ~> number
|
||||
|
||||
/**
|
||||
* Initialized + annotated fields take the type of the annotation.
|
||||
* (Note that this matters when the annotation is more general than the type of
|
||||
* the initializer)
|
||||
*/
|
||||
(o.annotatedInitializedFieldValid: ?number);
|
||||
(o.annotatedInitializedFieldValid: number); // Error: ?number ~> number
|
||||
(Base.annotatedInitializedFieldValid: ?number);
|
||||
(Base.annotatedInitializedFieldValid: number); // Error: ?number ~> number
|
||||
|
||||
/**
|
||||
* Initialized + annotated fields where the init/annot combo is a mismatch
|
||||
* should assume the type of the annotation.
|
||||
*
|
||||
* (This happens in addition to erroring at the site of initialization)
|
||||
*/
|
||||
(o.annotatedInitializedFieldInvalid: number);
|
||||
(o.annotatedInitializedFieldInvalid: string); // Error: number ~> string
|
||||
(Base.annotatedInitializedFieldInvalid: number);
|
||||
(Base.annotatedInitializedFieldInvalid: string); // Error: number ~> string
|
||||
@@ -1,134 +0,0 @@
|
||||
// @flow
|
||||
|
||||
class Base {
|
||||
base_unannotatedField;
|
||||
base_annotatedField: number;
|
||||
base_initializedField = 42;
|
||||
base_initializedFieldWithThis = this.base_initializedField;
|
||||
base_annotatedInitializedFieldValid: ?number = 42;
|
||||
base_annotatedInitializedFieldInvalid: number = 'asdf'; // Error: string ~> number
|
||||
|
||||
static base_unannotatedField;
|
||||
static base_annotatedField: number;
|
||||
static base_initializedField = 'asdf';
|
||||
static base_initializedFieldWithThis = this.base_initializedField;
|
||||
static base_annotatedInitializedFieldValid: ?number = 42;
|
||||
static base_annotatedInitializedFieldInvalid: number = 'asdf'; // Error: string ~> number
|
||||
|
||||
inherited_initializer = 42;
|
||||
static inherited_initializer = 42;
|
||||
}
|
||||
|
||||
class Child extends Base {
|
||||
child_unannotatedField;
|
||||
child_annotatedField: number;
|
||||
child_initializedField = 42;
|
||||
child_initializedFieldWithThis = this.child_initializedField;
|
||||
child_annotatedInitializedFieldValid: ?number = 42;
|
||||
child_annotatedInitializedFieldInvalid: number = 'asdf'; // Error: string ~> number
|
||||
|
||||
static child_unannotatedField;
|
||||
static child_annotatedField: number;
|
||||
static child_initializedField = 'asdf';
|
||||
static child_initializedFieldWithThis = this.child_initializedField;
|
||||
static child_annotatedInitializedFieldValid: ?number = 42;
|
||||
static child_annotatedInitializedFieldInvalid: number = 'asdf'; // Error: string ~> number
|
||||
|
||||
inherited_initializer;
|
||||
static inherited_initializer;
|
||||
}
|
||||
|
||||
var o = new Child();
|
||||
|
||||
/**
|
||||
* Unannotated fields are open.
|
||||
*/
|
||||
(o.base_unannotatedField: string);
|
||||
(o.base_unannotatedField: number);
|
||||
(Child.base_unannotatedField: string);
|
||||
(Child.base_unannotatedField: number);
|
||||
|
||||
(o.child_unannotatedField: string);
|
||||
(o.child_unannotatedField: number);
|
||||
(Child.child_unannotatedField: string);
|
||||
(Child.child_unannotatedField: number);
|
||||
|
||||
|
||||
/**
|
||||
* Annotated (but uninitialized) fields still have a type.
|
||||
*/
|
||||
(o.base_annotatedField: number);
|
||||
(o.base_annotatedField: string); // Error: number ~> string
|
||||
(Child.base_annotatedField: number);
|
||||
(Child.base_annotatedField: string); // Error: number ~> string
|
||||
|
||||
(o.child_annotatedField: number);
|
||||
(o.child_annotatedField: string); // Error: number ~> string
|
||||
(Child.child_annotatedField: number);
|
||||
(Child.child_annotatedField: string); // Error: number ~> string
|
||||
|
||||
/**
|
||||
* Initialized (but unannotated) fields assume the type of their initializer.
|
||||
*/
|
||||
(o.base_initializedField: number);
|
||||
(o.base_initializedField: string); // Error: number ~> string
|
||||
(Child.base_initializedField: string);
|
||||
(Child.base_initializedField: number); // Error: string ~> number
|
||||
|
||||
(o.child_initializedField: number);
|
||||
(o.child_initializedField: string); // Error: number ~> string
|
||||
(Child.child_initializedField: string);
|
||||
(Child.child_initializedField: number); // Error: string ~> number
|
||||
|
||||
/**
|
||||
* Initialized fields can reference `this`.
|
||||
*/
|
||||
(o.base_initializedFieldWithThis: number);
|
||||
(o.base_initializedFieldWithThis: string); // Error: number ~> string
|
||||
(Child.base_initializedFieldWithThis: string);
|
||||
(Child.base_initializedFieldWithThis: number); // Error: string ~> number
|
||||
|
||||
(o.child_initializedFieldWithThis: number);
|
||||
(o.child_initializedFieldWithThis: string); // Error: number ~> string
|
||||
(Child.child_initializedFieldWithThis: string);
|
||||
(Child.child_initializedFieldWithThis: number); // Error: string ~> number
|
||||
|
||||
/**
|
||||
* Initialized + annotated fields take the type of the annotation.
|
||||
* (Note that this matters when the annotation is more general than the type of
|
||||
* the initializer)
|
||||
*/
|
||||
(o.base_annotatedInitializedFieldValid: ?number);
|
||||
(o.base_annotatedInitializedFieldValid: number); // Error: ?number ~> number
|
||||
(Child.base_annotatedInitializedFieldValid: ?number);
|
||||
(Child.base_annotatedInitializedFieldValid: number); // Error: ?number ~> number
|
||||
|
||||
(o.child_annotatedInitializedFieldValid: ?number);
|
||||
(o.child_annotatedInitializedFieldValid: number); // Error: ?number ~> number
|
||||
(Child.child_annotatedInitializedFieldValid: ?number);
|
||||
(Child.child_annotatedInitializedFieldValid: number); // Error: ?number ~> number
|
||||
|
||||
/**
|
||||
* Initialized + annotated fields where the init/annot combo is a mismatch
|
||||
* should assume the type of the annotation.
|
||||
*
|
||||
* (This happens in addition to erroring at the site of initialization)
|
||||
*/
|
||||
(o.base_annotatedInitializedFieldInvalid: number);
|
||||
(o.base_annotatedInitializedFieldInvalid: string); // Error: number ~> string
|
||||
(Child.base_annotatedInitializedFieldInvalid: number);
|
||||
(Child.base_annotatedInitializedFieldInvalid: string); // Error: number ~> string
|
||||
|
||||
(o.child_annotatedInitializedFieldInvalid: number);
|
||||
(o.child_annotatedInitializedFieldInvalid: string); // Error: number ~> string
|
||||
(Child.child_annotatedInitializedFieldInvalid: number);
|
||||
(Child.child_annotatedInitializedFieldInvalid: string); // Error: number ~> string
|
||||
|
||||
/**
|
||||
* Derived fields without an initializer that shadow base fields *with* an
|
||||
* initializer should have the type of the base field.
|
||||
*/
|
||||
(o.inherited_initializer: number);
|
||||
(o.inherited_initializer: string); // Error: number ~> string
|
||||
(Child.inherited_initializer: number);
|
||||
(Child.inherited_initializer: string); // Error: number ~> string
|
||||
@@ -1,31 +0,0 @@
|
||||
// @flow
|
||||
|
||||
/**
|
||||
* Fields annotated with a generic should assume a type once the type param
|
||||
* is instantiated.
|
||||
*/
|
||||
class ClassAnnotated<T> {
|
||||
p: T;
|
||||
static p: T;
|
||||
}
|
||||
|
||||
var o1 = new ClassAnnotated();
|
||||
o1.p = 42;
|
||||
(o1.p: number);
|
||||
(o1.p: string); // Error: number ~> string
|
||||
ClassAnnotated.p = 42;
|
||||
(ClassAnnotated.p: number);
|
||||
(ClassAnnotated.p: string); // Error: number ~> string
|
||||
|
||||
|
||||
/**
|
||||
* It's always an error to initialized a generically-typed field with an
|
||||
* expression of any type other than the generic itself.
|
||||
*/
|
||||
class ClassGenericInitialized<T, U> {
|
||||
invalid: T = 42; // Error: number ~> Generic<T>
|
||||
valid: T = ((42:any):T);
|
||||
|
||||
static invalid: T = 42; // Error: number ~> Generic<T>
|
||||
static valid: T = ((42:any):T);
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
run_spec(__dirname);
|
||||
@@ -1,40 +0,0 @@
|
||||
// @flow
|
||||
|
||||
var someVar = 42;
|
||||
|
||||
class Foo {
|
||||
outer = someVar;
|
||||
selfTyped: Foo;
|
||||
selfTypedInit = new Foo();
|
||||
|
||||
static outer = someVar;
|
||||
static selfTyped: Foo;
|
||||
static selfTypedInit = new Foo();
|
||||
|
||||
constructor() {
|
||||
var someVar = 'asdf';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Field initializers execute in a scope immediately under the scope outside the
|
||||
* class definition.
|
||||
*/
|
||||
(new Foo().outer: number);
|
||||
(new Foo().outer: string); // Error: number ~> string
|
||||
(Foo.outer: number);
|
||||
(Foo.outer: string); // Error: number ~> string
|
||||
|
||||
/**
|
||||
* Field initializers should be able to refer to the class type in their type
|
||||
* annotations.
|
||||
*/
|
||||
(new Foo().selfTyped: Foo);
|
||||
(new Foo().selfTyped: number); // Error: Foo ~> number
|
||||
(Foo.selfTyped: Foo);
|
||||
(Foo.selfTyped: number); // Error: Foo ~> number
|
||||
|
||||
(new Foo().selfTypedInit: Foo);
|
||||
(new Foo().selfTypedInit: number); // Error: Foo ~> number
|
||||
(Foo.selfTypedInit: Foo);
|
||||
(Foo.selfTypedInit: number); // Error: Foo ~> number
|
||||
@@ -12,9 +12,9 @@ class B extends A {
|
||||
static foo(x: string) { } // error?
|
||||
static main() {
|
||||
B.x = 0; // error
|
||||
B.x = \"\";
|
||||
B.x = "";
|
||||
B.foo(0); // error
|
||||
B.foo(\"\");
|
||||
B.foo("");
|
||||
B.y = 0; // error
|
||||
B.bar(0); // error
|
||||
B.qux(0); // error
|
||||
@@ -94,9 +94,9 @@ class B extends A {
|
||||
}
|
||||
static main() {
|
||||
B.x = 0;
|
||||
B.x = \"\";
|
||||
B.x = "";
|
||||
B.foo(0);
|
||||
B.foo(\"\");
|
||||
B.foo("");
|
||||
B.y = 0;
|
||||
B.bar(0);
|
||||
B.qux(0);
|
||||
|
||||
@@ -14,7 +14,7 @@ module.exports = { A, B };
|
||||
|
||||
exports[`test test2.js 1`] = `
|
||||
"/* @flow */
|
||||
var I = require(\"./test.js\");
|
||||
var I = require("./test.js");
|
||||
|
||||
class C extends I.A {}
|
||||
|
||||
@@ -22,7 +22,7 @@ var x: I.A = new C();
|
||||
var y: I.B = new C();
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
var I = require(\"./test.js\");
|
||||
var I = require("./test.js");
|
||||
class C extends I.A {}
|
||||
var x: I.A = new C();
|
||||
var y: I.B = new C();
|
||||
|
||||
@@ -47,7 +47,7 @@ check(B, new C);
|
||||
// A function to typecheck values against their types. Covariance of Class<.>
|
||||
// makes it useless in such a function (when limited to classes and instances),
|
||||
// since everything can be trivially satisfied by going to \`mixed\`.
|
||||
declare function check(cls: $Type<X>, inst: X): void;
|
||||
declare function check<X>(cls: $Type<X>, inst: X): void;
|
||||
class A {}
|
||||
class B extends A {}
|
||||
class C {}
|
||||
|
||||
@@ -120,7 +120,7 @@ var w : Foo = z;
|
||||
// conflicts with cast to Foo
|
||||
// conflicts with cast to Foo
|
||||
// conflicts with cast to Foo
|
||||
type Foo = { a: string, b: string, c?: ?string, d?: number };
|
||||
type Foo = { a: string; b: string; c?: ?string; d?: number };
|
||||
class TestClass {
|
||||
a: string;
|
||||
c: ?string;
|
||||
|
||||
@@ -13,11 +13,11 @@ module.exports = f;
|
||||
|
||||
exports[`test Rel.js 1`] = `
|
||||
"
|
||||
var f = require(\'./Abs\');
|
||||
var f = require('./Abs');
|
||||
|
||||
f(0);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var f = require(\"./Abs\");
|
||||
var f = require("./Abs");
|
||||
f(0);
|
||||
"
|
||||
`;
|
||||
@@ -1,14 +1,14 @@
|
||||
exports[`test test.js 1`] = `
|
||||
"var ColorId = {
|
||||
RED: \'R\',
|
||||
GREEN: \'G\',
|
||||
BLUE: \'B\',
|
||||
RED: 'R',
|
||||
GREEN: 'G',
|
||||
BLUE: 'B',
|
||||
};
|
||||
|
||||
var ColorNumber = {
|
||||
RED: \'ff0000\',
|
||||
GREEN: \'00ff00\',
|
||||
BLUE: \'0000ff\',
|
||||
RED: 'ff0000',
|
||||
GREEN: '00ff00',
|
||||
BLUE: '0000ff',
|
||||
};
|
||||
|
||||
var ColorIdToNumber = {
|
||||
@@ -17,7 +17,7 @@ var ColorIdToNumber = {
|
||||
[ColorId.BLUE]: ColorNumber.BLUE,
|
||||
};
|
||||
|
||||
(ColorIdToNumber[ColorId.RED]: \'ffffff\'); // oops
|
||||
(ColorIdToNumber[ColorId.RED]: 'ffffff'); // oops
|
||||
|
||||
ColorIdToNumber.XXX; // oops
|
||||
|
||||
@@ -25,91 +25,91 @@ module.exports = { ColorId, ColorNumber };
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// oops
|
||||
// oops
|
||||
var ColorId = { RED: \"R\", GREEN: \"G\", BLUE: \"B\" };
|
||||
var ColorNumber = { RED: \"ff0000\", GREEN: \"00ff00\", BLUE: \"0000ff\" };
|
||||
var ColorId = { RED: "R", GREEN: "G", BLUE: "B" };
|
||||
var ColorNumber = { RED: "ff0000", GREEN: "00ff00", BLUE: "0000ff" };
|
||||
var ColorIdToNumber = {
|
||||
[ColorId.RED]: ColorNumber.RED,
|
||||
[ColorId.GREEN]: ColorNumber.GREEN,
|
||||
[ColorId.BLUE]: ColorNumber.BLUE
|
||||
};
|
||||
(ColorIdToNumber[ColorId.RED]: \"ffffff\");
|
||||
(ColorIdToNumber[ColorId.RED]: "ffffff");
|
||||
ColorIdToNumber.XXX;
|
||||
module.exports = { ColorId, ColorNumber };
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test test2.js 1`] = `
|
||||
"var { ColorId, ColorNumber } = require(\'./test\');
|
||||
"var { ColorId, ColorNumber } = require('./test');
|
||||
var ColorIdToNumber = {
|
||||
[ColorId.RED]: ColorNumber.RED,
|
||||
[ColorId.GREEN]: ColorNumber.GREEN,
|
||||
[ColorId.BLUE]: ColorNumber.BLUE,
|
||||
};
|
||||
|
||||
(ColorIdToNumber[ColorId.GREEN]: \'ffffff\'); // oops
|
||||
(ColorIdToNumber[ColorId.GREEN]: 'ffffff'); // oops
|
||||
|
||||
module.exports = ColorIdToNumber;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// oops
|
||||
var { ColorId, ColorNumber } = require(\"./test\");
|
||||
var { ColorId, ColorNumber } = require("./test");
|
||||
var ColorIdToNumber = {
|
||||
[ColorId.RED]: ColorNumber.RED,
|
||||
[ColorId.GREEN]: ColorNumber.GREEN,
|
||||
[ColorId.BLUE]: ColorNumber.BLUE
|
||||
};
|
||||
(ColorIdToNumber[ColorId.GREEN]: \"ffffff\");
|
||||
(ColorIdToNumber[ColorId.GREEN]: "ffffff");
|
||||
module.exports = ColorIdToNumber;
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test test3.js 1`] = `
|
||||
"var { ColorId } = require(\'./test\');
|
||||
var ColorIdToNumber = require(\'./test2\');
|
||||
"var { ColorId } = require('./test');
|
||||
var ColorIdToNumber = require('./test2');
|
||||
|
||||
(ColorIdToNumber[ColorId.BLUE]: \'ffffff\'); // oops
|
||||
(ColorIdToNumber[ColorId.BLUE]: 'ffffff'); // oops
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// oops
|
||||
var { ColorId } = require(\"./test\");
|
||||
var ColorIdToNumber = require(\"./test2\");
|
||||
(ColorIdToNumber[ColorId.BLUE]: \"ffffff\");
|
||||
var { ColorId } = require("./test");
|
||||
var ColorIdToNumber = require("./test2");
|
||||
(ColorIdToNumber[ColorId.BLUE]: "ffffff");
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test test4.js 1`] = `
|
||||
"module.exports = \'hello\';
|
||||
"module.exports = 'hello';
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
module.exports = \"hello\";
|
||||
module.exports = "hello";
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test test5.js 1`] = `
|
||||
"var hello = require(\'./test4\');
|
||||
var dummy = require(\'./test\');
|
||||
"var hello = require('./test4');
|
||||
var dummy = require('./test');
|
||||
module.exports = {
|
||||
...dummy,
|
||||
[hello]: \'world\',
|
||||
[hello]: 'world',
|
||||
...dummy,
|
||||
};
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var hello = require(\"./test4\");
|
||||
var dummy = require(\"./test\");
|
||||
module.exports = { ...dummy, [hello]: \"world\", ...dummy };
|
||||
var hello = require("./test4");
|
||||
var dummy = require("./test");
|
||||
module.exports = { ...dummy, [hello]: "world", ...dummy };
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test test6.js 1`] = `
|
||||
"var o = require(\'./test5\');
|
||||
(o.hello: \'nothing\'); // oops
|
||||
"var o = require('./test5');
|
||||
(o.hello: 'nothing'); // oops
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// oops
|
||||
var o = require(\"./test5\");
|
||||
(o.hello: \"nothing\");
|
||||
var o = require("./test5");
|
||||
(o.hello: "nothing");
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test test7.js 1`] = `
|
||||
"var obj = {x: 0, m() { return this.x }}
|
||||
var x: string = obj[\'m\'](); // error, number ~> string
|
||||
var x: string = obj['m'](); // error, number ~> string
|
||||
|
||||
var arr = [function() { return this.length }];
|
||||
var y: string = arr[0](); // error: number ~> string
|
||||
@@ -122,7 +122,7 @@ var obj = {
|
||||
return this.x;
|
||||
}
|
||||
};
|
||||
var x: string = obj[\"m\"]();
|
||||
var x: string = obj["m"]();
|
||||
var arr = [
|
||||
function() {
|
||||
return this.length;
|
||||
|
||||
@@ -4,21 +4,21 @@ exports[`test test.js 1`] = `
|
||||
*/
|
||||
|
||||
function foo(x) {
|
||||
var a: number = \'asdf\';
|
||||
var a: number = 'asdf';
|
||||
return x * 10;
|
||||
}
|
||||
|
||||
// This file should be ignored, so this should not result in an error
|
||||
foo(\'Hello, world!\');
|
||||
foo('Hello, world!');
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/*
|
||||
* @flow
|
||||
*/
|
||||
// This file should be ignored, so this should not result in an error
|
||||
function foo(x) {
|
||||
var a: number = \"asdf\";
|
||||
var a: number = "asdf";
|
||||
return x * 10;
|
||||
}
|
||||
foo(\"Hello, world!\");
|
||||
foo("Hello, world!");
|
||||
"
|
||||
`;
|
||||
@@ -1,31 +1,31 @@
|
||||
exports[`test A.js 1`] = `
|
||||
"/* @flow */
|
||||
|
||||
var m1 = require(\'1DoesntExist\');
|
||||
import {numVal as numVal1} from \'1DoesntExist\';
|
||||
var m1 = require('1DoesntExist');
|
||||
import {numVal as numVal1} from '1DoesntExist';
|
||||
var a_1: number = m1.numVal;
|
||||
var a_2: number = numVal1;
|
||||
|
||||
// Error: \'Exists2\' is not a valid module name
|
||||
// Error: 'Exists2' is not a valid module name
|
||||
//
|
||||
// This tests that, for haste, the first name_mapper regexp that happens to
|
||||
// match the given module name string is picked.
|
||||
var m2 = require(\'2DoesntExist\'); // Error
|
||||
import {numVal as numVal2} from \'3DoesntExist\'; // Error
|
||||
var m2 = require('2DoesntExist'); // Error
|
||||
import {numVal as numVal2} from '3DoesntExist'; // Error
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
// Error: \'Exists2\' is not a valid module name
|
||||
// Error: 'Exists2' is not a valid module name
|
||||
//
|
||||
// This tests that, for haste, the first name_mapper regexp that happens to
|
||||
// match the given module name string is picked.
|
||||
// Error
|
||||
// Error
|
||||
var m1 = require(\"1DoesntExist\");
|
||||
import { numVal as numVal1 } from \"1DoesntExist\";
|
||||
var m1 = require("1DoesntExist");
|
||||
import { numVal as numVal1 } from "1DoesntExist";
|
||||
var a_1: number = m1.numVal;
|
||||
var a_2: number = numVal1;
|
||||
var m2 = require(\"2DoesntExist\");
|
||||
import { numVal as numVal2 } from \"3DoesntExist\";
|
||||
var m2 = require("2DoesntExist");
|
||||
import { numVal as numVal2 } from "3DoesntExist";
|
||||
"
|
||||
`;
|
||||
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
exports[`test A.js 1`] = `
|
||||
"/* @flow */
|
||||
|
||||
var m1 = require(\'./1DoesntExist\');
|
||||
var m1 = require('./1DoesntExist');
|
||||
var a_1: number = m1.numVal;
|
||||
var a_2: string = m1.numVal; // Error: number ~> string
|
||||
import {numVal} from \'./1DoesntExist\';
|
||||
import {numVal} from './1DoesntExist';
|
||||
var a_3: number = numVal;
|
||||
var a_4: string = numVal; // Error: number ~> string
|
||||
|
||||
// This tests that, for node, the first name mapping that both matches *and*
|
||||
// results in a valid module filename is picked.
|
||||
var m2 = require(\'./2DoesntExist\');
|
||||
var m2 = require('./2DoesntExist');
|
||||
var b_1: number = m2.numVal;
|
||||
var b_2: string = m2.numVal; // Error: number ~> string
|
||||
import {numVal as numVal2} from \'./3DoesntExist\';
|
||||
import {numVal as numVal2} from './3DoesntExist';
|
||||
var b_3: number = numVal2;
|
||||
var b_4: string = numVal2; // Error: number ~> string
|
||||
|
||||
// node_modules/Exists/index.js
|
||||
var m3 = require(\'4DoesntExist\');
|
||||
var m3 = require('4DoesntExist');
|
||||
var c_1: number = m3.numVal;
|
||||
var c_2: string = m3.numVal; // Error: number ~> string
|
||||
import {numVal as numVal3} from \'5DoesntExist\';
|
||||
import {numVal as numVal3} from '5DoesntExist';
|
||||
var c_3: number = numVal3;
|
||||
var c_4: string = numVal3; // Error: number ~> string
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -35,22 +35,22 @@ var c_4: string = numVal3; // Error: number ~> string
|
||||
// node_modules/Exists/index.js
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
var m1 = require(\"./1DoesntExist\");
|
||||
var m1 = require("./1DoesntExist");
|
||||
var a_1: number = m1.numVal;
|
||||
var a_2: string = m1.numVal;
|
||||
import { numVal } from \"./1DoesntExist\";
|
||||
import { numVal } from "./1DoesntExist";
|
||||
var a_3: number = numVal;
|
||||
var a_4: string = numVal;
|
||||
var m2 = require(\"./2DoesntExist\");
|
||||
var m2 = require("./2DoesntExist");
|
||||
var b_1: number = m2.numVal;
|
||||
var b_2: string = m2.numVal;
|
||||
import { numVal as numVal2 } from \"./3DoesntExist\";
|
||||
import { numVal as numVal2 } from "./3DoesntExist";
|
||||
var b_3: number = numVal2;
|
||||
var b_4: string = numVal2;
|
||||
var m3 = require(\"4DoesntExist\");
|
||||
var m3 = require("4DoesntExist");
|
||||
var c_1: number = m3.numVal;
|
||||
var c_2: string = m3.numVal;
|
||||
import { numVal as numVal3 } from \"5DoesntExist\";
|
||||
import { numVal as numVal3 } from "5DoesntExist";
|
||||
var c_3: number = numVal3;
|
||||
var c_4: string = numVal3;
|
||||
"
|
||||
|
||||
@@ -12,7 +12,7 @@ class A {
|
||||
return 1;
|
||||
}
|
||||
static _sMethod(): string {
|
||||
return \"some string\";
|
||||
return "some string";
|
||||
}
|
||||
}
|
||||
A._sProperty = 48;
|
||||
@@ -23,16 +23,16 @@ class B extends A {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this._property1 = \"another string\";
|
||||
this._property1 = "another string";
|
||||
}
|
||||
_method1(): string {
|
||||
return \"yet another string\";
|
||||
return "yet another string";
|
||||
}
|
||||
static _sMethod(): number {
|
||||
return 23;
|
||||
}
|
||||
}
|
||||
B._sProperty = \"B._sProperty string\";
|
||||
B._sProperty = "B._sProperty string";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
class A {
|
||||
@@ -45,7 +45,7 @@ class A {
|
||||
return 1;
|
||||
}
|
||||
static _sMethod(): string {
|
||||
return \"some string\";
|
||||
return "some string";
|
||||
}
|
||||
}
|
||||
A._sProperty = 48;
|
||||
@@ -54,16 +54,16 @@ class B extends A {
|
||||
static _sProperty: string;
|
||||
constructor() {
|
||||
super();
|
||||
this._property1 = \"another string\";
|
||||
this._property1 = "another string";
|
||||
}
|
||||
_method1(): string {
|
||||
return \"yet another string\";
|
||||
return "yet another string";
|
||||
}
|
||||
static _sMethod(): number {
|
||||
return 23;
|
||||
}
|
||||
}
|
||||
B._sProperty = \"B._sProperty string\";
|
||||
B._sProperty = "B._sProperty string";
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -87,9 +87,9 @@ module.exports = new C();
|
||||
exports[`test commonjs_import.js 1`] = `
|
||||
"/* @flow */
|
||||
|
||||
import {_p} from \"./commonjs_export\";
|
||||
import {_p} from "./commonjs_export";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
import { _p } from \"./commonjs_export\";
|
||||
import { _p } from "./commonjs_export";
|
||||
"
|
||||
`;
|
||||
@@ -12,7 +12,7 @@ class A {
|
||||
return 1;
|
||||
}
|
||||
static _sMethod(): string {
|
||||
return \"some string\";
|
||||
return "some string";
|
||||
}
|
||||
}
|
||||
A._sProperty = 48;
|
||||
@@ -23,16 +23,16 @@ class B extends A {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this._property1 = \"another string\";
|
||||
this._property1 = "another string";
|
||||
}
|
||||
_method1(): string {
|
||||
return \"yet another string\";
|
||||
return "yet another string";
|
||||
}
|
||||
static _sMethod(): number {
|
||||
return 23;
|
||||
}
|
||||
}
|
||||
B._sProperty = \"B._sProperty string\";
|
||||
B._sProperty = "B._sProperty string";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
class A {
|
||||
@@ -45,7 +45,7 @@ class A {
|
||||
return 1;
|
||||
}
|
||||
static _sMethod(): string {
|
||||
return \"some string\";
|
||||
return "some string";
|
||||
}
|
||||
}
|
||||
A._sProperty = 48;
|
||||
@@ -54,15 +54,15 @@ class B extends A {
|
||||
static _sProperty: string;
|
||||
constructor() {
|
||||
super();
|
||||
this._property1 = \"another string\";
|
||||
this._property1 = "another string";
|
||||
}
|
||||
_method1(): string {
|
||||
return \"yet another string\";
|
||||
return "yet another string";
|
||||
}
|
||||
static _sMethod(): number {
|
||||
return 23;
|
||||
}
|
||||
}
|
||||
B._sProperty = \"B._sProperty string\";
|
||||
B._sProperty = "B._sProperty string";
|
||||
"
|
||||
`;
|
||||
@@ -39,8 +39,8 @@ Foo.prototype = {
|
||||
}
|
||||
};
|
||||
exports.Foo = Foo;
|
||||
interface IFooPrototype extends { m: : () => number }
|
||||
interface IFoo extends IFooPrototype { (): void, x: boolean, y: boolean }
|
||||
interface IFooPrototype { m(): number }
|
||||
interface IFoo extends IFooPrototype { (): void; x: boolean; static y: boolean }
|
||||
exports.Foo2 = (Foo: Class<IFoo>);
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -5,11 +5,11 @@ exports[`test dummy.js 1`] = `
|
||||
`;
|
||||
|
||||
exports[`test test.js 1`] = `
|
||||
"require(\'./dummy\');
|
||||
"require('./dummy');
|
||||
var xxx = 0;
|
||||
xxx
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
require(\"./dummy\");
|
||||
require("./dummy");
|
||||
var xxx = 0;
|
||||
xxx;
|
||||
"
|
||||
|
||||
@@ -5,11 +5,11 @@ exports[`test dummy.js 1`] = `
|
||||
`;
|
||||
|
||||
exports[`test test.js 1`] = `
|
||||
"require(\'./dummy\');
|
||||
"require('./dummy');
|
||||
var xxx = 0;
|
||||
xxx
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
require(\"./dummy\");
|
||||
require("./dummy");
|
||||
var xxx = 0;
|
||||
xxx;
|
||||
"
|
||||
|
||||
@@ -124,7 +124,7 @@ let tests = [
|
||||
// get()
|
||||
// error, string | void
|
||||
// error, wrong key type
|
||||
function* generator(): Iterable<[stringnumber]> {
|
||||
function* generator(): Iterable<[string, number]> {
|
||||
while (true) {
|
||||
yield [ \"foo\", 123 ];
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ exports[`test test.js 1`] = `
|
||||
"type CovArrayVerbose<X,Y:X> = Array<Y>;
|
||||
var b: CovArrayVerbose<number,*> = [];
|
||||
var y: CovArrayVerbose<mixed,*> = b;
|
||||
y[0] = \"\"; // error
|
||||
y[0] = ""; // error
|
||||
|
||||
class NVerbose<E,I:E> {
|
||||
x: CovArrayVerbose<E,I>;
|
||||
@@ -22,12 +22,12 @@ var z: CovArray<string> = c; // error
|
||||
|
||||
var d: CovArray<number> = [];
|
||||
var w: CovArray<mixed> = d;
|
||||
w[0] = \"\"; // error
|
||||
w[0] = ""; // error
|
||||
|
||||
type P<X> = CovArray<X>;
|
||||
var p: P<mixed> = [];
|
||||
(p[0]: number); // not an error!
|
||||
p[0] = \"\"; // error
|
||||
p[0] = ""; // error
|
||||
|
||||
class M {
|
||||
x: CovArray<number>;
|
||||
@@ -60,12 +60,12 @@ var z: CovArray<string> = c; // error
|
||||
|
||||
var d: CovArray<number> = [];
|
||||
var w: CovArray<mixed> = d;
|
||||
w[0] = \"\"; // error
|
||||
w[0] = ""; // error
|
||||
|
||||
type P<X> = CovArray<X>;
|
||||
var p: P<mixed> = [];
|
||||
(p[0]: number); // not an error!
|
||||
p[0] = \"\"; // error
|
||||
p[0] = ""; // error
|
||||
|
||||
class M {
|
||||
x: CovArray<number>;
|
||||
@@ -89,7 +89,7 @@ n.x = [0];
|
||||
type CovArrayVerbose<X, Y: X> = Array<Y>;
|
||||
var b: CovArrayVerbose<number, *> = [ ];
|
||||
var y: CovArrayVerbose<mixed, *> = b;
|
||||
y[0] = \"\";
|
||||
y[0] = "";
|
||||
class NVerbose<E, I: E> {
|
||||
x: CovArrayVerbose<E, I>;
|
||||
foo(): CovArrayVerbose<mixed, I> {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
exports[`test crash.js 1`] = `
|
||||
"// This file triggers a violation of the \"disjoint-or-nested ranges invariant\"
|
||||
"// This file triggers a violation of the "disjoint-or-nested ranges invariant"
|
||||
// that we implicitly assume in type-at-pos and coverage implementations. In
|
||||
// particular, when unchecked it causes a crash with coverage --color.
|
||||
|
||||
@@ -11,7 +11,7 @@ declare module bar {
|
||||
|
||||
// TODO
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// This file triggers a violation of the \"disjoint-or-nested ranges invariant\"
|
||||
// This file triggers a violation of the "disjoint-or-nested ranges invariant"
|
||||
// that we implicitly assume in type-at-pos and coverage implementations. In
|
||||
// particular, when unchecked it causes a crash with coverage --color.
|
||||
// TODO
|
||||
@@ -47,7 +47,7 @@ let x = 0;
|
||||
`;
|
||||
|
||||
exports[`test non-termination.js 1`] = `
|
||||
"// This file triggers a violation of the \"disjoint-or-nested ranges invariant\"
|
||||
"// This file triggers a violation of the "disjoint-or-nested ranges invariant"
|
||||
// that we implicitly assume in type-at-pos and coverage implementations. In
|
||||
// particular, when unchecked it causes non-termination with coverage --color.
|
||||
|
||||
@@ -62,7 +62,7 @@ declare module bar {
|
||||
declare class qux {
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// This file triggers a violation of the \"disjoint-or-nested ranges invariant\"
|
||||
// This file triggers a violation of the "disjoint-or-nested ranges invariant"
|
||||
// that we implicitly assume in type-at-pos and coverage implementations. In
|
||||
// particular, when unchecked it causes non-termination with coverage --color.
|
||||
// TODO
|
||||
|
||||
@@ -7,7 +7,7 @@ var y:number = d;
|
||||
// valid constructors
|
||||
new Date();
|
||||
new Date(1234567890);
|
||||
new Date(\'2015/06/18\');
|
||||
new Date('2015/06/18');
|
||||
new Date(2015, 6);
|
||||
new Date(2015, 6, 18);
|
||||
new Date(2015, 6, 18, 11);
|
||||
@@ -17,16 +17,16 @@ new Date(2015, 6, 18, 11, 55, 42, 999);
|
||||
|
||||
// invalid constructors
|
||||
new Date({});
|
||||
new Date(2015, \'6\');
|
||||
new Date(2015, 6, \'18\');
|
||||
new Date(2015, 6, 18, \'11\');
|
||||
new Date(2015, 6, 18, 11, \'55\');
|
||||
new Date(2015, 6, 18, 11, 55, \'42\');
|
||||
new Date(2015, 6, 18, 11, 55, 42, \'999\');
|
||||
new Date(2015, '6');
|
||||
new Date(2015, 6, '18');
|
||||
new Date(2015, 6, 18, '11');
|
||||
new Date(2015, 6, 18, 11, '55');
|
||||
new Date(2015, 6, 18, 11, 55, '42');
|
||||
new Date(2015, 6, 18, 11, 55, 42, '999');
|
||||
|
||||
// invalid constructors that we incorrectly consider valid
|
||||
new Date(\'2015\', 6);
|
||||
new Date(2015, 6, 18, 11, 55, 42, 999, \'hahaha\');
|
||||
new Date('2015', 6);
|
||||
new Date(2015, 6, 18, 11, 55, 42, 999, 'hahaha');
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// valid constructors
|
||||
// invalid constructors
|
||||
@@ -36,7 +36,7 @@ var x: string = d.getTime();
|
||||
var y: number = d;
|
||||
new Date();
|
||||
new Date(1234567890);
|
||||
new Date(\"2015/06/18\");
|
||||
new Date("2015/06/18");
|
||||
new Date(2015, 6);
|
||||
new Date(2015, 6, 18);
|
||||
new Date(2015, 6, 18, 11);
|
||||
@@ -44,13 +44,13 @@ new Date(2015, 6, 18, 11, 55);
|
||||
new Date(2015, 6, 18, 11, 55, 42);
|
||||
new Date(2015, 6, 18, 11, 55, 42, 999);
|
||||
new Date({});
|
||||
new Date(2015, \"6\");
|
||||
new Date(2015, 6, \"18\");
|
||||
new Date(2015, 6, 18, \"11\");
|
||||
new Date(2015, 6, 18, 11, \"55\");
|
||||
new Date(2015, 6, 18, 11, 55, \"42\");
|
||||
new Date(2015, 6, 18, 11, 55, 42, \"999\");
|
||||
new Date(\"2015\", 6);
|
||||
new Date(2015, 6, 18, 11, 55, 42, 999, \"hahaha\");
|
||||
new Date(2015, "6");
|
||||
new Date(2015, 6, "18");
|
||||
new Date(2015, 6, 18, "11");
|
||||
new Date(2015, 6, 18, 11, "55");
|
||||
new Date(2015, 6, 18, 11, 55, "42");
|
||||
new Date(2015, 6, 18, 11, 55, 42, "999");
|
||||
new Date("2015", 6);
|
||||
new Date(2015, 6, 18, 11, 55, 42, 999, "hahaha");
|
||||
"
|
||||
`;
|
||||
@@ -1,10 +1,10 @@
|
||||
exports[`test A.js 1`] = `
|
||||
"/* @flow */
|
||||
|
||||
module.exports.fun = (): string => \'hello there!\';
|
||||
module.exports.fun = (): string => 'hello there!';
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
module.exports.fun = (): string => \"hello there!\";
|
||||
module.exports.fun = (): string => "hello there!";
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -21,23 +21,23 @@ exports[`test test_absolute.js 1`] = `
|
||||
"/* @flow */
|
||||
|
||||
// This will require ./node_modules/B.js.flow
|
||||
var B1 = require(\'B\');
|
||||
var B1 = require('B');
|
||||
(B1.fun(): string); // Error number ~> string
|
||||
|
||||
// This will require ./node_modules/B.js.flow
|
||||
var B2 = require(\'B.js\');
|
||||
var B2 = require('B.js');
|
||||
(B2.fun(): string); // Error number ~> string
|
||||
|
||||
var C = require(\'package_with_full_main\');
|
||||
var C = require('package_with_full_main');
|
||||
(C.fun(): string); // Error number ~> string
|
||||
|
||||
var D = require(\'package_with_partial_main\');
|
||||
var D = require('package_with_partial_main');
|
||||
(D.fun(): string); // Error number ~> string
|
||||
|
||||
var E = require(\'package_with_no_package_json\');
|
||||
var E = require('package_with_no_package_json');
|
||||
(E.fun(): string); // Error number ~> string
|
||||
|
||||
var F = require(\'package_with_dir_main\');
|
||||
var F = require('package_with_dir_main');
|
||||
(F.fun(): string); // Error number ~> string
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
@@ -49,17 +49,17 @@ var F = require(\'package_with_dir_main\');
|
||||
// Error number ~> string
|
||||
// Error number ~> string
|
||||
// Error number ~> string
|
||||
var B1 = require(\"B\");
|
||||
var B1 = require("B");
|
||||
(B1.fun(): string);
|
||||
var B2 = require(\"B.js\");
|
||||
var B2 = require("B.js");
|
||||
(B2.fun(): string);
|
||||
var C = require(\"package_with_full_main\");
|
||||
var C = require("package_with_full_main");
|
||||
(C.fun(): string);
|
||||
var D = require(\"package_with_partial_main\");
|
||||
var D = require("package_with_partial_main");
|
||||
(D.fun(): string);
|
||||
var E = require(\"package_with_no_package_json\");
|
||||
var E = require("package_with_no_package_json");
|
||||
(E.fun(): string);
|
||||
var F = require(\"package_with_dir_main\");
|
||||
var F = require("package_with_dir_main");
|
||||
(F.fun(): string);
|
||||
"
|
||||
`;
|
||||
@@ -68,14 +68,14 @@ exports[`test test_relative.js 1`] = `
|
||||
"/* @flow */
|
||||
|
||||
// This will require ./A.js.flow
|
||||
var A1 = require(\'./A\');
|
||||
var A1 = require('./A');
|
||||
(A1.fun(): string); // Error number ~> string
|
||||
|
||||
// This will require ./A.js.flow
|
||||
var A2 = require(\'./A.js\');
|
||||
var A2 = require('./A.js');
|
||||
(A2.fun(): string); // Error number ~> string
|
||||
|
||||
var CJS = require(\'./CJS.js\');
|
||||
var CJS = require('./CJS.js');
|
||||
(CJS: string);
|
||||
(CJS: number); // Error: string ~> number
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -85,11 +85,11 @@ var CJS = require(\'./CJS.js\');
|
||||
// This will require ./A.js.flow
|
||||
// Error number ~> string
|
||||
// Error: string ~> number
|
||||
var A1 = require(\"./A\");
|
||||
var A1 = require("./A");
|
||||
(A1.fun(): string);
|
||||
var A2 = require(\"./A.js\");
|
||||
var A2 = require("./A.js");
|
||||
(A2.fun(): string);
|
||||
var CJS = require(\"./CJS.js\");
|
||||
var CJS = require("./CJS.js");
|
||||
(CJS: string);
|
||||
(CJS: number);
|
||||
"
|
||||
|
||||
@@ -4,16 +4,16 @@ exports[`test declare_class.js 1`] = `
|
||||
static foo(x: number): void;
|
||||
}
|
||||
|
||||
C.x = "";
|
||||
C.foo("");
|
||||
C.x = \"\";
|
||||
C.foo(\"\");
|
||||
|
||||
(C.name: string);
|
||||
(C.name: number); // error, it's a string
|
||||
(C.name: number); // error, it\'s a string
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// error, it's a string
|
||||
declare class C { x: number, foo: : (x: number) => void }
|
||||
C.x = "";
|
||||
C.foo("");
|
||||
// error, it\'s a string
|
||||
declare class C { static x: number; static foo(x: number): void }
|
||||
C.x = \"\";
|
||||
C.foo(\"\");
|
||||
(C.name: string);
|
||||
(C.name: number);
|
||||
"
|
||||
|
||||
@@ -9,8 +9,8 @@ declare class D extends _module.C {
|
||||
foo(): string;
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
declare class _C { foo: : () => number }
|
||||
declare class _C { foo(): number }
|
||||
declare var _module: { C: Class<_C> };
|
||||
declare class D { foo: : () => string }
|
||||
declare class D extends _module.C { foo(): string }
|
||||
"
|
||||
`;
|
||||
@@ -132,7 +132,7 @@ declare export default () => number;
|
||||
* @providesModule ES6_Default_AnonFunction1
|
||||
* @flow
|
||||
*/
|
||||
declare export default : () => number
|
||||
declare export default () => number
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -148,7 +148,7 @@ declare export default () =>number;
|
||||
* @providesModule ES6_Default_AnonFunction2
|
||||
* @flow
|
||||
*/
|
||||
declare export default : () => number
|
||||
declare export default () => number
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -173,7 +173,7 @@ declare export function getAFoo(): FooImpl;
|
||||
// Regression test for https://github.com/facebook/flow/issues/511
|
||||
//
|
||||
// Default-exported class should also be available in local scope
|
||||
declare export default class FooImpl { givesANum: : () => number }
|
||||
declare export default class FooImpl { givesANum(): number }
|
||||
declare export { FooImpl as Foo }
|
||||
declare export function getAFoo(): FooImpl;
|
||||
"
|
||||
@@ -191,7 +191,7 @@ declare export default class Foo { givesANum(): number; };
|
||||
* @providesModule ES6_Default_NamedClass2
|
||||
* @flow
|
||||
*/
|
||||
declare export default class Foo { givesANum: : () => number }
|
||||
declare export default class Foo { givesANum(): number }
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -245,13 +245,13 @@ exports[`test ES6_ExportAllFrom_Intermediary1.js 1`] = `
|
||||
* @flow
|
||||
*/
|
||||
|
||||
declare export * from \"ES6_ExportAllFrom_Source1\";
|
||||
declare export * from "ES6_ExportAllFrom_Source1";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/**
|
||||
* @providesModule ES6_ExportAllFrom_Intermediary1
|
||||
* @flow
|
||||
*/
|
||||
declare export * from \"ES6_ExportAllFrom_Source1\"
|
||||
declare export * from "ES6_ExportAllFrom_Source1"
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -261,13 +261,13 @@ exports[`test ES6_ExportAllFrom_Intermediary2.js 1`] = `
|
||||
* @flow
|
||||
*/
|
||||
|
||||
declare export * from \"ES6_ExportAllFrom_Source2\";
|
||||
declare export * from "ES6_ExportAllFrom_Source2";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/**
|
||||
* @providesModule ES6_ExportAllFrom_Intermediary2
|
||||
* @flow
|
||||
*/
|
||||
declare export * from \"ES6_ExportAllFrom_Source2\"
|
||||
declare export * from "ES6_ExportAllFrom_Source2"
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -306,12 +306,12 @@ declare export var numberValue2: number;
|
||||
exports[`test ES6_ExportAllFromMulti.js 1`] = `
|
||||
"// @flow
|
||||
|
||||
declare export * from \"./ES6_ExportAllFrom_Source1\";
|
||||
declare export * from \"./ES6_ExportAllFrom_Source2\";
|
||||
declare export * from "./ES6_ExportAllFrom_Source1";
|
||||
declare export * from "./ES6_ExportAllFrom_Source2";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
declare export * from \"./ES6_ExportAllFrom_Source1\"
|
||||
declare export * from \"./ES6_ExportAllFrom_Source2\"
|
||||
declare export * from "./ES6_ExportAllFrom_Source1"
|
||||
declare export * from "./ES6_ExportAllFrom_Source2"
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -324,13 +324,13 @@ exports[`test ES6_ExportFrom_Intermediary1.js 1`] = `
|
||||
declare export {
|
||||
numberValue1,
|
||||
numberValue2 as numberValue2_renamed
|
||||
} from \"ES6_ExportFrom_Source1\";
|
||||
} from "ES6_ExportFrom_Source1";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/**
|
||||
* @providesModule ES6_ExportFrom_Intermediary1
|
||||
* @flow
|
||||
*/
|
||||
declare export { numberValue1, numberValue2 as numberValue2_renamed } from \"ES6_ExportFrom_Source1\"
|
||||
declare export { numberValue1, numberValue2 as numberValue2_renamed } from "ES6_ExportFrom_Source1"
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -343,13 +343,13 @@ exports[`test ES6_ExportFrom_Intermediary2.js 1`] = `
|
||||
declare export {
|
||||
numberValue1,
|
||||
numberValue2 as numberValue2_renamed2
|
||||
} from \"ES6_ExportFrom_Source2\";
|
||||
} from "ES6_ExportFrom_Source2";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/**
|
||||
* @providesModule ES6_ExportFrom_Intermediary2
|
||||
* @flow
|
||||
*/
|
||||
declare export { numberValue1, numberValue2 as numberValue2_renamed2 } from \"ES6_ExportFrom_Source2\"
|
||||
declare export { numberValue1, numberValue2 as numberValue2_renamed2 } from "ES6_ExportFrom_Source2"
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -426,7 +426,7 @@ declare export { specifierNumber2 as specifierNumber2Renamed }
|
||||
declare export { specifierNumber3 }
|
||||
declare export { groupedSpecifierNumber1, groupedSpecifierNumber2 }
|
||||
declare export function givesANumber(): number;
|
||||
declare export class NumberGenerator { givesANumber: : () => number }
|
||||
declare export class NumberGenerator { givesANumber(): number }
|
||||
declare export var varDeclNumber1: number;
|
||||
declare export var varDeclNumber2: number;
|
||||
"
|
||||
@@ -465,7 +465,7 @@ declare export { specifierNumber4 }
|
||||
declare export { specifierNumber5 as specifierNumber5Renamed }
|
||||
declare export { groupedSpecifierNumber3, groupedSpecifierNumber4 }
|
||||
declare export function givesANumber2(): number;
|
||||
declare export class NumberGenerator2 { givesANumber: : () => number }
|
||||
declare export class NumberGenerator2 { givesANumber(): number }
|
||||
declare export var varDeclNumber3: number;
|
||||
declare export var varDeclNumber4: number;
|
||||
"
|
||||
@@ -481,7 +481,7 @@ exports.numberValue1 = 42;
|
||||
exports.numberValue2 = 42;
|
||||
exports.numberValue3 = 42;
|
||||
exports.numberValue4 = 42;
|
||||
exports.stringValue = \"str\";
|
||||
exports.stringValue = "str";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/**
|
||||
* @providesModule A
|
||||
@@ -491,7 +491,7 @@ exports.numberValue1 = 42;
|
||||
exports.numberValue2 = 42;
|
||||
exports.numberValue3 = 42;
|
||||
exports.numberValue4 = 42;
|
||||
exports.stringValue = \"str\";
|
||||
exports.stringValue = "str";
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -568,44 +568,44 @@ exports[`test es6modules.js 1`] = `
|
||||
// ===================== //
|
||||
|
||||
// @providesModule
|
||||
import * as DefaultA from \"A\";
|
||||
import * as DefaultA from "A";
|
||||
var a1: number = DefaultA.numberValue1;
|
||||
var a2: string = DefaultA.numberValue1; // Error: number ~> string
|
||||
|
||||
// File path
|
||||
import * as DefaultB from \"./B\";
|
||||
import * as DefaultB from "./B";
|
||||
var b1: number = DefaultB.numberValue;
|
||||
var b2: string = DefaultB.numberValue; // Error: number ~> string
|
||||
|
||||
// C.js exists, but not as a providesModule
|
||||
import DefaultC from \"C\"; // Error: No such module
|
||||
import DefaultC from "C"; // Error: No such module
|
||||
|
||||
// @providesModule D exists, but not as a filename
|
||||
import DefaultD from \"./D\"; // Error: No such module
|
||||
import DefaultD from "./D"; // Error: No such module
|
||||
|
||||
// ================================================ //
|
||||
// == CommonJS Clobbering Literal Exports -> ES6 == //
|
||||
// ================================================ //
|
||||
|
||||
import {doesntExist1} from \"CommonJS_Clobbering_Lit\"; // Error: Not an exported binding
|
||||
import {doesntExist1} from "CommonJS_Clobbering_Lit"; // Error: Not an exported binding
|
||||
|
||||
import {numberValue1} from \"CommonJS_Clobbering_Lit\";
|
||||
import {numberValue1} from "CommonJS_Clobbering_Lit";
|
||||
var c1: number = numberValue1;
|
||||
var c2: string = numberValue1; // Error: number ~> string
|
||||
|
||||
import {numberValue2 as numVal1} from \"CommonJS_Clobbering_Lit\";
|
||||
import {numberValue2 as numVal1} from "CommonJS_Clobbering_Lit";
|
||||
var d1: number = numVal1;
|
||||
var d2: string = numVal1; // Error: number ~> string
|
||||
|
||||
import CJS_Clobb_Lit from \"CommonJS_Clobbering_Lit\";
|
||||
import CJS_Clobb_Lit from "CommonJS_Clobbering_Lit";
|
||||
var e1: number = CJS_Clobb_Lit.numberValue3;
|
||||
var e2: string = CJS_Clobb_Lit.numberValue3; // Error: number ~> string
|
||||
CJS_Clobb_Lit.doesntExist; // Error: doesntExist isn\'t a property
|
||||
CJS_Clobb_Lit.doesntExist; // Error: doesntExist isn't a property
|
||||
|
||||
import * as CJS_Clobb_Lit_NS from \"CommonJS_Clobbering_Lit\";
|
||||
import * as CJS_Clobb_Lit_NS from "CommonJS_Clobbering_Lit";
|
||||
var f1: number = CJS_Clobb_Lit_NS.numberValue4;
|
||||
var f2: number = CJS_Clobb_Lit_NS.default.numberValue4;
|
||||
CJS_Clobb_Lit_NS.default.default; // Error: No \'default\' property on the exported obj
|
||||
CJS_Clobb_Lit_NS.default.default; // Error: No 'default' property on the exported obj
|
||||
var f3: string = CJS_Clobb_Lit_NS.numberValue4; // Error: number ~> string
|
||||
var f4: string = CJS_Clobb_Lit_NS.default.numberValue5; // Error: number ~> string
|
||||
|
||||
@@ -613,15 +613,15 @@ var f4: string = CJS_Clobb_Lit_NS.default.numberValue5; // Error: number ~> stri
|
||||
// == CommonJS Clobbering Class Exports -> ES6 == //
|
||||
// ============================================== //
|
||||
|
||||
import {doesntExist2} from \"CommonJS_Clobbering_Class\"; // Error: Not an exported binding
|
||||
import {doesntExist2} from "CommonJS_Clobbering_Class"; // Error: Not an exported binding
|
||||
|
||||
// The following import should error because class statics are not turned into
|
||||
// named exports for now. This avoids complexities with polymorphic static
|
||||
// members (where the polymophism is defined on the class itself rather than the
|
||||
// method).
|
||||
import {staticNumber1, baseProp, childProp} from \"CommonJS_Clobbering_Class\"; // Error
|
||||
import {staticNumber1, baseProp, childProp} from "CommonJS_Clobbering_Class"; // Error
|
||||
|
||||
import CJS_Clobb_Class from \"CommonJS_Clobbering_Class\";
|
||||
import CJS_Clobb_Class from "CommonJS_Clobbering_Class";
|
||||
new CJS_Clobb_Class();
|
||||
new CJS_Clobb_Class().doesntExist; // Error: Class has no \`doesntExist\` property
|
||||
var h1: number = CJS_Clobb_Class.staticNumber2();
|
||||
@@ -629,8 +629,8 @@ var h2: string = CJS_Clobb_Class.staticNumber2(); // Error: number ~> string
|
||||
var h3: number = new CJS_Clobb_Class().instNumber1();
|
||||
var h4: string = new CJS_Clobb_Class().instNumber1(); // Error: number ~> string
|
||||
|
||||
import * as CJS_Clobb_Class_NS from \"CommonJS_Clobbering_Class\";
|
||||
new CJS_Clobb_Class_NS(); // Error: Namespace object isn\'t constructable
|
||||
import * as CJS_Clobb_Class_NS from "CommonJS_Clobbering_Class";
|
||||
new CJS_Clobb_Class_NS(); // Error: Namespace object isn't constructable
|
||||
var i1: number = CJS_Clobb_Class_NS.staticNumber3(); // Error: Class statics not copied to Namespace object
|
||||
var i2: number = new CJS_Clobb_Class_NS.default().instNumber2();
|
||||
var i3: string = new CJS_Clobb_Class_NS.default().instNumber2(); // Error: number ~> string
|
||||
@@ -639,22 +639,22 @@ var i3: string = new CJS_Clobb_Class_NS.default().instNumber2(); // Error: numbe
|
||||
// == CommonJS Named Exports -> ES6 == //
|
||||
// =================================== //
|
||||
|
||||
import {doesntExist3} from \"CommonJS_Named\"; // Error: Not an exported binding
|
||||
import {doesntExist3} from "CommonJS_Named"; // Error: Not an exported binding
|
||||
|
||||
import {numberValue2} from \"CommonJS_Named\";
|
||||
import {numberValue2} from "CommonJS_Named";
|
||||
var j1: number = numberValue2;
|
||||
var j2: string = numberValue2; // Error: number ~> string
|
||||
|
||||
import {numberValue3 as numVal3} from \"CommonJS_Named\";
|
||||
import {numberValue3 as numVal3} from "CommonJS_Named";
|
||||
var k1: number = numVal3;
|
||||
var k2: string = numVal3; // Error: number ~> string
|
||||
|
||||
import * as CJS_Named from \"CommonJS_Named\";
|
||||
import * as CJS_Named from "CommonJS_Named";
|
||||
var l1: number = CJS_Named.numberValue1;
|
||||
var l2: string = CJS_Named.numberValue1; // Error: number ~> string
|
||||
CJS_Named.doesntExist; // Error: doesntExist isn\'t a property
|
||||
CJS_Named.doesntExist; // Error: doesntExist isn't a property
|
||||
|
||||
import * as CJS_Named_NS from \"CommonJS_Named\";
|
||||
import * as CJS_Named_NS from "CommonJS_Named";
|
||||
var m1: number = CJS_Named_NS.numberValue4;
|
||||
var m2: string = CJS_Named_NS.default.numberValue4; // Error: CommonJS_Named has no default export
|
||||
var m3: string = CJS_Named_NS.numberValue4; // Error: number ~> string
|
||||
@@ -663,13 +663,13 @@ var m3: string = CJS_Named_NS.numberValue4; // Error: number ~> string
|
||||
// == ES6 Default -> ES6 == //
|
||||
//////////////////////////////
|
||||
|
||||
import {doesntExist4} from \"ES6_Default_AnonFunction1\"; // Error: Not an exported binding
|
||||
import {doesntExist4} from "ES6_Default_AnonFunction1"; // Error: Not an exported binding
|
||||
|
||||
import ES6_Def_AnonFunc1 from \"ES6_Default_AnonFunction1\";
|
||||
import ES6_Def_AnonFunc1 from "ES6_Default_AnonFunction1";
|
||||
var n1: number = ES6_Def_AnonFunc1();
|
||||
var n2: string = ES6_Def_AnonFunc1(); // Error: number ~> string
|
||||
|
||||
import ES6_Def_NamedFunc1 from \"ES6_Default_NamedFunction1\";
|
||||
import ES6_Def_NamedFunc1 from "ES6_Default_NamedFunction1";
|
||||
var o1: number = ES6_Def_NamedFunc1();
|
||||
var o2: string = ES6_Def_NamedFunc1(); // Error: number ~> string
|
||||
|
||||
@@ -677,7 +677,7 @@ var o2: string = ES6_Def_NamedFunc1(); // Error: number ~> string
|
||||
|
||||
|
||||
|
||||
import ES6_Def_NamedClass1 from \"ES6_Default_NamedClass1\";
|
||||
import ES6_Def_NamedClass1 from "ES6_Default_NamedClass1";
|
||||
var q1: number = new ES6_Def_NamedClass1().givesANum();
|
||||
var q2: string = new ES6_Def_NamedClass1().givesANum(); // Error: number ~> string
|
||||
|
||||
@@ -685,35 +685,35 @@ var q2: string = new ES6_Def_NamedClass1().givesANum(); // Error: number ~> stri
|
||||
// == ES6 Named -> ES6 == //
|
||||
////////////////////////////
|
||||
|
||||
import doesntExist5 from \"ES6_Named1\"; // Error: Not an exported binding
|
||||
import doesntExist5 from "ES6_Named1"; // Error: Not an exported binding
|
||||
|
||||
import {specifierNumber1 as specifierNumber1_1} from \"ES6_Named1\";
|
||||
import {specifierNumber1 as specifierNumber1_1} from "ES6_Named1";
|
||||
var r1: number = specifierNumber1_1;
|
||||
var r2: string = specifierNumber1_1; // Error: number ~> string
|
||||
|
||||
import {specifierNumber2Renamed} from \"ES6_Named1\";
|
||||
import {specifierNumber2Renamed} from "ES6_Named1";
|
||||
var s1: number = specifierNumber2Renamed;
|
||||
var s2: string = specifierNumber2Renamed; // Error: number ~> string
|
||||
|
||||
import {specifierNumber3 as specifierNumber3Renamed} from \"ES6_Named1\";
|
||||
import {specifierNumber3 as specifierNumber3Renamed} from "ES6_Named1";
|
||||
var t1: number = specifierNumber3Renamed;
|
||||
var t2: string = specifierNumber3Renamed; // Error: number ~> string
|
||||
|
||||
import {groupedSpecifierNumber1, groupedSpecifierNumber2} from \"ES6_Named1\";
|
||||
import {groupedSpecifierNumber1, groupedSpecifierNumber2} from "ES6_Named1";
|
||||
var u1: number = groupedSpecifierNumber1;
|
||||
var u2: number = groupedSpecifierNumber2;
|
||||
var u3: string = groupedSpecifierNumber1; // Error: number ~> string
|
||||
var u4: string = groupedSpecifierNumber2; // Error: number ~> string
|
||||
|
||||
import {givesANumber} from \"ES6_Named1\";
|
||||
import {givesANumber} from "ES6_Named1";
|
||||
var v1: number = givesANumber();
|
||||
var v2: string = givesANumber(); // Error: number ~> string
|
||||
|
||||
import {NumberGenerator} from \"ES6_Named1\";
|
||||
import {NumberGenerator} from "ES6_Named1";
|
||||
var w1: number = new NumberGenerator().givesANumber();
|
||||
var w2: string = new NumberGenerator().givesANumber(); // Error: number ~> string
|
||||
|
||||
import {varDeclNumber1, varDeclNumber2} from \"ES6_Named1\";
|
||||
import {varDeclNumber1, varDeclNumber2} from "ES6_Named1";
|
||||
var x1: number = varDeclNumber1;
|
||||
var x2: number = varDeclNumber2;
|
||||
var x3: string = varDeclNumber1; // Error: number ~> string
|
||||
@@ -727,15 +727,15 @@ var x4: string = varDeclNumber2; // Error: number ~> string
|
||||
|
||||
|
||||
|
||||
import {numberValue1 as numberValue4} from \"ES6_ExportFrom_Intermediary1\";
|
||||
import {numberValue1 as numberValue4} from "ES6_ExportFrom_Intermediary1";
|
||||
var aa1: number = numberValue4;
|
||||
var aa2: string = numberValue4; // Error: number ~> string
|
||||
|
||||
import {numberValue2_renamed} from \"ES6_ExportFrom_Intermediary1\";
|
||||
import {numberValue2_renamed} from "ES6_ExportFrom_Intermediary1";
|
||||
var ab1: number = numberValue2_renamed;
|
||||
var ab2: string = numberValue2_renamed; // Error: number ~> string
|
||||
|
||||
import {numberValue1 as numberValue5} from \"ES6_ExportAllFrom_Intermediary1\";
|
||||
import {numberValue1 as numberValue5} from "ES6_ExportAllFrom_Intermediary1";
|
||||
var ac1: number = numberValue5;
|
||||
var ac2: string = numberValue5; // Error: number ~> string
|
||||
|
||||
@@ -743,13 +743,13 @@ var ac2: string = numberValue5; // Error: number ~> string
|
||||
// == ES6 Default -> CommonJS == //
|
||||
///////////////////////////////////
|
||||
|
||||
require(\'ES6_Default_AnonFunction2\').doesntExist; // Error: \'doesntExist\' isn\'t an export
|
||||
require('ES6_Default_AnonFunction2').doesntExist; // Error: 'doesntExist' isn't an export
|
||||
|
||||
var ES6_Def_AnonFunc2 = require(\"ES6_Default_AnonFunction2\").default;
|
||||
var ES6_Def_AnonFunc2 = require("ES6_Default_AnonFunction2").default;
|
||||
var ad1: number = ES6_Def_AnonFunc2();
|
||||
var ad2: string = ES6_Def_AnonFunc2(); // Error: number ~> string
|
||||
|
||||
var ES6_Def_NamedFunc2 = require(\"ES6_Default_NamedFunction2\").default;
|
||||
var ES6_Def_NamedFunc2 = require("ES6_Default_NamedFunction2").default;
|
||||
var ae1: number = ES6_Def_NamedFunc2();
|
||||
var ae2: string = ES6_Def_NamedFunc2(); // Error: number ~> string
|
||||
|
||||
@@ -757,7 +757,7 @@ var ae2: string = ES6_Def_NamedFunc2(); // Error: number ~> string
|
||||
|
||||
|
||||
|
||||
var ES6_Def_NamedClass2 = require(\"ES6_Default_NamedClass2\").default;
|
||||
var ES6_Def_NamedClass2 = require("ES6_Default_NamedClass2").default;
|
||||
var ag1: number = new ES6_Def_NamedClass2().givesANum();
|
||||
var ag2: string = new ES6_Def_NamedClass2().givesANum(); // Error: number ~> string
|
||||
|
||||
@@ -765,31 +765,31 @@ var ag2: string = new ES6_Def_NamedClass2().givesANum(); // Error: number ~> str
|
||||
// == ES6 Named -> CommonJS == //
|
||||
/////////////////////////////////
|
||||
|
||||
var specifierNumber4 = require(\"ES6_Named2\").specifierNumber4;
|
||||
var specifierNumber4 = require("ES6_Named2").specifierNumber4;
|
||||
var ah1: number = specifierNumber4;
|
||||
var ah2: string = specifierNumber4; // Error: number ~> string
|
||||
|
||||
var specifierNumber5Renamed = require(\"ES6_Named2\").specifierNumber5Renamed;
|
||||
var specifierNumber5Renamed = require("ES6_Named2").specifierNumber5Renamed;
|
||||
var ai1: number = specifierNumber5Renamed;
|
||||
var ai2: string = specifierNumber5Renamed; // Error: number ~> string
|
||||
|
||||
var groupedSpecifierNumber3 = require(\"ES6_Named2\").groupedSpecifierNumber3;
|
||||
var groupedSpecifierNumber4 = require(\"ES6_Named2\").groupedSpecifierNumber4;
|
||||
var groupedSpecifierNumber3 = require("ES6_Named2").groupedSpecifierNumber3;
|
||||
var groupedSpecifierNumber4 = require("ES6_Named2").groupedSpecifierNumber4;
|
||||
var aj1: number = groupedSpecifierNumber3;
|
||||
var aj2: number = groupedSpecifierNumber4;
|
||||
var aj3: string = groupedSpecifierNumber3; // Error: number ~> string
|
||||
var aj4: string = groupedSpecifierNumber4; // Error: number ~> string
|
||||
|
||||
var givesANumber2 = require(\"ES6_Named2\").givesANumber2;
|
||||
var givesANumber2 = require("ES6_Named2").givesANumber2;
|
||||
var ak1: number = givesANumber2();
|
||||
var ak2: string = givesANumber2(); // Error: number ~> string
|
||||
|
||||
var NumberGenerator2 = require(\"ES6_Named2\").NumberGenerator2;
|
||||
var NumberGenerator2 = require("ES6_Named2").NumberGenerator2;
|
||||
var al1: number = new NumberGenerator2().givesANumber();
|
||||
var al2: string = new NumberGenerator2().givesANumber(); // Error: number ~> string
|
||||
|
||||
var varDeclNumber3 = require(\"ES6_Named2\").varDeclNumber3;
|
||||
var varDeclNumber4 = require(\"ES6_Named2\").varDeclNumber4;
|
||||
var varDeclNumber3 = require("ES6_Named2").varDeclNumber3;
|
||||
var varDeclNumber4 = require("ES6_Named2").varDeclNumber4;
|
||||
var am1: number = varDeclNumber3;
|
||||
var am2: number = varDeclNumber4;
|
||||
var am3: string = varDeclNumber3; // Error: number ~> string
|
||||
@@ -803,15 +803,15 @@ var am4: string = varDeclNumber4; // Error: number ~> string
|
||||
|
||||
|
||||
|
||||
var numberValue6 = require(\"ES6_ExportFrom_Intermediary2\").numberValue1;
|
||||
var numberValue6 = require("ES6_ExportFrom_Intermediary2").numberValue1;
|
||||
var ap1: number = numberValue6;
|
||||
var ap2: string = numberValue6; // Error: number ~> string
|
||||
|
||||
var numberValue2_renamed2 = require(\"ES6_ExportFrom_Intermediary2\").numberValue2_renamed2;
|
||||
var numberValue2_renamed2 = require("ES6_ExportFrom_Intermediary2").numberValue2_renamed2;
|
||||
var aq1: number = numberValue2_renamed2;
|
||||
var aq2: string = numberValue2_renamed2; // Error: number ~> string
|
||||
|
||||
var numberValue7 = require(\"ES6_ExportAllFrom_Intermediary2\").numberValue2;
|
||||
var numberValue7 = require("ES6_ExportAllFrom_Intermediary2").numberValue2;
|
||||
var ar1: number = numberValue7;
|
||||
var ar2: string = numberValue7; // Error: number ~> string
|
||||
|
||||
@@ -819,7 +819,7 @@ var ar2: string = numberValue7; // Error: number ~> string
|
||||
// == ES6 Default+Named -> ES6 import Default+Named== //
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
import defaultNum, {str as namedStr} from \"./ES6_DefaultAndNamed\";
|
||||
import defaultNum, {str as namedStr} from "./ES6_DefaultAndNamed";
|
||||
|
||||
var as1: number = defaultNum;
|
||||
var as2: string = defaultNum; // Error: number ~> string
|
||||
@@ -831,13 +831,13 @@ var as4: number = namedStr; // Error: string ~> number
|
||||
// == Side-effect only ES6 imports == //
|
||||
////////////////////////////////////////
|
||||
|
||||
import \"./SideEffects\";
|
||||
import "./SideEffects";
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// == Suggest export name on likely typo == //
|
||||
//////////////////////////////////////////////
|
||||
import specifierNumber1 from \"ES6_Named1\"; // Error: Did you mean \`import {specifierNumber1} from ...\`?
|
||||
import {specifierNumber} from \"ES6_Named1\"; // Error: Did you mean \`specifierNumber1\`?
|
||||
import specifierNumber1 from "ES6_Named1"; // Error: Did you mean \`import {specifierNumber1} from ...\`?
|
||||
import {specifierNumber} from "ES6_Named1"; // Error: Did you mean \`specifierNumber1\`?
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
// == Multi \`export *\` should combine exports == //
|
||||
@@ -845,7 +845,7 @@ import {specifierNumber} from \"ES6_Named1\"; // Error: Did you mean \`specifier
|
||||
import {
|
||||
numberValue1 as numberValue8,
|
||||
numberValue2 as numberValue9
|
||||
} from \"./ES6_ExportAllFromMulti\";
|
||||
} from "./ES6_ExportAllFromMulti";
|
||||
|
||||
var at1: number = numberValue8;
|
||||
var at2: string = numberValue8; // Error: number ~> string
|
||||
@@ -872,8 +872,8 @@ var at4: string = numberValue9; // Error: number ~> string
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
// Error: doesntExist isn\'t a property
|
||||
// Error: No \'default\' property on the exported obj
|
||||
// Error: doesntExist isn't a property
|
||||
// Error: No 'default' property on the exported obj
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
// ============================================== //
|
||||
@@ -888,7 +888,7 @@ var at4: string = numberValue9; // Error: number ~> string
|
||||
// Error: Class has no \`doesntExist\` property
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
// Error: Namespace object isn\'t constructable
|
||||
// Error: Namespace object isn't constructable
|
||||
// Error: Class statics not copied to Namespace object
|
||||
// Error: number ~> string
|
||||
// =================================== //
|
||||
@@ -898,7 +898,7 @@ var at4: string = numberValue9; // Error: number ~> string
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
// Error: doesntExist isn\'t a property
|
||||
// Error: doesntExist isn't a property
|
||||
// Error: CommonJS_Named has no default export
|
||||
// Error: number ~> string
|
||||
//////////////////////////////
|
||||
@@ -927,7 +927,7 @@ var at4: string = numberValue9; // Error: number ~> string
|
||||
///////////////////////////////////
|
||||
// == ES6 Default -> CommonJS == //
|
||||
///////////////////////////////////
|
||||
// Error: \'doesntExist\' isn\'t an export
|
||||
// Error: 'doesntExist' isn't an export
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
@@ -963,159 +963,159 @@ var at4: string = numberValue9; // Error: number ~> string
|
||||
///////////////////////////////////////////////////
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
import * as DefaultA from \"A\";
|
||||
import * as DefaultA from "A";
|
||||
var a1: number = DefaultA.numberValue1;
|
||||
var a2: string = DefaultA.numberValue1;
|
||||
import * as DefaultB from \"./B\";
|
||||
import * as DefaultB from "./B";
|
||||
var b1: number = DefaultB.numberValue;
|
||||
var b2: string = DefaultB.numberValue;
|
||||
import DefaultC from \"C\";
|
||||
import DefaultD from \"./D\";
|
||||
import { doesntExist1 } from \"CommonJS_Clobbering_Lit\";
|
||||
import { numberValue1 } from \"CommonJS_Clobbering_Lit\";
|
||||
import DefaultC from "C";
|
||||
import DefaultD from "./D";
|
||||
import { doesntExist1 } from "CommonJS_Clobbering_Lit";
|
||||
import { numberValue1 } from "CommonJS_Clobbering_Lit";
|
||||
var c1: number = numberValue1;
|
||||
var c2: string = numberValue1;
|
||||
import { numberValue2 as numVal1 } from \"CommonJS_Clobbering_Lit\";
|
||||
import { numberValue2 as numVal1 } from "CommonJS_Clobbering_Lit";
|
||||
var d1: number = numVal1;
|
||||
var d2: string = numVal1;
|
||||
import CJS_Clobb_Lit from \"CommonJS_Clobbering_Lit\";
|
||||
import CJS_Clobb_Lit from "CommonJS_Clobbering_Lit";
|
||||
var e1: number = CJS_Clobb_Lit.numberValue3;
|
||||
var e2: string = CJS_Clobb_Lit.numberValue3;
|
||||
CJS_Clobb_Lit.doesntExist;
|
||||
import * as CJS_Clobb_Lit_NS from \"CommonJS_Clobbering_Lit\";
|
||||
import * as CJS_Clobb_Lit_NS from "CommonJS_Clobbering_Lit";
|
||||
var f1: number = CJS_Clobb_Lit_NS.numberValue4;
|
||||
var f2: number = CJS_Clobb_Lit_NS.default.numberValue4;
|
||||
CJS_Clobb_Lit_NS.default.default;
|
||||
var f3: string = CJS_Clobb_Lit_NS.numberValue4;
|
||||
var f4: string = CJS_Clobb_Lit_NS.default.numberValue5;
|
||||
import { doesntExist2 } from \"CommonJS_Clobbering_Class\";
|
||||
import { staticNumber1, baseProp, childProp } from \"CommonJS_Clobbering_Class\";
|
||||
import CJS_Clobb_Class from \"CommonJS_Clobbering_Class\";
|
||||
import { doesntExist2 } from "CommonJS_Clobbering_Class";
|
||||
import { staticNumber1, baseProp, childProp } from "CommonJS_Clobbering_Class";
|
||||
import CJS_Clobb_Class from "CommonJS_Clobbering_Class";
|
||||
new CJS_Clobb_Class();
|
||||
new CJS_Clobb_Class().doesntExist;
|
||||
var h1: number = CJS_Clobb_Class.staticNumber2();
|
||||
var h2: string = CJS_Clobb_Class.staticNumber2();
|
||||
var h3: number = new CJS_Clobb_Class().instNumber1();
|
||||
var h4: string = new CJS_Clobb_Class().instNumber1();
|
||||
import * as CJS_Clobb_Class_NS from \"CommonJS_Clobbering_Class\";
|
||||
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();
|
||||
import { doesntExist3 } from \"CommonJS_Named\";
|
||||
import { numberValue2 } from \"CommonJS_Named\";
|
||||
import { doesntExist3 } from "CommonJS_Named";
|
||||
import { numberValue2 } from "CommonJS_Named";
|
||||
var j1: number = numberValue2;
|
||||
var j2: string = numberValue2;
|
||||
import { numberValue3 as numVal3 } from \"CommonJS_Named\";
|
||||
import { numberValue3 as numVal3 } from "CommonJS_Named";
|
||||
var k1: number = numVal3;
|
||||
var k2: string = numVal3;
|
||||
import * as CJS_Named from \"CommonJS_Named\";
|
||||
import * as CJS_Named from "CommonJS_Named";
|
||||
var l1: number = CJS_Named.numberValue1;
|
||||
var l2: string = CJS_Named.numberValue1;
|
||||
CJS_Named.doesntExist;
|
||||
import * as CJS_Named_NS from \"CommonJS_Named\";
|
||||
import * as CJS_Named_NS from "CommonJS_Named";
|
||||
var m1: number = CJS_Named_NS.numberValue4;
|
||||
var m2: string = CJS_Named_NS.default.numberValue4;
|
||||
var m3: string = CJS_Named_NS.numberValue4;
|
||||
import { doesntExist4 } from \"ES6_Default_AnonFunction1\";
|
||||
import ES6_Def_AnonFunc1 from \"ES6_Default_AnonFunction1\";
|
||||
import { doesntExist4 } from "ES6_Default_AnonFunction1";
|
||||
import ES6_Def_AnonFunc1 from "ES6_Default_AnonFunction1";
|
||||
var n1: number = ES6_Def_AnonFunc1();
|
||||
var n2: string = ES6_Def_AnonFunc1();
|
||||
import ES6_Def_NamedFunc1 from \"ES6_Default_NamedFunction1\";
|
||||
import ES6_Def_NamedFunc1 from "ES6_Default_NamedFunction1";
|
||||
var o1: number = ES6_Def_NamedFunc1();
|
||||
var o2: string = ES6_Def_NamedFunc1();
|
||||
import ES6_Def_NamedClass1 from \"ES6_Default_NamedClass1\";
|
||||
import ES6_Def_NamedClass1 from "ES6_Default_NamedClass1";
|
||||
var q1: number = new ES6_Def_NamedClass1().givesANum();
|
||||
var q2: string = new ES6_Def_NamedClass1().givesANum();
|
||||
import doesntExist5 from \"ES6_Named1\";
|
||||
import { specifierNumber1 as specifierNumber1_1 } from \"ES6_Named1\";
|
||||
import doesntExist5 from "ES6_Named1";
|
||||
import { specifierNumber1 as specifierNumber1_1 } from "ES6_Named1";
|
||||
var r1: number = specifierNumber1_1;
|
||||
var r2: string = specifierNumber1_1;
|
||||
import { specifierNumber2Renamed } from \"ES6_Named1\";
|
||||
import { specifierNumber2Renamed } from "ES6_Named1";
|
||||
var s1: number = specifierNumber2Renamed;
|
||||
var s2: string = specifierNumber2Renamed;
|
||||
import { specifierNumber3 as specifierNumber3Renamed } from \"ES6_Named1\";
|
||||
import { specifierNumber3 as specifierNumber3Renamed } from "ES6_Named1";
|
||||
var t1: number = specifierNumber3Renamed;
|
||||
var t2: string = specifierNumber3Renamed;
|
||||
import { groupedSpecifierNumber1, groupedSpecifierNumber2 } from \"ES6_Named1\";
|
||||
import { groupedSpecifierNumber1, groupedSpecifierNumber2 } from "ES6_Named1";
|
||||
var u1: number = groupedSpecifierNumber1;
|
||||
var u2: number = groupedSpecifierNumber2;
|
||||
var u3: string = groupedSpecifierNumber1;
|
||||
var u4: string = groupedSpecifierNumber2;
|
||||
import { givesANumber } from \"ES6_Named1\";
|
||||
import { givesANumber } from "ES6_Named1";
|
||||
var v1: number = givesANumber();
|
||||
var v2: string = givesANumber();
|
||||
import { NumberGenerator } from \"ES6_Named1\";
|
||||
import { NumberGenerator } from "ES6_Named1";
|
||||
var w1: number = new NumberGenerator().givesANumber();
|
||||
var w2: string = new NumberGenerator().givesANumber();
|
||||
import { varDeclNumber1, varDeclNumber2 } from \"ES6_Named1\";
|
||||
import { varDeclNumber1, varDeclNumber2 } from "ES6_Named1";
|
||||
var x1: number = varDeclNumber1;
|
||||
var x2: number = varDeclNumber2;
|
||||
var x3: string = varDeclNumber1;
|
||||
var x4: string = varDeclNumber2;
|
||||
import { numberValue1 as numberValue4 } from \"ES6_ExportFrom_Intermediary1\";
|
||||
import { numberValue1 as numberValue4 } from "ES6_ExportFrom_Intermediary1";
|
||||
var aa1: number = numberValue4;
|
||||
var aa2: string = numberValue4;
|
||||
import { numberValue2_renamed } from \"ES6_ExportFrom_Intermediary1\";
|
||||
import { numberValue2_renamed } from "ES6_ExportFrom_Intermediary1";
|
||||
var ab1: number = numberValue2_renamed;
|
||||
var ab2: string = numberValue2_renamed;
|
||||
import { numberValue1 as numberValue5 } from \"ES6_ExportAllFrom_Intermediary1\";
|
||||
import { numberValue1 as numberValue5 } from "ES6_ExportAllFrom_Intermediary1";
|
||||
var ac1: number = numberValue5;
|
||||
var ac2: string = numberValue5;
|
||||
require(\"ES6_Default_AnonFunction2\").doesntExist;
|
||||
var ES6_Def_AnonFunc2 = require(\"ES6_Default_AnonFunction2\").default;
|
||||
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();
|
||||
var ES6_Def_NamedFunc2 = require(\"ES6_Default_NamedFunction2\").default;
|
||||
var ES6_Def_NamedFunc2 = require("ES6_Default_NamedFunction2").default;
|
||||
var ae1: number = ES6_Def_NamedFunc2();
|
||||
var ae2: string = ES6_Def_NamedFunc2();
|
||||
var ES6_Def_NamedClass2 = require(\"ES6_Default_NamedClass2\").default;
|
||||
var ES6_Def_NamedClass2 = require("ES6_Default_NamedClass2").default;
|
||||
var ag1: number = new ES6_Def_NamedClass2().givesANum();
|
||||
var ag2: string = new ES6_Def_NamedClass2().givesANum();
|
||||
var specifierNumber4 = require(\"ES6_Named2\").specifierNumber4;
|
||||
var specifierNumber4 = require("ES6_Named2").specifierNumber4;
|
||||
var ah1: number = specifierNumber4;
|
||||
var ah2: string = specifierNumber4;
|
||||
var specifierNumber5Renamed = require(\"ES6_Named2\").specifierNumber5Renamed;
|
||||
var specifierNumber5Renamed = require("ES6_Named2").specifierNumber5Renamed;
|
||||
var ai1: number = specifierNumber5Renamed;
|
||||
var ai2: string = specifierNumber5Renamed;
|
||||
var groupedSpecifierNumber3 = require(\"ES6_Named2\").groupedSpecifierNumber3;
|
||||
var groupedSpecifierNumber4 = require(\"ES6_Named2\").groupedSpecifierNumber4;
|
||||
var groupedSpecifierNumber3 = require("ES6_Named2").groupedSpecifierNumber3;
|
||||
var groupedSpecifierNumber4 = require("ES6_Named2").groupedSpecifierNumber4;
|
||||
var aj1: number = groupedSpecifierNumber3;
|
||||
var aj2: number = groupedSpecifierNumber4;
|
||||
var aj3: string = groupedSpecifierNumber3;
|
||||
var aj4: string = groupedSpecifierNumber4;
|
||||
var givesANumber2 = require(\"ES6_Named2\").givesANumber2;
|
||||
var givesANumber2 = require("ES6_Named2").givesANumber2;
|
||||
var ak1: number = givesANumber2();
|
||||
var ak2: string = givesANumber2();
|
||||
var NumberGenerator2 = require(\"ES6_Named2\").NumberGenerator2;
|
||||
var NumberGenerator2 = require("ES6_Named2").NumberGenerator2;
|
||||
var al1: number = new NumberGenerator2().givesANumber();
|
||||
var al2: string = new NumberGenerator2().givesANumber();
|
||||
var varDeclNumber3 = require(\"ES6_Named2\").varDeclNumber3;
|
||||
var varDeclNumber4 = require(\"ES6_Named2\").varDeclNumber4;
|
||||
var varDeclNumber3 = require("ES6_Named2").varDeclNumber3;
|
||||
var varDeclNumber4 = require("ES6_Named2").varDeclNumber4;
|
||||
var am1: number = varDeclNumber3;
|
||||
var am2: number = varDeclNumber4;
|
||||
var am3: string = varDeclNumber3;
|
||||
var am4: string = varDeclNumber4;
|
||||
var numberValue6 = require(\"ES6_ExportFrom_Intermediary2\").numberValue1;
|
||||
var numberValue6 = require("ES6_ExportFrom_Intermediary2").numberValue1;
|
||||
var ap1: number = numberValue6;
|
||||
var ap2: string = numberValue6;
|
||||
var numberValue2_renamed2 = require(
|
||||
\"ES6_ExportFrom_Intermediary2\"
|
||||
"ES6_ExportFrom_Intermediary2"
|
||||
).numberValue2_renamed2;
|
||||
var aq1: number = numberValue2_renamed2;
|
||||
var aq2: string = numberValue2_renamed2;
|
||||
var numberValue7 = require(\"ES6_ExportAllFrom_Intermediary2\").numberValue2;
|
||||
var numberValue7 = require("ES6_ExportAllFrom_Intermediary2").numberValue2;
|
||||
var ar1: number = numberValue7;
|
||||
var ar2: string = numberValue7;
|
||||
import defaultNum, { str as namedStr } from \"./ES6_DefaultAndNamed\";
|
||||
import defaultNum, { str as namedStr } from "./ES6_DefaultAndNamed";
|
||||
var as1: number = defaultNum;
|
||||
var as2: string = defaultNum;
|
||||
var as3: string = namedStr;
|
||||
var as4: number = namedStr;
|
||||
import \"./SideEffects\";
|
||||
import specifierNumber1 from \"ES6_Named1\";
|
||||
import { specifierNumber } from \"ES6_Named1\";
|
||||
import { numberValue1 as numberValue8, numberValue2 as numberValue9 } from \"./ES6_ExportAllFromMulti\";
|
||||
import "./SideEffects";
|
||||
import specifierNumber1 from "ES6_Named1";
|
||||
import { specifierNumber } from "ES6_Named1";
|
||||
import { numberValue1 as numberValue8, numberValue2 as numberValue9 } from "./ES6_ExportAllFromMulti";
|
||||
var at1: number = numberValue8;
|
||||
var at2: string = numberValue8;
|
||||
var at3: number = numberValue9;
|
||||
|
||||
@@ -12,7 +12,7 @@ declare function foo<X>(x: X): X;
|
||||
// error, boolean ~/~ undefined
|
||||
declare function foo(x: number): string;
|
||||
declare function foo(x: string): number;
|
||||
declare function foo(x: X): X;
|
||||
declare function foo<X>(x: X): X;
|
||||
(foo(0): string);
|
||||
(foo(\"hello\"): number);
|
||||
(foo(false): void);
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
exports[`test main.js 1`] = `
|
||||
"// @flow
|
||||
|
||||
import declare_module_exports from \"declare_module_exports\";
|
||||
import declare_module_exports from "declare_module_exports";
|
||||
(declare_module_exports: number);
|
||||
(declare_module_exports: string); // Error: number ~> string
|
||||
|
||||
// Error: Has no named export \"str\"!
|
||||
import {str} from \"declare_m_e_with_other_value_declares\";
|
||||
// Error: Has no named export "str"!
|
||||
import {str} from "declare_m_e_with_other_value_declares";
|
||||
|
||||
import type {str2} from \"declare_m_e_with_other_type_declares\";
|
||||
(\"asdf\": str2);
|
||||
import type {str2} from "declare_m_e_with_other_type_declares";
|
||||
("asdf": str2);
|
||||
(42: str2); // Error: number ~> string
|
||||
|
||||
/**
|
||||
@@ -17,17 +17,17 @@ import type {str2} from \"declare_m_e_with_other_type_declares\";
|
||||
* syntaxes will work.
|
||||
*/
|
||||
|
||||
import DEPRECATED__declare_var_exports from \"DEPRECATED__declare_var_exports\";
|
||||
import DEPRECATED__declare_var_exports from "DEPRECATED__declare_var_exports";
|
||||
(DEPRECATED__declare_var_exports: number);
|
||||
(DEPRECATED__declare_var_exports: string); // Error: number ~> string
|
||||
|
||||
import declare_m_e_with_declare_var_e from \"declare_m_e_with_declare_var_e\";
|
||||
import declare_m_e_with_declare_var_e from "declare_m_e_with_declare_var_e";
|
||||
(declare_m_e_with_declare_var_e: number);
|
||||
(declare_m_e_with_declare_var_e: string); // Error: number ~> string
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
// Error: number ~> string
|
||||
// Error: Has no named export \"str\"!
|
||||
// Error: Has no named export "str"!
|
||||
// Error: number ~> string
|
||||
/**
|
||||
* \`declare var exports\` is deprecated, so we have a grace period where both
|
||||
@@ -35,17 +35,17 @@ import declare_m_e_with_declare_var_e from \"declare_m_e_with_declare_var_e\";
|
||||
*/
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
import declare_module_exports from \"declare_module_exports\";
|
||||
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);
|
||||
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\";
|
||||
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\";
|
||||
import declare_m_e_with_declare_var_e from "declare_m_e_with_declare_var_e";
|
||||
(declare_m_e_with_declare_var_e: number);
|
||||
(declare_m_e_with_declare_var_e: string);
|
||||
"
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
exports[`test libs.js 1`] = `
|
||||
"declare module "declare_module_exports" {
|
||||
"declare module \"declare_module_exports\" {
|
||||
declare module.exports: number;
|
||||
}
|
||||
|
||||
declare module "declare_m_e_with_other_value_declares" {
|
||||
declare module \"declare_m_e_with_other_value_declares\" {
|
||||
declare module.exports: number;
|
||||
declare var str: string;
|
||||
}
|
||||
|
||||
declare module "declare_m_e_with_other_type_declares" {
|
||||
declare module \"declare_m_e_with_other_type_declares\" {
|
||||
declare module.exports: number;
|
||||
declare type str2 = string;
|
||||
}
|
||||
@@ -18,14 +18,14 @@ declare module "declare_m_e_with_other_type_declares" {
|
||||
* syntaxes will work.
|
||||
*/
|
||||
|
||||
declare module "DEPRECATED__declare_var_exports" {
|
||||
declare module \"DEPRECATED__declare_var_exports\" {
|
||||
declare var exports: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that, if both are present, \`declare module.exports\` wins
|
||||
*/
|
||||
declare module "declare_m_e_with_declare_var_e" {
|
||||
declare module \"declare_m_e_with_declare_var_e\" {
|
||||
declare module.exports: number;
|
||||
declare var exports: string;
|
||||
}
|
||||
@@ -37,22 +37,22 @@ declare module "declare_m_e_with_declare_var_e" {
|
||||
/**
|
||||
* Ensure that, if both are present, \`declare module.exports\` wins
|
||||
*/
|
||||
declare module "declare_module_exports" {
|
||||
declare module.exports: number
|
||||
declare module \"declare_module_exports\" {
|
||||
declare module.exports: number;
|
||||
}
|
||||
declare module "declare_m_e_with_other_value_declares" {
|
||||
declare module.exports: number
|
||||
declare module \"declare_m_e_with_other_value_declares\" {
|
||||
declare module.exports: number;
|
||||
declare var str: string;
|
||||
}
|
||||
declare module "declare_m_e_with_other_type_declares" {
|
||||
declare module.exports: number
|
||||
type str2 = string;
|
||||
declare module \"declare_m_e_with_other_type_declares\" {
|
||||
declare module.exports: number;
|
||||
declare type str2 = string;
|
||||
}
|
||||
declare module "DEPRECATED__declare_var_exports" {
|
||||
declare module \"DEPRECATED__declare_var_exports\" {
|
||||
declare var exports: number;
|
||||
}
|
||||
declare module "declare_m_e_with_declare_var_e" {
|
||||
declare module.exports: number
|
||||
declare module \"declare_m_e_with_declare_var_e\" {
|
||||
declare module.exports: number;
|
||||
declare var exports: string;
|
||||
}
|
||||
"
|
||||
|
||||
@@ -6,21 +6,21 @@ exports[`test import_declare_type.js 1`] = `
|
||||
////////////////////////////////////////////////////////////
|
||||
// == Import Declared Type Alias From Declared Module == //
|
||||
//////////////////////////////////////////////////////////
|
||||
import type {baz} from \"ModuleAliasFoo\";
|
||||
import {foo} from \"ModuleAliasFoo\";
|
||||
import type {baz} from "ModuleAliasFoo";
|
||||
import {foo} from "ModuleAliasFoo";
|
||||
var k1: baz = 42;
|
||||
var k2: baz = \"shab\"; // Error: string to int
|
||||
var k2: baz = "shab"; // Error: string to int
|
||||
var k3: toz = foo(k1); // works
|
||||
|
||||
import type {toz} from \"ModuleAliasFoo\";
|
||||
import type {toz} from "ModuleAliasFoo";
|
||||
var k4: toz = foo(k1); // works
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
// == Declared Module with exports prop (issue 880) == //
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
import blah from \'foo\';
|
||||
import type { Foo, Bar, Id } from \'foo\';
|
||||
import blah from 'foo';
|
||||
import type { Foo, Bar, Id } from 'foo';
|
||||
|
||||
blah(0, 0);
|
||||
|
||||
@@ -28,7 +28,7 @@ blah(0, 0);
|
||||
|
||||
(3 : Bar); // error : number ~> A
|
||||
|
||||
(\"lol\" : Id<number>); // error : string ~> number
|
||||
("lol" : Id<number>); // error : string ~> number
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/**
|
||||
* @flow
|
||||
@@ -45,18 +45,18 @@ blah(0, 0);
|
||||
// error : {toz : number} ~> string
|
||||
// error : number ~> A
|
||||
// error : string ~> number
|
||||
import type { baz } from \"ModuleAliasFoo\";
|
||||
import { foo } from \"ModuleAliasFoo\";
|
||||
import type { baz } from "ModuleAliasFoo";
|
||||
import { foo } from "ModuleAliasFoo";
|
||||
var k1: baz = 42;
|
||||
var k2: baz = \"shab\";
|
||||
var k2: baz = "shab";
|
||||
var k3: toz = foo(k1);
|
||||
import type { toz } from \"ModuleAliasFoo\";
|
||||
import type { toz } from "ModuleAliasFoo";
|
||||
var k4: toz = foo(k1);
|
||||
import blah from \"foo\";
|
||||
import type { Foo, Bar, Id } from \"foo\";
|
||||
import blah from "foo";
|
||||
import type { Foo, Bar, Id } from "foo";
|
||||
blah(0, 0);
|
||||
({ toz: 3 }: Foo);
|
||||
(3: Bar);
|
||||
(\"lol\": Id<number>);
|
||||
("lol": Id<number>);
|
||||
"
|
||||
`;
|
||||
@@ -13,8 +13,8 @@ declare module ModuleAliasFoo {
|
||||
* @flow
|
||||
*/
|
||||
declare module ModuleAliasFoo {
|
||||
type baz = number;
|
||||
type toz = string;
|
||||
declare type baz = number;
|
||||
declare type toz = string;
|
||||
declare function foo(bar: baz): toz;
|
||||
}
|
||||
"
|
||||
@@ -23,7 +23,7 @@ declare module ModuleAliasFoo {
|
||||
exports[`test declare_type_exports.js 1`] = `
|
||||
"/* @flow */
|
||||
|
||||
declare module 'foo' {
|
||||
declare module \'foo\' {
|
||||
declare class A {
|
||||
toz : number
|
||||
}
|
||||
@@ -40,12 +40,12 @@ declare module 'foo' {
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
declare module "foo" {
|
||||
declare module \"foo\" {
|
||||
declare class A { toz: number }
|
||||
declare var n: string;
|
||||
type Foo = typeof n;
|
||||
type Bar = A;
|
||||
type Id<T> = T;
|
||||
declare type Foo = typeof n;
|
||||
declare type Bar = A;
|
||||
declare type Id<T> = T;
|
||||
declare var exports: { (a: number, b: number): number };
|
||||
}
|
||||
"
|
||||
|
||||
@@ -43,11 +43,11 @@ module.exports = A;
|
||||
`;
|
||||
|
||||
exports[`test B.js 1`] = `
|
||||
"var A = require(\'Demo\');
|
||||
"var A = require('Demo');
|
||||
|
||||
var z = new A(\"42\").getX();
|
||||
var z = new A("42").getX();
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var A = require(\"Demo\");
|
||||
var z = new A(\"42\").getX();
|
||||
var A = require("Demo");
|
||||
var z = new A("42").getX();
|
||||
"
|
||||
`;
|
||||
@@ -342,11 +342,11 @@ function foo({ p, z: [ r ] }) {
|
||||
foo({ p: 0, z: [ 1, 2 ] });
|
||||
[ a, , b, ...c ] = [ 0, 1, true, 3 ];
|
||||
function bar({ x, ...z }) {
|
||||
var o: { x: string, y: number } = z;
|
||||
var o: { x: string; y: number } = z;
|
||||
}
|
||||
bar({ x: \"\", y: 0 });
|
||||
var spread = { y: \"\" };
|
||||
var extend: { x: number, y: string, z: boolean } = { x: 0, ...spread };
|
||||
var extend: { x: number; y: string; z: boolean } = { x: 0, ...spread };
|
||||
function qux(_: { a: number }) {
|
||||
|
||||
}
|
||||
@@ -387,21 +387,6 @@ var cp2_err: string = others.childprop2;
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test destructuring_init.js 1`] = `
|
||||
"var {foo};
|
||||
var [bar];
|
||||
var [];
|
||||
var {};
|
||||
var [], {toz};
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
var { foo };
|
||||
var [ bar ];
|
||||
var [ ];
|
||||
var {};
|
||||
var [ ]{ toz };
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`test destructuring_param.js 1`] = `
|
||||
"function f(a, { b }) {
|
||||
return a + b;
|
||||
@@ -491,18 +476,18 @@ type Prop<X> = { prop: X };
|
||||
function obj_pattern2<X>({ prop }) {
|
||||
|
||||
}
|
||||
function arr_pattern<X>([ elem ]) {
|
||||
function arr_pattern<X>([ elem ]: X[]) {
|
||||
|
||||
}
|
||||
type Elem<X> = X[];
|
||||
function arr_pattern2<X>([ elem ]) {
|
||||
function arr_pattern2<X>([ elem ]: Elem<X>) {
|
||||
|
||||
}
|
||||
function tup_pattern<X>([ proj ]) {
|
||||
function tup_pattern<X>([ proj ]: [X]) {
|
||||
|
||||
}
|
||||
type Proj<X> = [X];
|
||||
function tup_pattern2<X>([ proj ]) {
|
||||
function tup_pattern2<X>([ proj ]: Proj<X>) {
|
||||
|
||||
}
|
||||
function rest_antipattern<T>(...t: T) {
|
||||
@@ -514,15 +499,15 @@ function rest_pattern<X>(...r: X[]) {
|
||||
function obj_rest_pattern<X>({ _, ...o }) {
|
||||
o.x;
|
||||
}
|
||||
type ObjRest<X> = { _: any, x: X };
|
||||
type ObjRest<X> = { _: any; x: X };
|
||||
function obj_rest_pattern<X>({ _, ...o }) {
|
||||
o.x;
|
||||
}
|
||||
function arr_rest_pattern<X>([ _, ...a ]) {
|
||||
function arr_rest_pattern<X>([ _, ...a ]: [any, X]) {
|
||||
a[0];
|
||||
}
|
||||
type ArrRest<X> = [anyX];
|
||||
function arr_rest_pattern<X>([ _, ...a ]) {
|
||||
type ArrRest<X> = [any, X];
|
||||
function arr_rest_pattern<X>([ _, ...a ]: ArrRest<X>) {
|
||||
a[0];
|
||||
}
|
||||
"
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
var {foo};
|
||||
var [bar];
|
||||
var [];
|
||||
var {};
|
||||
var [], {toz};
|
||||
@@ -41,8 +41,8 @@ function foo0(x: Array<{ [key: string]: mixed }>): Array<{
|
||||
return x;
|
||||
}
|
||||
function foo2(x: { [key: string]: number }): {
|
||||
[key: string]: number,
|
||||
+toString: : () => string
|
||||
[key: string]: number;
|
||||
+toString: () => string
|
||||
} {
|
||||
return x;
|
||||
}
|
||||
@@ -526,21 +526,21 @@ function add_prop_to_nonstring_key_dot(o: { [k: number]: any }) {
|
||||
function add_prop_to_nonstring_key_bracket(o: { [k: number]: any }) {
|
||||
o[0] = \"ok\";
|
||||
}
|
||||
function mix_with_declared_props(o: { [k: number]: X, p: Y }, x: X, y: Y) {
|
||||
function mix_with_declared_props(o: { [k: number]: X; p: Y }, x: X, y: Y) {
|
||||
(o[0]: X);
|
||||
(o.p: Y);
|
||||
o[0] = x;
|
||||
o.p = y;
|
||||
}
|
||||
function object_prototype(o: { [k: string]: number }): {
|
||||
[k: string]: number,
|
||||
+toString: : () => string
|
||||
[k: string]: number;
|
||||
+toString: () => string
|
||||
} {
|
||||
(o.toString(): boolean);
|
||||
return o;
|
||||
}
|
||||
function unsound_string_conversion_alias_declared_prop(
|
||||
o: { [k: number]: any, \"0\": X }
|
||||
o: { [k: number]: any; \"0\": X }
|
||||
) {
|
||||
o[0] = \"not-x\";
|
||||
}
|
||||
@@ -576,16 +576,16 @@ function subtype_dict_keys_invariant(x: { [k: B]: any }) {
|
||||
function unification_mix_with_declared_props_invariant_l(
|
||||
x: Array<{ [k: string]: B }>
|
||||
) {
|
||||
let a: Array<{ [k: string]: B, p: A }> = x;
|
||||
let a: Array<{ [k: string]: B; p: A }> = x;
|
||||
a[0].p = new A();
|
||||
let b: Array<{ [k: string]: B, p: B }> = x;
|
||||
let c: Array<{ [k: string]: B, p: C }> = x;
|
||||
let b: Array<{ [k: string]: B; p: B }> = x;
|
||||
let c: Array<{ [k: string]: B; p: C }> = x;
|
||||
(x[0].p: C);
|
||||
}
|
||||
function unification_mix_with_declared_props_invariant_r(
|
||||
xa: Array<{ [k: string]: A, p: B }>,
|
||||
xb: Array<{ [k: string]: B, p: B }>,
|
||||
xc: Array<{ [k: string]: C, p: B }>
|
||||
xa: Array<{ [k: string]: A; p: B }>,
|
||||
xb: Array<{ [k: string]: B; p: B }>,
|
||||
xc: Array<{ [k: string]: C; p: B }>
|
||||
) {
|
||||
let a: Array<{ [k: string]: A }> = xa;
|
||||
a[0].p = new A();
|
||||
@@ -594,16 +594,16 @@ function unification_mix_with_declared_props_invariant_r(
|
||||
(xc[0].p: C);
|
||||
}
|
||||
function subtype_mix_with_declared_props_invariant_l(x: { [k: string]: B }) {
|
||||
let a: { [k: string]: B, p: A } = x;
|
||||
let a: { [k: string]: B; p: A } = x;
|
||||
a.p = new A();
|
||||
let b: { [k: string]: B, p: B } = x;
|
||||
let c: { [k: string]: B, p: C } = x;
|
||||
let b: { [k: string]: B; p: B } = x;
|
||||
let c: { [k: string]: B; p: C } = x;
|
||||
(x.p: C);
|
||||
}
|
||||
function subtype_mix_with_declared_props_invariant_r(
|
||||
xa: { [k: string]: A, p: B },
|
||||
xb: { [k: string]: B, p: B },
|
||||
xc: { [k: string]: C, p: B }
|
||||
xa: { [k: string]: A; p: B },
|
||||
xb: { [k: string]: B; p: B },
|
||||
xc: { [k: string]: C; p: B }
|
||||
) {
|
||||
let a: { [k: string]: A } = xa;
|
||||
a.p = new A();
|
||||
@@ -635,20 +635,20 @@ function subtype_obj_to_dict(x: { p: B }) {
|
||||
let c: { [k: string]: C } = x;
|
||||
(x.p: C);
|
||||
}
|
||||
function subtype_obj_to_mixed(x: { p: B, x: X }) {
|
||||
let a: { [k: string]: A, x: X } = x;
|
||||
let b: { [k: string]: B, x: X } = x;
|
||||
let c: { [k: string]: C, x: X } = x;
|
||||
function subtype_obj_to_mixed(x: { p: B; x: X }) {
|
||||
let a: { [k: string]: A; x: X } = x;
|
||||
let b: { [k: string]: B; x: X } = x;
|
||||
let c: { [k: string]: C; x: X } = x;
|
||||
}
|
||||
function unification_dict_to_mixed(x: Array<{ [k: string]: B }>) {
|
||||
let a: Array<{ [k: string]: B, p: A }> = x;
|
||||
let b: Array<{ [k: string]: B, p: B }> = x;
|
||||
let c: Array<{ [k: string]: B, p: C }> = x;
|
||||
let a: Array<{ [k: string]: B; p: A }> = x;
|
||||
let b: Array<{ [k: string]: B; p: B }> = x;
|
||||
let c: Array<{ [k: string]: B; p: C }> = x;
|
||||
}
|
||||
function subtype_dict_to_mixed(x: { [k: string]: B }) {
|
||||
let a: { [k: string]: B, p: A } = x;
|
||||
let b: { [k: string]: B, p: B } = x;
|
||||
let c: { [k: string]: B, p: C } = x;
|
||||
let a: { [k: string]: B; p: A } = x;
|
||||
let b: { [k: string]: B; p: B } = x;
|
||||
let c: { [k: string]: B; p: C } = x;
|
||||
}
|
||||
function subtype_dict_to_optional_a(x: { [k: string]: B }) {
|
||||
let a: { p?: A } = x;
|
||||
@@ -756,13 +756,13 @@ function foo0(x: Array<{ [key: string]: number }>): Array<{
|
||||
return x;
|
||||
}
|
||||
function foo1(x: Array<{ [key: string]: number }>): Array<{
|
||||
[key: string]: number,
|
||||
[key: string]: number;
|
||||
fooBar: string
|
||||
}> {
|
||||
return x;
|
||||
}
|
||||
function foo2(x: Array<{ [key: string]: mixed }>): Array<{
|
||||
[key: string]: mixed,
|
||||
[key: string]: mixed;
|
||||
fooBar: string
|
||||
}> {
|
||||
x[0].fooBar = 123;
|
||||
@@ -772,7 +772,7 @@ function foo3(x: { [key: string]: number }): { foo: number } {
|
||||
return x;
|
||||
}
|
||||
function foo4(x: { [key: string]: number }): {
|
||||
[key: string]: number,
|
||||
[key: string]: number;
|
||||
foo: string
|
||||
} {
|
||||
return x;
|
||||
@@ -783,7 +783,7 @@ function foo5(x: Array<{ [key: string]: number }>): Array<{ foo: number }> {
|
||||
function foo6(x: Array<{ foo: number }>): Array<{ [key: string]: number }> {
|
||||
return x;
|
||||
}
|
||||
function foo7(x: { [key: string]: number, bar: string }) {
|
||||
function foo7(x: { [key: string]: number; bar: string }) {
|
||||
(x.bar: string);
|
||||
}
|
||||
function foo8(x: { [key: string]: number }) {
|
||||
@@ -859,8 +859,8 @@ var o: { foo: QueryFunction } = {
|
||||
module.exports = o;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// error, number ~/~ string
|
||||
type Params = { [name: string]: string, count: number };
|
||||
type QueryFunction = : (params: Params) => string;
|
||||
type Params = { [name: string]: string; count: number };
|
||||
type QueryFunction = (params: Params) => string;
|
||||
var o: { foo: QueryFunction } = {
|
||||
foo(params) {
|
||||
return params.count;
|
||||
|
||||
@@ -85,54 +85,54 @@ export type TypedNode =
|
||||
*/
|
||||
export type InferredType = \"unknown\" | \"gender\" | \"enum\" | \"number-or-string\" | \"number\" | \"string\" | \"error\";
|
||||
export type Pos = {
|
||||
firstLine: number,
|
||||
firstColumn: number,
|
||||
lastLine: number,
|
||||
firstLine: number;
|
||||
firstColumn: number;
|
||||
lastLine: number;
|
||||
lastColumn: number
|
||||
};
|
||||
export type TypedBinaryOpNode = {
|
||||
exprNodeType: \"binary_op\",
|
||||
binaryOp: \"plus\" | \"multiply\" | \"divide\" | \"minus\",
|
||||
lhs: TypedNode,
|
||||
rhs: TypedNode,
|
||||
pos: Pos,
|
||||
exprType: InferredType,
|
||||
exprNodeType: \"binary_op\";
|
||||
binaryOp: \"plus\" | \"multiply\" | \"divide\" | \"minus\";
|
||||
lhs: TypedNode;
|
||||
rhs: TypedNode;
|
||||
pos: Pos;
|
||||
exprType: InferredType;
|
||||
typed: true
|
||||
};
|
||||
export type TypedUnaryMinusNode = {
|
||||
exprNodeType: \"unary_minus\",
|
||||
op: TypedNode,
|
||||
pos: Pos,
|
||||
exprType: InferredType,
|
||||
exprNodeType: \"unary_minus\";
|
||||
op: TypedNode;
|
||||
pos: Pos;
|
||||
exprType: InferredType;
|
||||
typed: true
|
||||
};
|
||||
export type TypedNumberNode = {
|
||||
exprNodeType: \"number\",
|
||||
value: number,
|
||||
pos: Pos,
|
||||
exprType: \"number\",
|
||||
exprNodeType: \"number\";
|
||||
value: number;
|
||||
pos: Pos;
|
||||
exprType: \"number\";
|
||||
typed: true
|
||||
};
|
||||
export type TypedStringLiteralNode = {
|
||||
exprNodeType: \"string_literal\",
|
||||
value: string,
|
||||
pos: Pos,
|
||||
exprType: \"string\",
|
||||
exprNodeType: \"string_literal\";
|
||||
value: string;
|
||||
pos: Pos;
|
||||
exprType: \"string\";
|
||||
typed: true
|
||||
};
|
||||
export type TypedVariableNode = {
|
||||
exprNodeType: \"variable\",
|
||||
name: string,
|
||||
pos: Pos,
|
||||
exprType: InferredType,
|
||||
exprNodeType: \"variable\";
|
||||
name: string;
|
||||
pos: Pos;
|
||||
exprType: InferredType;
|
||||
typed: true
|
||||
};
|
||||
export type TypedFunctionInvocationNode = {
|
||||
exprNodeType: \"function_invocation\",
|
||||
name: string,
|
||||
parameters: TypedNode[],
|
||||
pos: Pos,
|
||||
exprType: \"error\" | \"string\",
|
||||
exprNodeType: \"function_invocation\";
|
||||
name: string;
|
||||
parameters: TypedNode[];
|
||||
pos: Pos;
|
||||
exprType: \"error\" | \"string\";
|
||||
typed: true
|
||||
};
|
||||
export type TypedNode = TypedBinaryOpNode | TypedUnaryMinusNode | TypedNumberNode | TypedStringLiteralNode | TypedVariableNode | TypedFunctionInvocationNode;
|
||||
@@ -914,31 +914,31 @@ export const builders : {
|
||||
// ast-types exports all expressions as patterns.
|
||||
// That seems not like it was intended.
|
||||
export type Comment = {
|
||||
loc: ?SourceLocation,
|
||||
value: string,
|
||||
leading: boolean,
|
||||
loc: ?SourceLocation;
|
||||
value: string;
|
||||
leading: boolean;
|
||||
trailing: boolean
|
||||
};
|
||||
export type SourceLocation = {
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
source: ?string
|
||||
};
|
||||
export type SourcePosition = { line: number, column: number };
|
||||
export type SourcePosition = { line: number; column: number };
|
||||
export type File = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"File\",
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"File\";
|
||||
program: Program
|
||||
};
|
||||
export type Program = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"Program\",
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"Program\";
|
||||
body: Statement[]
|
||||
};
|
||||
export type BinaryOperator = \"==\" | \"!=\" | \"===\" | \"!==\" | \"<\" | \"<=\" | \">\" | \">=\" | \"<<\" | \">>\" | \">>>\" | \"+\" | \"-\" | \"*\" | \"/\" | \"%\" | \"&\" | \"|\" | \"^\" | \"in\" | \"instanceof\" | \"..\";
|
||||
@@ -949,337 +949,368 @@ export type LogicalOperator = \"&&\" | \"||\";
|
||||
export type Node = EmptyStatement | BlockStatement | ExpressionStatement | IfStatement | BreakStatement | ContinueStatement | ReturnStatement | ThrowStatement | WhileStatement | ForStatement | ForInStatement | TryStatement | CatchClause | Identifier | Literal | ThisExpression | ArrayExpression | ObjectExpreession | Property | FunctionExpression | BinaryExpression | UnaryExpression | AssignmentExpression | UpdateExpression | LogicalExpression | ConditionalExpression | NewExpression | CallExpression | MemberExpression | VariableDeclaration | FunctionDeclaration | VariableDeclarator;
|
||||
export type Statement = BlockStatement | EmptyStatement | ExpressionStatement | IfStatement | BreakStatement | ContinueStatement | ReturnStatement | ThrowStatement | WhileStatement | ForStatement | ForInStatement | TryStatement | Declaration;
|
||||
export type EmptyStatement = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"EmptyStatement\"
|
||||
};
|
||||
export type BlockStatement = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"BlockStatement\",
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"BlockStatement\";
|
||||
body: Statement[]
|
||||
};
|
||||
export type ExpressionStatement = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"ExpressionStatement\",
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"ExpressionStatement\";
|
||||
expression: Expression
|
||||
};
|
||||
export type IfStatement = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"IfStatement\",
|
||||
test: Expression,
|
||||
consequent: Statement,
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"IfStatement\";
|
||||
test: Expression;
|
||||
consequent: Statement;
|
||||
alternate: ?Statement
|
||||
};
|
||||
export type BreakStatement = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"BreakStatement\",
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"BreakStatement\";
|
||||
label: ?Identifier
|
||||
};
|
||||
export type ContinueStatement = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"ContinueStatement\",
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"ContinueStatement\";
|
||||
label: ?Identifier
|
||||
};
|
||||
export type ReturnStatement = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"ReturnStatement\",
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"ReturnStatement\";
|
||||
argument: ?Expression
|
||||
};
|
||||
export type ThrowStatement = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"ThrowStatement\",
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"ThrowStatement\";
|
||||
argument: ?Expression
|
||||
};
|
||||
export type WhileStatement = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"WhileStatement\",
|
||||
test: Expression,
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"WhileStatement\";
|
||||
test: Expression;
|
||||
body: Statement
|
||||
};
|
||||
export type ForStatement = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"ForStatement\",
|
||||
init: ?(VariableDeclaration | Expression),
|
||||
test: ?Expression,
|
||||
update: ?Expression,
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"ForStatement\";
|
||||
init: ?(VariableDeclaration | Expression);
|
||||
test: ?Expression;
|
||||
update: ?Expression;
|
||||
body: Statement
|
||||
};
|
||||
export type ForInStatement = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"ForInStatement\",
|
||||
left: VariableDeclaration | Expression,
|
||||
right: Expression,
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"ForInStatement\";
|
||||
left: VariableDeclaration | Expression;
|
||||
right: Expression;
|
||||
body: Statement
|
||||
};
|
||||
export type TryStatement = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"TryStatement\",
|
||||
block: BlockStatement,
|
||||
handler: ?CatchClause,
|
||||
handlers: CatchClause[],
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"TryStatement\";
|
||||
block: BlockStatement;
|
||||
handler: ?CatchClause;
|
||||
handlers: CatchClause[];
|
||||
finalizer: ?BlockStatement
|
||||
};
|
||||
export type CatchClause = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"CatchClause\",
|
||||
param: Pattern,
|
||||
guard: ?Expression,
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"CatchClause\";
|
||||
param: Pattern;
|
||||
guard: ?Expression;
|
||||
body: BlockStatement
|
||||
};
|
||||
export type Expression = Identifier | ThisExpression | Literal | FunctionExpression | BinaryExpression | UnaryExpression | AssignmentExpression | UpdateExpression | LogicalExpression | ConditionalExpression | NewExpression | CallExpression | MemberExpression | ArrayExpression | ObjectExpreession;
|
||||
export type Identifier = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"Identifier\",
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"Identifier\";
|
||||
name: string
|
||||
};
|
||||
export type Literal = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"Literal\",
|
||||
value: ?(string | boolean | number | RegExp),
|
||||
regex: ?{ pattern: string, flags: string }
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"Literal\";
|
||||
value: ?(string | boolean | number | RegExp);
|
||||
regex: ?{ pattern: string; flags: string }
|
||||
};
|
||||
export type ThisExpression = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"ThisExpression\"
|
||||
};
|
||||
export type ArrayExpression = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"ArrayExpression\",
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"ArrayExpression\";
|
||||
elements: Expression[]
|
||||
};
|
||||
export type ObjectExpreession = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"ObjectExpression\",
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"ObjectExpression\";
|
||||
properties: Property[]
|
||||
};
|
||||
export type Property = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"Property\",
|
||||
kind: \"init\" | \"get\" | \"set\",
|
||||
key: Literal | Identifier,
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"Property\";
|
||||
kind: \"init\" | \"get\" | \"set\";
|
||||
key: Literal | Identifier;
|
||||
value: Expression
|
||||
};
|
||||
export type FunctionExpression = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"FunctionExpression\",
|
||||
id: ?Identifier,
|
||||
params: Pattern[],
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"FunctionExpression\";
|
||||
id: ?Identifier;
|
||||
params: Pattern[];
|
||||
body: BlockStatement
|
||||
};
|
||||
export type BinaryExpression = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"BinaryExpression\",
|
||||
operator: BinaryOperator,
|
||||
left: Expression,
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"BinaryExpression\";
|
||||
operator: BinaryOperator;
|
||||
left: Expression;
|
||||
right: Expression
|
||||
};
|
||||
export type UnaryExpression = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"UnaryExpression\",
|
||||
operator: UnaryOperator,
|
||||
argument: Expression,
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"UnaryExpression\";
|
||||
operator: UnaryOperator;
|
||||
argument: Expression;
|
||||
prefix: boolean
|
||||
};
|
||||
export type AssignmentExpression = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"AssignmentExpression\",
|
||||
operator: AssignmentOperator,
|
||||
left: Pattern,
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"AssignmentExpression\";
|
||||
operator: AssignmentOperator;
|
||||
left: Pattern;
|
||||
right: Expression
|
||||
};
|
||||
export type UpdateExpression = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"UpdateExpression\",
|
||||
operator: UpdateOperator,
|
||||
argument: Expression,
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"UpdateExpression\";
|
||||
operator: UpdateOperator;
|
||||
argument: Expression;
|
||||
prefix: boolean
|
||||
};
|
||||
export type LogicalExpression = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"LogicalExpression\",
|
||||
operator: LogicalOperator,
|
||||
left: Expression,
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"LogicalExpression\";
|
||||
operator: LogicalOperator;
|
||||
left: Expression;
|
||||
right: Expression
|
||||
};
|
||||
export type ConditionalExpression = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"ConditionalExpression\",
|
||||
test: Expression,
|
||||
consequent: Expression,
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"ConditionalExpression\";
|
||||
test: Expression;
|
||||
consequent: Expression;
|
||||
alternate: Expression
|
||||
};
|
||||
export type NewExpression = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"NewExpression\",
|
||||
callee: Expression,
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"NewExpression\";
|
||||
callee: Expression;
|
||||
arguments: Expression[]
|
||||
};
|
||||
export type CallExpression = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"CallExpression\",
|
||||
callee: Expression,
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"CallExpression\";
|
||||
callee: Expression;
|
||||
arguments: Expression[]
|
||||
};
|
||||
export type MemberExpression = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"MemberExpression\",
|
||||
object: Expression,
|
||||
property: Identifier | Expression,
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"MemberExpression\";
|
||||
object: Expression;
|
||||
property: Identifier | Expression;
|
||||
computed: boolean
|
||||
};
|
||||
export type Pattern = Identifier;
|
||||
export type Declaration = VariableDeclaration | FunctionDeclaration;
|
||||
export type VariableDeclaration = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"VariableDeclaration\",
|
||||
kind: \"var\" | \"let\" | \"const\",
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"VariableDeclaration\";
|
||||
kind: \"var\" | \"let\" | \"const\";
|
||||
declarations: VariableDeclarator[]
|
||||
};
|
||||
export type FunctionDeclaration = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"FunctionDeclaration\",
|
||||
id: Identifier,
|
||||
body: BlockStatement,
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"FunctionDeclaration\";
|
||||
id: Identifier;
|
||||
body: BlockStatement;
|
||||
params: Pattern[]
|
||||
};
|
||||
export type VariableDeclarator = {
|
||||
source: ?string,
|
||||
start: SourcePosition,
|
||||
end: SourcePosition,
|
||||
comments: ?Array<Comment>,
|
||||
type: \"VariableDeclarator\",
|
||||
id: Pattern,
|
||||
source: ?string;
|
||||
start: SourcePosition;
|
||||
end: SourcePosition;
|
||||
comments: ?Array<Comment>;
|
||||
type: \"VariableDeclarator\";
|
||||
id: Pattern;
|
||||
init: ?Expression
|
||||
};
|
||||
const a: any = null;
|
||||
export const builders: {
|
||||
emptyStatement: : () => EmptyStatement,
|
||||
blockStatement: : (body: Statement[]) => BlockStatement,
|
||||
expressionStatement: : (expression: Expression) => ExpressionStatement,
|
||||
ifStatement: : (test: Expression, consequent: Statement, alternate?: Statement) => IfStatement,
|
||||
breakStatement: : (label?: Identifier) => BreakStatement,
|
||||
continueStatement: : (label?: Identifier) => ContinueStatement,
|
||||
returnStatement: : (argument: ?Expression) => ReturnStatement,
|
||||
throwStatement: : (argument: ?Expression) => ThrowStatement,
|
||||
whileStatement: : (test: Expression, body: Statement) => WhileStatement,
|
||||
forStatement: : (init: ?(VariableDeclaration | Expression), test: ?Expression, update: ?Expression, body: Statement) => ForStatement,
|
||||
forInStatement: : (left: VariableDeclaration | Expression, right: Expression, body: Statement) => ForInStatement,
|
||||
tryStatement: : (block: BlockStatement, handler: ?CatchClause, handlers: CatchClause[], finalizer?: BlockStatement) => TryStatement,
|
||||
catchClause: : (param: Pattern, guard: ?Expression, body: BlockStatement) => CatchClause,
|
||||
identifier: : (name: string) => Identifier,
|
||||
literal: : (value: ?(string | boolean | number | RegExp), regex?: {
|
||||
pattern: string,
|
||||
flags: string
|
||||
}) => Literal,
|
||||
thisExpression: : () => ThisExpression,
|
||||
arrayExpression: : (elements: Expression[]) => ArrayExpression,
|
||||
objectExpreession: : (properties: Property[]) => ObjectExpreession,
|
||||
property: : (kind: \"init\" | \"get\" | \"set\", key: Literal | Identifier, value: Expression) => Property,
|
||||
functionExpression: : (id: ?Identifier, params: Pattern[], body: BlockStatement) => FunctionExpression,
|
||||
binaryExpression: : (operator: BinaryOperator, left: Expression, right: Expression) => BinaryExpression,
|
||||
unaryExpression: : (operator: UnaryOperator, argument: Expression, prefix: boolean) => UnaryExpression,
|
||||
assignmentExpression: : (operator: AssignmentOperator, left: Pattern, right: Expression) => AssignmentExpression,
|
||||
updateExpression: : (operator: UpdateOperator, argument: Expression, prefix: boolean) => UpdateExpression,
|
||||
logicalExpression: : (operator: LogicalOperator, left: Expression, right: Expression) => LogicalExpression,
|
||||
conditionalExpression: : (test: Expression, consequent: Expression, alternate: Expression) => ConditionalExpression,
|
||||
newExpression: : (callee: Expression, arguments: Expression[]) => NewExpression,
|
||||
callExpression: : (callee: Expression, arguments: Expression[]) => CallExpression,
|
||||
memberExpression: : (object: Expression, property: Identifier | Expression, computed: boolean) => MemberExpression,
|
||||
variableDeclaration: : (kind: \"var\" | \"let\" | \"const\", declarations: VariableDeclarator[]) => VariableDeclaration,
|
||||
functionDeclaration: : (id: Identifier, body: BlockStatement, params: Pattern[]) => FunctionDeclaration,
|
||||
variableDeclarator: : (id: Pattern, init?: Expression) => VariableDeclarator
|
||||
emptyStatement(): EmptyStatement;
|
||||
blockStatement(body: Statement[]): BlockStatement;
|
||||
expressionStatement(expression: Expression): ExpressionStatement;
|
||||
ifStatement(test: Expression,
|
||||
consequent: Statement,
|
||||
alternate?: Statement): IfStatement;
|
||||
breakStatement(label?: Identifier): BreakStatement;
|
||||
continueStatement(label?: Identifier): ContinueStatement;
|
||||
returnStatement(argument: ?Expression): ReturnStatement;
|
||||
throwStatement(argument: ?Expression): ThrowStatement;
|
||||
whileStatement(test: Expression, body: Statement): WhileStatement;
|
||||
forStatement(init: ?(VariableDeclaration | Expression),
|
||||
test: ?Expression,
|
||||
update: ?Expression,
|
||||
body: Statement): ForStatement;
|
||||
forInStatement(left: VariableDeclaration | Expression,
|
||||
right: Expression,
|
||||
body: Statement): ForInStatement;
|
||||
tryStatement(block: BlockStatement,
|
||||
handler: ?CatchClause,
|
||||
handlers: CatchClause[],
|
||||
finalizer?: BlockStatement): TryStatement;
|
||||
catchClause(param: Pattern,
|
||||
guard: ?Expression,
|
||||
body: BlockStatement): CatchClause;
|
||||
identifier(name: string): Identifier;
|
||||
literal(value: ?(string | boolean | number | RegExp),
|
||||
regex?: { pattern: string; flags: string }): Literal;
|
||||
thisExpression(): ThisExpression;
|
||||
arrayExpression(elements: Expression[]): ArrayExpression;
|
||||
objectExpreession(properties: Property[]): ObjectExpreession;
|
||||
property(kind: \"init\" | \"get\" | \"set\",
|
||||
key: Literal | Identifier,
|
||||
value: Expression): Property;
|
||||
functionExpression(id: ?Identifier,
|
||||
params: Pattern[],
|
||||
body: BlockStatement): FunctionExpression;
|
||||
binaryExpression(operator: BinaryOperator,
|
||||
left: Expression,
|
||||
right: Expression): BinaryExpression;
|
||||
unaryExpression(operator: UnaryOperator,
|
||||
argument: Expression,
|
||||
prefix: boolean): UnaryExpression;
|
||||
assignmentExpression(operator: AssignmentOperator,
|
||||
left: Pattern,
|
||||
right: Expression): AssignmentExpression;
|
||||
updateExpression(operator: UpdateOperator,
|
||||
argument: Expression,
|
||||
prefix: boolean): UpdateExpression;
|
||||
logicalExpression(operator: LogicalOperator,
|
||||
left: Expression,
|
||||
right: Expression): LogicalExpression;
|
||||
conditionalExpression(test: Expression,
|
||||
consequent: Expression,
|
||||
alternate: Expression): ConditionalExpression;
|
||||
newExpression(callee: Expression, arguments: Expression[]): NewExpression;
|
||||
callExpression(callee: Expression, arguments: Expression[]): CallExpression;
|
||||
memberExpression(object: Expression,
|
||||
property: Identifier | Expression,
|
||||
computed: boolean): MemberExpression;
|
||||
variableDeclaration(kind: \"var\" | \"let\" | \"const\",
|
||||
declarations: VariableDeclarator[]): VariableDeclaration;
|
||||
functionDeclaration(id: Identifier,
|
||||
body: BlockStatement,
|
||||
params: Pattern[]): FunctionDeclaration;
|
||||
variableDeclarator(id: Pattern, init?: Expression): VariableDeclarator
|
||||
} = a;
|
||||
"
|
||||
`;
|
||||
@@ -9,7 +9,7 @@ let tests = [
|
||||
|
||||
// moveTo
|
||||
function(ctx: CanvasRenderingContext2D) {
|
||||
ctx.moveTo(\'0\', \'1\'); // error: should be numbers
|
||||
ctx.moveTo('0', '1'); // error: should be numbers
|
||||
},
|
||||
];
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -22,7 +22,7 @@ let tests = [
|
||||
ctx.fillRect(0, 0, 200, 100);
|
||||
},
|
||||
function(ctx: CanvasRenderingContext2D) {
|
||||
ctx.moveTo(\"0\", \"1\");
|
||||
ctx.moveTo("0", "1");
|
||||
}
|
||||
];
|
||||
"
|
||||
@@ -34,8 +34,8 @@ exports[`test CustomEvent.js 1`] = `
|
||||
let tests = [
|
||||
// CustomEvent
|
||||
function(document: Document) {
|
||||
const event = document.createEvent(\'CustomEvent\');
|
||||
event.initCustomEvent(\'butts\', true, false, { nice: 42 });
|
||||
const event = document.createEvent('CustomEvent');
|
||||
event.initCustomEvent('butts', true, false, { nice: 42 });
|
||||
}
|
||||
];
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -43,8 +43,8 @@ let tests = [
|
||||
// CustomEvent
|
||||
let tests = [
|
||||
function(document: Document) {
|
||||
const event = document.createEvent(\"CustomEvent\");
|
||||
event.initCustomEvent(\"butts\", true, false, { nice: 42 });
|
||||
const event = document.createEvent("CustomEvent");
|
||||
event.initCustomEvent("butts", true, false, { nice: 42 });
|
||||
}
|
||||
];
|
||||
"
|
||||
@@ -56,10 +56,10 @@ exports[`test Document.js 1`] = `
|
||||
let tests = [
|
||||
// createElement
|
||||
function(document: Document) {
|
||||
(document.createElement(\'canvas\'): HTMLCanvasElement);
|
||||
(document.createElement(\'link\'): HTMLLinkElement);
|
||||
(document.createElement(\'option\'): HTMLOptionElement);
|
||||
(document.createElement(\'select\'): HTMLSelectElement);
|
||||
(document.createElement('canvas'): HTMLCanvasElement);
|
||||
(document.createElement('link'): HTMLLinkElement);
|
||||
(document.createElement('option'): HTMLOptionElement);
|
||||
(document.createElement('select'): HTMLSelectElement);
|
||||
}
|
||||
];
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -67,10 +67,10 @@ let tests = [
|
||||
// createElement
|
||||
let tests = [
|
||||
function(document: Document) {
|
||||
(document.createElement(\"canvas\"): HTMLCanvasElement);
|
||||
(document.createElement(\"link\"): HTMLLinkElement);
|
||||
(document.createElement(\"option\"): HTMLOptionElement);
|
||||
(document.createElement(\"select\"): HTMLSelectElement);
|
||||
(document.createElement("canvas"): HTMLCanvasElement);
|
||||
(document.createElement("link"): HTMLLinkElement);
|
||||
(document.createElement("option"): HTMLOptionElement);
|
||||
(document.createElement("select"): HTMLSelectElement);
|
||||
}
|
||||
];
|
||||
"
|
||||
@@ -85,13 +85,13 @@ let tests = [
|
||||
element.scrollIntoView();
|
||||
element.scrollIntoView(false);
|
||||
element.scrollIntoView({});
|
||||
element.scrollIntoView({ behavior: \'smooth\', block: \'end\' });
|
||||
element.scrollIntoView({ block: \'end\' });
|
||||
element.scrollIntoView({ behavior: \'smooth\' });
|
||||
element.scrollIntoView({ behavior: 'smooth', block: 'end' });
|
||||
element.scrollIntoView({ block: 'end' });
|
||||
element.scrollIntoView({ behavior: 'smooth' });
|
||||
|
||||
// fails
|
||||
element.scrollIntoView({ behavior: \'invalid\' });
|
||||
element.scrollIntoView({ block: \'invalid\' });
|
||||
element.scrollIntoView({ behavior: 'invalid' });
|
||||
element.scrollIntoView({ block: 'invalid' });
|
||||
element.scrollIntoView(1);
|
||||
}
|
||||
];
|
||||
@@ -104,11 +104,11 @@ let tests = [
|
||||
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({ behavior: "smooth", block: "end" });
|
||||
element.scrollIntoView({ block: "end" });
|
||||
element.scrollIntoView({ behavior: "smooth" });
|
||||
element.scrollIntoView({ behavior: "invalid" });
|
||||
element.scrollIntoView({ block: "invalid" });
|
||||
element.scrollIntoView(1);
|
||||
}
|
||||
];
|
||||
@@ -121,7 +121,7 @@ exports[`test HTMLCanvasElement.js 1`] = `
|
||||
let tests = [
|
||||
// getContext
|
||||
function(el: HTMLCanvasElement) {
|
||||
(el.getContext(\'2d\'): ?CanvasRenderingContext2D);
|
||||
(el.getContext('2d'): ?CanvasRenderingContext2D);
|
||||
}
|
||||
];
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -129,7 +129,7 @@ let tests = [
|
||||
// getContext
|
||||
let tests = [
|
||||
function(el: HTMLCanvasElement) {
|
||||
(el.getContext(\"2d\"): ?CanvasRenderingContext2D);
|
||||
(el.getContext("2d"): ?CanvasRenderingContext2D);
|
||||
}
|
||||
];
|
||||
"
|
||||
@@ -144,13 +144,13 @@ let tests = [
|
||||
element.scrollIntoView();
|
||||
element.scrollIntoView(false);
|
||||
element.scrollIntoView({});
|
||||
element.scrollIntoView({ behavior: \'smooth\', block: \'end\' });
|
||||
element.scrollIntoView({ block: \'end\' });
|
||||
element.scrollIntoView({ behavior: \'smooth\' });
|
||||
element.scrollIntoView({ behavior: 'smooth', block: 'end' });
|
||||
element.scrollIntoView({ block: 'end' });
|
||||
element.scrollIntoView({ behavior: 'smooth' });
|
||||
|
||||
// fails
|
||||
element.scrollIntoView({ behavior: \'invalid\' });
|
||||
element.scrollIntoView({ block: \'invalid\' });
|
||||
element.scrollIntoView({ behavior: 'invalid' });
|
||||
element.scrollIntoView({ block: 'invalid' });
|
||||
element.scrollIntoView(1);
|
||||
}
|
||||
];
|
||||
@@ -163,11 +163,11 @@ let tests = [
|
||||
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({ behavior: "smooth", block: "end" });
|
||||
element.scrollIntoView({ block: "end" });
|
||||
element.scrollIntoView({ behavior: "smooth" });
|
||||
element.scrollIntoView({ behavior: "invalid" });
|
||||
element.scrollIntoView({ block: "invalid" });
|
||||
element.scrollIntoView(1);
|
||||
}
|
||||
];
|
||||
@@ -180,11 +180,11 @@ exports[`test HTMLInputElement.js 1`] = `
|
||||
let tests = [
|
||||
// setRangeText
|
||||
function(el: HTMLInputElement) {
|
||||
el.setRangeText(\'foo\');
|
||||
el.setRangeText(\'foo\', 123); // end is required
|
||||
el.setRangeText(\'foo\', 123, 234);
|
||||
el.setRangeText(\'foo\', 123, 234, \'select\');
|
||||
el.setRangeText(\'foo\', 123, 234, \'bogus\'); // invalid value
|
||||
el.setRangeText('foo');
|
||||
el.setRangeText('foo', 123); // end is required
|
||||
el.setRangeText('foo', 123, 234);
|
||||
el.setRangeText('foo', 123, 234, 'select');
|
||||
el.setRangeText('foo', 123, 234, 'bogus'); // invalid value
|
||||
}
|
||||
];
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -194,11 +194,11 @@ let tests = [
|
||||
// invalid value
|
||||
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\");
|
||||
el.setRangeText("foo");
|
||||
el.setRangeText("foo", 123);
|
||||
el.setRangeText("foo", 123, 234);
|
||||
el.setRangeText("foo", 123, 234, "select");
|
||||
el.setRangeText("foo", 123, 234, "bogus");
|
||||
}
|
||||
];
|
||||
"
|
||||
@@ -207,9 +207,9 @@ let tests = [
|
||||
exports[`test URL.js 1`] = `
|
||||
"/* @flow */
|
||||
|
||||
const a = new URL(\'http://flowtype.org/\'); // correct
|
||||
const b = new URL(\'/docs\', a); // correct
|
||||
const c = new URL(\'/docs\', \'http://flowtype.org/\'); // correct
|
||||
const a = new URL('http://flowtype.org/'); // correct
|
||||
const b = new URL('/docs', a); // correct
|
||||
const c = new URL('/docs', 'http://flowtype.org/'); // correct
|
||||
|
||||
const d: URLSearchParams = c.searchParams; // correct
|
||||
const e: string = c.path; // not correct
|
||||
@@ -244,9 +244,9 @@ const r: string = c.username; // correct
|
||||
// correct
|
||||
// correct
|
||||
// correct
|
||||
const a = new URL(\"http://flowtype.org/\");
|
||||
const b = new URL(\"/docs\", a);
|
||||
const c = new URL(\"/docs\", \"http://flowtype.org/\");
|
||||
const a = new URL("http://flowtype.org/");
|
||||
const b = new URL("/docs", a);
|
||||
const c = new URL("/docs", "http://flowtype.org/");
|
||||
const d: URLSearchParams = c.searchParams;
|
||||
const e: string = c.path;
|
||||
const f: string = c.pathname;
|
||||
@@ -273,15 +273,15 @@ let tests = [
|
||||
// attachEvent
|
||||
function() {
|
||||
let target = new EventTarget();
|
||||
(target.attachEvent(\'foo\', listener): void); // invalid, may be undefined
|
||||
(target.attachEvent && target.attachEvent(\'foo\', listener): void); // valid
|
||||
(target.attachEvent('foo', listener): void); // invalid, may be undefined
|
||||
(target.attachEvent && target.attachEvent('foo', listener): void); // valid
|
||||
},
|
||||
|
||||
// detachEvent
|
||||
function() {
|
||||
let target = new EventTarget();
|
||||
(target.detachEvent(\'foo\', listener): void); // invalid, may be undefined
|
||||
(target.detachEvent && target.detachEvent(\'foo\', listener): void); // valid
|
||||
(target.detachEvent('foo', listener): void); // invalid, may be undefined
|
||||
(target.detachEvent && target.detachEvent('foo', listener): void); // valid
|
||||
},
|
||||
|
||||
function() {
|
||||
@@ -304,13 +304,13 @@ 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);
|
||||
(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);
|
||||
(target.detachEvent("foo", listener): void);
|
||||
(target.detachEvent && target.detachEvent("foo", listener): void);
|
||||
},
|
||||
function() {
|
||||
window.onmessage = (event: MessageEvent) => {
|
||||
@@ -330,7 +330,7 @@ let tests = [
|
||||
let path = new Path2D();
|
||||
(path.arcTo(0, 0, 0, 0, 10): void); // valid
|
||||
(path.arcTo(0, 0, 0, 0, 10, 20, 5): void); // valid
|
||||
(path.arcTo(0, 0, 0, 0, 10, \'20\', 5): void); // invalid
|
||||
(path.arcTo(0, 0, 0, 0, 10, '20', 5): void); // invalid
|
||||
},
|
||||
];
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -344,7 +344,7 @@ let tests = [
|
||||
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);
|
||||
(path.arcTo(0, 0, 0, 0, 10, "20", 5): void);
|
||||
}
|
||||
];
|
||||
"
|
||||
@@ -356,7 +356,7 @@ exports[`test registerElement.js 1`] = `
|
||||
let tests = [
|
||||
// should work with Object.create()
|
||||
function() {
|
||||
document.registerElement(\'custom-element\', {
|
||||
document.registerElement('custom-element', {
|
||||
prototype: Object.create(HTMLElement.prototype, {
|
||||
createdCallback: { value: function createdCallback () {
|
||||
}},
|
||||
@@ -378,7 +378,7 @@ let tests = [
|
||||
},
|
||||
// or with Object.assign()
|
||||
function() {
|
||||
document.registerElement(\'custom-element\', {
|
||||
document.registerElement('custom-element', {
|
||||
prototype: Object.assign(Object.create(HTMLElement.prototype), {
|
||||
createdCallback () {
|
||||
},
|
||||
@@ -398,7 +398,7 @@ let tests = [
|
||||
},
|
||||
// should complain about invalid callback parameters
|
||||
function() {
|
||||
document.registerElement(\'custom-element\', {
|
||||
document.registerElement('custom-element', {
|
||||
prototype: {
|
||||
attributeChangedCallback(
|
||||
localName: string,
|
||||
@@ -419,7 +419,7 @@ let tests = [
|
||||
let tests = [
|
||||
function() {
|
||||
document.registerElement(
|
||||
\"custom-element\",
|
||||
"custom-element",
|
||||
{
|
||||
prototype: Object.create(
|
||||
HTMLElement.prototype,
|
||||
@@ -456,7 +456,7 @@ let tests = [
|
||||
},
|
||||
function() {
|
||||
document.registerElement(
|
||||
\"custom-element\",
|
||||
"custom-element",
|
||||
{
|
||||
prototype: Object.assign(
|
||||
Object.create(HTMLElement.prototype),
|
||||
@@ -483,7 +483,7 @@ let tests = [
|
||||
},
|
||||
function() {
|
||||
document.registerElement(
|
||||
\"custom-element\",
|
||||
"custom-element",
|
||||
{
|
||||
prototype: {
|
||||
attributeChangedCallback(localName: string,
|
||||
@@ -683,16 +683,16 @@ let tests = [
|
||||
// NodeFilterInterface
|
||||
function() {
|
||||
document.createNodeIterator(document.body, -1, node => NodeFilter.FILTER_ACCEPT); // valid
|
||||
document.createNodeIterator(document.body, -1, node => \'accept\'); // invalid
|
||||
document.createNodeIterator(document.body, -1, node => 'accept'); // invalid
|
||||
document.createNodeIterator(document.body, -1, { accept: node => NodeFilter.FILTER_ACCEPT }); // valid
|
||||
document.createNodeIterator(document.body, -1, { accept: node => \'accept\' }); // invalid
|
||||
document.createNodeIterator(document.body, -1, { accept: node => 'accept' }); // invalid
|
||||
document.createNodeIterator(document.body, -1, {}); // invalid
|
||||
},
|
||||
function() {
|
||||
document.createTreeWalker(document.body, -1, node => NodeFilter.FILTER_ACCEPT); // valid
|
||||
document.createTreeWalker(document.body, -1, node => \'accept\'); // invalid
|
||||
document.createTreeWalker(document.body, -1, node => 'accept'); // invalid
|
||||
document.createTreeWalker(document.body, -1, { accept: node => NodeFilter.FILTER_ACCEPT }); // valid
|
||||
document.createTreeWalker(document.body, -1, { accept: node => \'accept\' }); // invalid
|
||||
document.createTreeWalker(document.body, -1, { accept: node => 'accept' }); // invalid
|
||||
document.createTreeWalker(document.body, -1, {}); // invalid
|
||||
},
|
||||
];
|
||||
@@ -897,7 +897,7 @@ let tests = [
|
||||
-1,
|
||||
node => NodeFilter.FILTER_ACCEPT
|
||||
);
|
||||
document.createNodeIterator(document.body, -1, node => \"accept\");
|
||||
document.createNodeIterator(document.body, -1, node => "accept");
|
||||
document.createNodeIterator(
|
||||
document.body,
|
||||
-1,
|
||||
@@ -906,7 +906,7 @@ let tests = [
|
||||
document.createNodeIterator(
|
||||
document.body,
|
||||
-1,
|
||||
{ accept: node => \"accept\" }
|
||||
{ accept: node => "accept" }
|
||||
);
|
||||
document.createNodeIterator(document.body, -1, {});
|
||||
},
|
||||
@@ -916,13 +916,13 @@ let tests = [
|
||||
-1,
|
||||
node => NodeFilter.FILTER_ACCEPT
|
||||
);
|
||||
document.createTreeWalker(document.body, -1, node => \"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, { accept: node => "accept" });
|
||||
document.createTreeWalker(document.body, -1, {});
|
||||
}
|
||||
];
|
||||
|
||||
@@ -17,7 +17,7 @@ module.exports = num;
|
||||
|
||||
exports[`test test.js 1`] = `
|
||||
"// @flow
|
||||
var num = require(\'./import\');
|
||||
var num = require('./import');
|
||||
function foo(x) { }
|
||||
foo(0);
|
||||
var a:string = num;
|
||||
@@ -40,7 +40,7 @@ const idxResult = idx(obj, obj => obj.a.b.c.d);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
// test deduping of inferred types
|
||||
var num = require(\"./import\");
|
||||
var num = require("./import");
|
||||
function foo(x) {
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ function tag(strings,...values) {
|
||||
var s2 = tag \`l\${42}r\`;
|
||||
|
||||
function tag2(strings,...values) {
|
||||
return { foo: \"\" }; // ok: tagged templates can return whatever
|
||||
return { foo: "" }; // ok: tagged templates can return whatever
|
||||
}
|
||||
|
||||
var s3 = tag2 \`la la la\`;
|
||||
@@ -29,7 +29,7 @@ function tag(strings, ...values) {
|
||||
}
|
||||
var s2 = tag\`l\${42}r\`;
|
||||
function tag2(strings, ...values) {
|
||||
return { foo: \"\" };
|
||||
return { foo: "" };
|
||||
}
|
||||
var s3 = tag2\`la la la\`;
|
||||
(s3.foo: number);
|
||||
|
||||
@@ -30,7 +30,7 @@ function union2keys(s: Union): Keys { return s; } // ok
|
||||
// ok
|
||||
// ok
|
||||
function isActive(
|
||||
ad: { state: $Keys<{ PAUSED: string, ACTIVE: string, DELETED: string }> }
|
||||
ad: { state: $Keys<{ PAUSED: string; ACTIVE: string; DELETED: string }> }
|
||||
): boolean {
|
||||
return ad.state === "ACTIVE";
|
||||
}
|
||||
@@ -40,7 +40,7 @@ function isActive2(ad: { state: $Keys<typeof MyStates> }): boolean {
|
||||
return ad.state === MyStates.ACTIVE;
|
||||
}
|
||||
isActive2({ state: "PAUSE" });
|
||||
type Keys = $Keys<{ x: any, y: any }>;
|
||||
type Keys = $Keys<{ x: any; y: any }>;
|
||||
type Union = "x" | "y";
|
||||
function keys2union(s: Keys): Union {
|
||||
return s;
|
||||
|
||||
@@ -2,11 +2,11 @@ exports[`test equals.js 1`] = `
|
||||
"/* @flow */
|
||||
|
||||
(1 == 1);
|
||||
(\"foo\" == \"bar\");
|
||||
("foo" == "bar");
|
||||
(1 == null);
|
||||
(null == 1);
|
||||
(1 == \"\"); // error
|
||||
(\"\" == 1); // error
|
||||
(1 == ""); // error
|
||||
("" == 1); // error
|
||||
|
||||
var x = (null : ?number);
|
||||
(x == 1);
|
||||
@@ -16,11 +16,11 @@ var x = (null : ?number);
|
||||
// error
|
||||
// error
|
||||
1 == 1;
|
||||
\"foo\" == \"bar\";
|
||||
"foo" == "bar";
|
||||
1 == null;
|
||||
null == 1;
|
||||
1 == \"\";
|
||||
\"\" == 1;
|
||||
1 == "";
|
||||
"" == 1;
|
||||
var x = (null: ?number);
|
||||
x == 1;
|
||||
1 == x;
|
||||
|
||||
@@ -303,11 +303,11 @@ exports[`test ES6_DefaultAndNamed.js 1`] = `
|
||||
"/* @flow */
|
||||
|
||||
export default 42;
|
||||
export var str = \'asdf\';
|
||||
export var str = 'asdf';
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
export default 42
|
||||
export var str = \"asdf\";
|
||||
export var str = "asdf";
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -317,13 +317,13 @@ exports[`test ES6_ExportAllFrom_Intermediary1.js 1`] = `
|
||||
* @flow
|
||||
*/
|
||||
|
||||
export * from \"ES6_ExportAllFrom_Source1\";
|
||||
export * from "ES6_ExportAllFrom_Source1";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/**
|
||||
* @providesModule ES6_ExportAllFrom_Intermediary1
|
||||
* @flow
|
||||
*/
|
||||
export * from \"ES6_ExportAllFrom_Source1\"
|
||||
export * from "ES6_ExportAllFrom_Source1"
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -333,13 +333,13 @@ exports[`test ES6_ExportAllFrom_Intermediary2.js 1`] = `
|
||||
* @flow
|
||||
*/
|
||||
|
||||
export * from \"ES6_ExportAllFrom_Source2\";
|
||||
export * from "ES6_ExportAllFrom_Source2";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/**
|
||||
* @providesModule ES6_ExportAllFrom_Intermediary2
|
||||
* @flow
|
||||
*/
|
||||
export * from \"ES6_ExportAllFrom_Source2\"
|
||||
export * from "ES6_ExportAllFrom_Source2"
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -378,12 +378,12 @@ export var numberValue2 = 1;
|
||||
exports[`test ES6_ExportAllFromMulti.js 1`] = `
|
||||
"// @flow
|
||||
|
||||
export * from \"./ES6_ExportAllFrom_Source1\";
|
||||
export * from \"./ES6_ExportAllFrom_Source2\";
|
||||
export * from "./ES6_ExportAllFrom_Source1";
|
||||
export * from "./ES6_ExportAllFrom_Source2";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
export * from \"./ES6_ExportAllFrom_Source1\"
|
||||
export * from \"./ES6_ExportAllFrom_Source2\"
|
||||
export * from "./ES6_ExportAllFrom_Source1"
|
||||
export * from "./ES6_ExportAllFrom_Source2"
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -396,13 +396,13 @@ exports[`test ES6_ExportFrom_Intermediary1.js 1`] = `
|
||||
export {
|
||||
numberValue1,
|
||||
numberValue2 as numberValue2_renamed
|
||||
} from \"ES6_ExportFrom_Source1\";
|
||||
} from "ES6_ExportFrom_Source1";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/**
|
||||
* @providesModule ES6_ExportFrom_Intermediary1
|
||||
* @flow
|
||||
*/
|
||||
export { numberValue1, numberValue2 as numberValue2_renamed } from \"ES6_ExportFrom_Source1\"
|
||||
export { numberValue1, numberValue2 as numberValue2_renamed } from "ES6_ExportFrom_Source1"
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -415,13 +415,13 @@ exports[`test ES6_ExportFrom_Intermediary2.js 1`] = `
|
||||
export {
|
||||
numberValue1,
|
||||
numberValue2 as numberValue2_renamed2
|
||||
} from \"ES6_ExportFrom_Source2\";
|
||||
} from "ES6_ExportFrom_Source2";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/**
|
||||
* @providesModule ES6_ExportFrom_Intermediary2
|
||||
* @flow
|
||||
*/
|
||||
export { numberValue1, numberValue2 as numberValue2_renamed2 } from \"ES6_ExportFrom_Source2\"
|
||||
export { numberValue1, numberValue2 as numberValue2_renamed2 } from "ES6_ExportFrom_Source2"
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -575,7 +575,7 @@ exports.numberValue1 = 42;
|
||||
exports.numberValue2 = 42;
|
||||
exports.numberValue3 = 42;
|
||||
exports.numberValue4 = 42;
|
||||
exports.stringValue = \"str\";
|
||||
exports.stringValue = "str";
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/**
|
||||
* @providesModule A
|
||||
@@ -585,7 +585,7 @@ exports.numberValue1 = 42;
|
||||
exports.numberValue2 = 42;
|
||||
exports.numberValue3 = 42;
|
||||
exports.numberValue4 = 42;
|
||||
exports.stringValue = \"str\";
|
||||
exports.stringValue = "str";
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -662,44 +662,44 @@ exports[`test es6modules.js 1`] = `
|
||||
// ===================== //
|
||||
|
||||
// @providesModule
|
||||
import * as DefaultA from \"A\";
|
||||
import * as DefaultA from "A";
|
||||
var a1: number = DefaultA.numberValue1;
|
||||
var a2: string = DefaultA.numberValue1; // Error: number ~> string
|
||||
|
||||
// File path
|
||||
import * as DefaultB from \"./B\";
|
||||
import * as DefaultB from "./B";
|
||||
var b1: number = DefaultB.numberValue;
|
||||
var b2: string = DefaultB.numberValue; // Error: number ~> string
|
||||
|
||||
// C.js exists, but not as a providesModule
|
||||
import DefaultC from \"C\"; // Error: No such module
|
||||
import DefaultC from "C"; // Error: No such module
|
||||
|
||||
// @providesModule D exists, but not as a filename
|
||||
import DefaultD from \"./D\"; // Error: No such module
|
||||
import DefaultD from "./D"; // Error: No such module
|
||||
|
||||
// ================================================ //
|
||||
// == CommonJS Clobbering Literal Exports -> ES6 == //
|
||||
// ================================================ //
|
||||
|
||||
import {doesntExist1} from \"CommonJS_Clobbering_Lit\"; // Error: Not an exported binding
|
||||
import {doesntExist1} from "CommonJS_Clobbering_Lit"; // Error: Not an exported binding
|
||||
|
||||
import {numberValue1} from \"CommonJS_Clobbering_Lit\";
|
||||
import {numberValue1} from "CommonJS_Clobbering_Lit";
|
||||
var c1: number = numberValue1;
|
||||
var c2: string = numberValue1; // Error: number ~> string
|
||||
|
||||
import {numberValue2 as numVal1} from \"CommonJS_Clobbering_Lit\";
|
||||
import {numberValue2 as numVal1} from "CommonJS_Clobbering_Lit";
|
||||
var d1: number = numVal1;
|
||||
var d2: string = numVal1; // Error: number ~> string
|
||||
|
||||
import CJS_Clobb_Lit from \"CommonJS_Clobbering_Lit\";
|
||||
import CJS_Clobb_Lit from "CommonJS_Clobbering_Lit";
|
||||
var e1: number = CJS_Clobb_Lit.numberValue3;
|
||||
var e2: string = CJS_Clobb_Lit.numberValue3; // Error: number ~> string
|
||||
CJS_Clobb_Lit.doesntExist; // Error: doesntExist isn\'t a property
|
||||
CJS_Clobb_Lit.doesntExist; // Error: doesntExist isn't a property
|
||||
|
||||
import * as CJS_Clobb_Lit_NS from \"CommonJS_Clobbering_Lit\";
|
||||
import * as CJS_Clobb_Lit_NS from "CommonJS_Clobbering_Lit";
|
||||
var f1: number = CJS_Clobb_Lit_NS.numberValue4;
|
||||
var f2: number = CJS_Clobb_Lit_NS.default.numberValue4;
|
||||
CJS_Clobb_Lit_NS.default.default; // Error: No \'default\' property on the exported obj
|
||||
CJS_Clobb_Lit_NS.default.default; // Error: No 'default' property on the exported obj
|
||||
var f3: string = CJS_Clobb_Lit_NS.numberValue4; // Error: number ~> string
|
||||
var f4: string = CJS_Clobb_Lit_NS.default.numberValue5; // Error: number ~> string
|
||||
|
||||
@@ -707,15 +707,15 @@ var f4: string = CJS_Clobb_Lit_NS.default.numberValue5; // Error: number ~> stri
|
||||
// == CommonJS Clobbering Class Exports -> ES6 == //
|
||||
// ============================================== //
|
||||
|
||||
import {doesntExist2} from \"CommonJS_Clobbering_Class\"; // Error: Not an exported binding
|
||||
import {doesntExist2} from "CommonJS_Clobbering_Class"; // Error: Not an exported binding
|
||||
|
||||
// The following import should error because class statics are not turned into
|
||||
// named exports for now. This avoids complexities with polymorphic static
|
||||
// members (where the polymophism is defined on the class itself rather than the
|
||||
// method).
|
||||
import {staticNumber1, baseProp, childProp} from \"CommonJS_Clobbering_Class\"; // Error
|
||||
import {staticNumber1, baseProp, childProp} from "CommonJS_Clobbering_Class"; // Error
|
||||
|
||||
import CJS_Clobb_Class from \"CommonJS_Clobbering_Class\";
|
||||
import CJS_Clobb_Class from "CommonJS_Clobbering_Class";
|
||||
new CJS_Clobb_Class();
|
||||
new CJS_Clobb_Class().doesntExist; // Error: Class has no \`doesntExist\` property
|
||||
var h1: number = CJS_Clobb_Class.staticNumber2();
|
||||
@@ -723,8 +723,8 @@ var h2: string = CJS_Clobb_Class.staticNumber2(); // Error: number ~> string
|
||||
var h3: number = new CJS_Clobb_Class().instNumber1();
|
||||
var h4: string = new CJS_Clobb_Class().instNumber1(); // Error: number ~> string
|
||||
|
||||
import * as CJS_Clobb_Class_NS from \"CommonJS_Clobbering_Class\";
|
||||
new CJS_Clobb_Class_NS(); // Error: Namespace object isn\'t constructable
|
||||
import * as CJS_Clobb_Class_NS from "CommonJS_Clobbering_Class";
|
||||
new CJS_Clobb_Class_NS(); // Error: Namespace object isn't constructable
|
||||
var i1: number = CJS_Clobb_Class_NS.staticNumber3(); // Error: Class statics not copied to Namespace object
|
||||
var i2: number = new CJS_Clobb_Class_NS.default().instNumber2();
|
||||
var i3: string = new CJS_Clobb_Class_NS.default().instNumber2(); // Error: number ~> string
|
||||
@@ -733,22 +733,22 @@ var i3: string = new CJS_Clobb_Class_NS.default().instNumber2(); // Error: numbe
|
||||
// == CommonJS Named Exports -> ES6 == //
|
||||
// =================================== //
|
||||
|
||||
import {doesntExist3} from \"CommonJS_Named\"; // Error: Not an exported binding
|
||||
import {doesntExist3} from "CommonJS_Named"; // Error: Not an exported binding
|
||||
|
||||
import {numberValue2} from \"CommonJS_Named\";
|
||||
import {numberValue2} from "CommonJS_Named";
|
||||
var j1: number = numberValue2;
|
||||
var j2: string = numberValue2; // Error: number ~> string
|
||||
|
||||
import {numberValue3 as numVal3} from \"CommonJS_Named\";
|
||||
import {numberValue3 as numVal3} from "CommonJS_Named";
|
||||
var k1: number = numVal3;
|
||||
var k2: string = numVal3; // Error: number ~> string
|
||||
|
||||
import * as CJS_Named from \"CommonJS_Named\";
|
||||
import * as CJS_Named from "CommonJS_Named";
|
||||
var l1: number = CJS_Named.numberValue1;
|
||||
var l2: string = CJS_Named.numberValue1; // Error: number ~> string
|
||||
CJS_Named.doesntExist; // Error: doesntExist isn\'t a property
|
||||
CJS_Named.doesntExist; // Error: doesntExist isn't a property
|
||||
|
||||
import * as CJS_Named_NS from \"CommonJS_Named\";
|
||||
import * as CJS_Named_NS from "CommonJS_Named";
|
||||
var m1: number = CJS_Named_NS.numberValue4;
|
||||
var m2: string = CJS_Named_NS.default.numberValue4; // Error: CommonJS_Named has no default export
|
||||
var m3: string = CJS_Named_NS.numberValue4; // Error: number ~> string
|
||||
@@ -757,21 +757,21 @@ var m3: string = CJS_Named_NS.numberValue4; // Error: number ~> string
|
||||
// == ES6 Default -> ES6 == //
|
||||
//////////////////////////////
|
||||
|
||||
import {doesntExist4} from \"ES6_Default_AnonFunction1\"; // Error: Not an exported binding
|
||||
import {doesntExist4} from "ES6_Default_AnonFunction1"; // Error: Not an exported binding
|
||||
|
||||
import ES6_Def_AnonFunc1 from \"ES6_Default_AnonFunction1\";
|
||||
import ES6_Def_AnonFunc1 from "ES6_Default_AnonFunction1";
|
||||
var n1: number = ES6_Def_AnonFunc1();
|
||||
var n2: string = ES6_Def_AnonFunc1(); // Error: number ~> string
|
||||
|
||||
import ES6_Def_NamedFunc1 from \"ES6_Default_NamedFunction1\";
|
||||
import ES6_Def_NamedFunc1 from "ES6_Default_NamedFunction1";
|
||||
var o1: number = ES6_Def_NamedFunc1();
|
||||
var o2: string = ES6_Def_NamedFunc1(); // Error: number ~> string
|
||||
|
||||
import ES6_Def_AnonClass1 from \"ES6_Default_AnonClass1\";
|
||||
import ES6_Def_AnonClass1 from "ES6_Default_AnonClass1";
|
||||
var p1: number = new ES6_Def_AnonClass1().givesANum();
|
||||
var p2: string = new ES6_Def_AnonClass1().givesANum(); // Error: number ~> string
|
||||
|
||||
import ES6_Def_NamedClass1 from \"ES6_Default_NamedClass1\";
|
||||
import ES6_Def_NamedClass1 from "ES6_Default_NamedClass1";
|
||||
var q1: number = new ES6_Def_NamedClass1().givesANum();
|
||||
var q2: string = new ES6_Def_NamedClass1().givesANum(); // Error: number ~> string
|
||||
|
||||
@@ -779,57 +779,57 @@ var q2: string = new ES6_Def_NamedClass1().givesANum(); // Error: number ~> stri
|
||||
// == ES6 Named -> ES6 == //
|
||||
////////////////////////////
|
||||
|
||||
import doesntExist5 from \"ES6_Named1\"; // Error: Not an exported binding
|
||||
import doesntExist5 from "ES6_Named1"; // Error: Not an exported binding
|
||||
|
||||
import {specifierNumber1 as specifierNumber1_1} from \"ES6_Named1\";
|
||||
import {specifierNumber1 as specifierNumber1_1} from "ES6_Named1";
|
||||
var r1: number = specifierNumber1_1;
|
||||
var r2: string = specifierNumber1_1; // Error: number ~> string
|
||||
|
||||
import {specifierNumber2Renamed} from \"ES6_Named1\";
|
||||
import {specifierNumber2Renamed} from "ES6_Named1";
|
||||
var s1: number = specifierNumber2Renamed;
|
||||
var s2: string = specifierNumber2Renamed; // Error: number ~> string
|
||||
|
||||
import {specifierNumber3 as specifierNumber3Renamed} from \"ES6_Named1\";
|
||||
import {specifierNumber3 as specifierNumber3Renamed} from "ES6_Named1";
|
||||
var t1: number = specifierNumber3Renamed;
|
||||
var t2: string = specifierNumber3Renamed; // Error: number ~> string
|
||||
|
||||
import {groupedSpecifierNumber1, groupedSpecifierNumber2} from \"ES6_Named1\";
|
||||
import {groupedSpecifierNumber1, groupedSpecifierNumber2} from "ES6_Named1";
|
||||
var u1: number = groupedSpecifierNumber1;
|
||||
var u2: number = groupedSpecifierNumber2;
|
||||
var u3: string = groupedSpecifierNumber1; // Error: number ~> string
|
||||
var u4: string = groupedSpecifierNumber2; // Error: number ~> string
|
||||
|
||||
import {givesANumber} from \"ES6_Named1\";
|
||||
import {givesANumber} from "ES6_Named1";
|
||||
var v1: number = givesANumber();
|
||||
var v2: string = givesANumber(); // Error: number ~> string
|
||||
|
||||
import {NumberGenerator} from \"ES6_Named1\";
|
||||
import {NumberGenerator} from "ES6_Named1";
|
||||
var w1: number = new NumberGenerator().givesANumber();
|
||||
var w2: string = new NumberGenerator().givesANumber(); // Error: number ~> string
|
||||
|
||||
import {varDeclNumber1, varDeclNumber2} from \"ES6_Named1\";
|
||||
import {varDeclNumber1, varDeclNumber2} from "ES6_Named1";
|
||||
var x1: number = varDeclNumber1;
|
||||
var x2: number = varDeclNumber2;
|
||||
var x3: string = varDeclNumber1; // Error: number ~> string
|
||||
var x4: string = varDeclNumber2; // Error: number ~> string
|
||||
|
||||
import {destructuredObjNumber} from \"ES6_Named1\";
|
||||
import {destructuredObjNumber} from "ES6_Named1";
|
||||
var y1: number = destructuredObjNumber;
|
||||
var y2: string = destructuredObjNumber; // Error: number ~> string
|
||||
|
||||
import {destructuredArrNumber} from \"ES6_Named1\";
|
||||
import {destructuredArrNumber} from "ES6_Named1";
|
||||
var z1: number = destructuredArrNumber;
|
||||
var z2: string = destructuredArrNumber; // Error: number ~> string
|
||||
|
||||
import {numberValue1 as numberValue4} from \"ES6_ExportFrom_Intermediary1\";
|
||||
import {numberValue1 as numberValue4} from "ES6_ExportFrom_Intermediary1";
|
||||
var aa1: number = numberValue4;
|
||||
var aa2: string = numberValue4; // Error: number ~> string
|
||||
|
||||
import {numberValue2_renamed} from \"ES6_ExportFrom_Intermediary1\";
|
||||
import {numberValue2_renamed} from "ES6_ExportFrom_Intermediary1";
|
||||
var ab1: number = numberValue2_renamed;
|
||||
var ab2: string = numberValue2_renamed; // Error: number ~> string
|
||||
|
||||
import {numberValue1 as numberValue5} from \"ES6_ExportAllFrom_Intermediary1\";
|
||||
import {numberValue1 as numberValue5} from "ES6_ExportAllFrom_Intermediary1";
|
||||
var ac1: number = numberValue5;
|
||||
var ac2: string = numberValue5; // Error: number ~> string
|
||||
|
||||
@@ -837,21 +837,21 @@ var ac2: string = numberValue5; // Error: number ~> string
|
||||
// == ES6 Default -> CommonJS == //
|
||||
///////////////////////////////////
|
||||
|
||||
require(\'ES6_Default_AnonFunction2\').doesntExist; // Error: \'doesntExist\' isn\'t an export
|
||||
require('ES6_Default_AnonFunction2').doesntExist; // Error: 'doesntExist' isn't an export
|
||||
|
||||
var ES6_Def_AnonFunc2 = require(\"ES6_Default_AnonFunction2\").default;
|
||||
var ES6_Def_AnonFunc2 = require("ES6_Default_AnonFunction2").default;
|
||||
var ad1: number = ES6_Def_AnonFunc2();
|
||||
var ad2: string = ES6_Def_AnonFunc2(); // Error: number ~> string
|
||||
|
||||
var ES6_Def_NamedFunc2 = require(\"ES6_Default_NamedFunction2\").default;
|
||||
var ES6_Def_NamedFunc2 = require("ES6_Default_NamedFunction2").default;
|
||||
var ae1: number = ES6_Def_NamedFunc2();
|
||||
var ae2: string = ES6_Def_NamedFunc2(); // Error: number ~> string
|
||||
|
||||
var ES6_Def_AnonClass2 = require(\"ES6_Default_AnonClass2\").default;
|
||||
var ES6_Def_AnonClass2 = require("ES6_Default_AnonClass2").default;
|
||||
var af1: number = new ES6_Def_AnonClass2().givesANum();
|
||||
var af2: string = new ES6_Def_AnonClass2().givesANum(); // Error: number ~> string
|
||||
|
||||
var ES6_Def_NamedClass2 = require(\"ES6_Default_NamedClass2\").default;
|
||||
var ES6_Def_NamedClass2 = require("ES6_Default_NamedClass2").default;
|
||||
var ag1: number = new ES6_Def_NamedClass2().givesANum();
|
||||
var ag2: string = new ES6_Def_NamedClass2().givesANum(); // Error: number ~> string
|
||||
|
||||
@@ -859,53 +859,53 @@ var ag2: string = new ES6_Def_NamedClass2().givesANum(); // Error: number ~> str
|
||||
// == ES6 Named -> CommonJS == //
|
||||
/////////////////////////////////
|
||||
|
||||
var specifierNumber4 = require(\"ES6_Named2\").specifierNumber4;
|
||||
var specifierNumber4 = require("ES6_Named2").specifierNumber4;
|
||||
var ah1: number = specifierNumber4;
|
||||
var ah2: string = specifierNumber4; // Error: number ~> string
|
||||
|
||||
var specifierNumber5Renamed = require(\"ES6_Named2\").specifierNumber5Renamed;
|
||||
var specifierNumber5Renamed = require("ES6_Named2").specifierNumber5Renamed;
|
||||
var ai1: number = specifierNumber5Renamed;
|
||||
var ai2: string = specifierNumber5Renamed; // Error: number ~> string
|
||||
|
||||
var groupedSpecifierNumber3 = require(\"ES6_Named2\").groupedSpecifierNumber3;
|
||||
var groupedSpecifierNumber4 = require(\"ES6_Named2\").groupedSpecifierNumber4;
|
||||
var groupedSpecifierNumber3 = require("ES6_Named2").groupedSpecifierNumber3;
|
||||
var groupedSpecifierNumber4 = require("ES6_Named2").groupedSpecifierNumber4;
|
||||
var aj1: number = groupedSpecifierNumber3;
|
||||
var aj2: number = groupedSpecifierNumber4;
|
||||
var aj3: string = groupedSpecifierNumber3; // Error: number ~> string
|
||||
var aj4: string = groupedSpecifierNumber4; // Error: number ~> string
|
||||
|
||||
var givesANumber2 = require(\"ES6_Named2\").givesANumber2;
|
||||
var givesANumber2 = require("ES6_Named2").givesANumber2;
|
||||
var ak1: number = givesANumber2();
|
||||
var ak2: string = givesANumber2(); // Error: number ~> string
|
||||
|
||||
var NumberGenerator2 = require(\"ES6_Named2\").NumberGenerator2;
|
||||
var NumberGenerator2 = require("ES6_Named2").NumberGenerator2;
|
||||
var al1: number = new NumberGenerator2().givesANumber();
|
||||
var al2: string = new NumberGenerator2().givesANumber(); // Error: number ~> string
|
||||
|
||||
var varDeclNumber3 = require(\"ES6_Named2\").varDeclNumber3;
|
||||
var varDeclNumber4 = require(\"ES6_Named2\").varDeclNumber4;
|
||||
var varDeclNumber3 = require("ES6_Named2").varDeclNumber3;
|
||||
var varDeclNumber4 = require("ES6_Named2").varDeclNumber4;
|
||||
var am1: number = varDeclNumber3;
|
||||
var am2: number = varDeclNumber4;
|
||||
var am3: string = varDeclNumber3; // Error: number ~> string
|
||||
var am4: string = varDeclNumber4; // Error: number ~> string
|
||||
|
||||
var destructuredObjNumber2 = require(\"ES6_Named2\").destructuredObjNumber2;
|
||||
var destructuredObjNumber2 = require("ES6_Named2").destructuredObjNumber2;
|
||||
var an1: number = destructuredObjNumber2;
|
||||
var an2: string = destructuredObjNumber2; // Error: number ~> string
|
||||
|
||||
var destructuredArrNumber2 = require(\"ES6_Named2\").destructuredArrNumber2;
|
||||
var destructuredArrNumber2 = require("ES6_Named2").destructuredArrNumber2;
|
||||
var ao1: number = destructuredArrNumber2;
|
||||
var ao2: string = destructuredArrNumber2; // Error: number ~> string
|
||||
|
||||
var numberValue6 = require(\"ES6_ExportFrom_Intermediary2\").numberValue1;
|
||||
var numberValue6 = require("ES6_ExportFrom_Intermediary2").numberValue1;
|
||||
var ap1: number = numberValue6;
|
||||
var ap2: string = numberValue6; // Error: number ~> string
|
||||
|
||||
var numberValue2_renamed2 = require(\"ES6_ExportFrom_Intermediary2\").numberValue2_renamed2;
|
||||
var numberValue2_renamed2 = require("ES6_ExportFrom_Intermediary2").numberValue2_renamed2;
|
||||
var aq1: number = numberValue2_renamed2;
|
||||
var aq2: string = numberValue2_renamed2; // Error: number ~> string
|
||||
|
||||
var numberValue7 = require(\"ES6_ExportAllFrom_Intermediary2\").numberValue2;
|
||||
var numberValue7 = require("ES6_ExportAllFrom_Intermediary2").numberValue2;
|
||||
var ar1: number = numberValue7;
|
||||
var ar2: string = numberValue7; // Error: number ~> string
|
||||
|
||||
@@ -913,7 +913,7 @@ var ar2: string = numberValue7; // Error: number ~> string
|
||||
// == ES6 Default+Named -> ES6 import Default+Named== //
|
||||
////////////////////////////////////////////////////////
|
||||
|
||||
import defaultNum, {str as namedStr} from \"./ES6_DefaultAndNamed\";
|
||||
import defaultNum, {str as namedStr} from "./ES6_DefaultAndNamed";
|
||||
|
||||
var as1: number = defaultNum;
|
||||
var as2: string = defaultNum; // Error: number ~> string
|
||||
@@ -925,13 +925,13 @@ var as4: number = namedStr; // Error: string ~> number
|
||||
// == Side-effect only ES6 imports == //
|
||||
////////////////////////////////////////
|
||||
|
||||
import \"./SideEffects\";
|
||||
import "./SideEffects";
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// == Suggest export name on likely typo == //
|
||||
//////////////////////////////////////////////
|
||||
import specifierNumber1 from \"ES6_Named1\"; // Error: Did you mean \`import {specifierNumber1} from ...\`?
|
||||
import {specifierNumber} from \"ES6_Named1\"; // Error: Did you mean \`specifierNumber1\`?
|
||||
import specifierNumber1 from "ES6_Named1"; // Error: Did you mean \`import {specifierNumber1} from ...\`?
|
||||
import {specifierNumber} from "ES6_Named1"; // Error: Did you mean \`specifierNumber1\`?
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
// == Multi \`export *\` should combine exports == //
|
||||
@@ -939,7 +939,7 @@ import {specifierNumber} from \"ES6_Named1\"; // Error: Did you mean \`specifier
|
||||
import {
|
||||
numberValue1 as numberValue8,
|
||||
numberValue2 as numberValue9
|
||||
} from \"./ES6_ExportAllFromMulti\";
|
||||
} from "./ES6_ExportAllFromMulti";
|
||||
|
||||
var at1: number = numberValue8;
|
||||
var at2: string = numberValue8; // Error: number ~> string
|
||||
@@ -950,7 +950,7 @@ var at4: string = numberValue9; // Error: number ~> string
|
||||
/////////////////////////////////////////////////////////////
|
||||
// == Vanilla \`import\` cannot import a type-only export == //
|
||||
/////////////////////////////////////////////////////////////
|
||||
import {typeAlias} from \"./ExportType\"; // Error: Cannot vanilla-import a type alias!
|
||||
import {typeAlias} from "./ExportType"; // Error: Cannot vanilla-import a type alias!
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
// ===================== //
|
||||
@@ -971,8 +971,8 @@ import {typeAlias} from \"./ExportType\"; // Error: Cannot vanilla-import a type
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
// Error: doesntExist isn\'t a property
|
||||
// Error: No \'default\' property on the exported obj
|
||||
// Error: doesntExist isn't a property
|
||||
// Error: No 'default' property on the exported obj
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
// ============================================== //
|
||||
@@ -987,7 +987,7 @@ import {typeAlias} from \"./ExportType\"; // Error: Cannot vanilla-import a type
|
||||
// Error: Class has no \`doesntExist\` property
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
// Error: Namespace object isn\'t constructable
|
||||
// Error: Namespace object isn't constructable
|
||||
// Error: Class statics not copied to Namespace object
|
||||
// Error: number ~> string
|
||||
// =================================== //
|
||||
@@ -997,7 +997,7 @@ import {typeAlias} from \"./ExportType\"; // Error: Cannot vanilla-import a type
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
// Error: doesntExist isn\'t a property
|
||||
// Error: doesntExist isn't a property
|
||||
// Error: CommonJS_Named has no default export
|
||||
// Error: number ~> string
|
||||
//////////////////////////////
|
||||
@@ -1029,7 +1029,7 @@ import {typeAlias} from \"./ExportType\"; // Error: Cannot vanilla-import a type
|
||||
///////////////////////////////////
|
||||
// == ES6 Default -> CommonJS == //
|
||||
///////////////////////////////////
|
||||
// Error: \'doesntExist\' isn\'t an export
|
||||
// Error: 'doesntExist' isn't an export
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
// Error: number ~> string
|
||||
@@ -1072,182 +1072,182 @@ import {typeAlias} from \"./ExportType\"; // Error: Cannot vanilla-import a type
|
||||
// == Vanilla \`import\` cannot import a type-only export == //
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Error: Cannot vanilla-import a type alias!
|
||||
import * as DefaultA from \"A\";
|
||||
import * as DefaultA from "A";
|
||||
var a1: number = DefaultA.numberValue1;
|
||||
var a2: string = DefaultA.numberValue1;
|
||||
import * as DefaultB from \"./B\";
|
||||
import * as DefaultB from "./B";
|
||||
var b1: number = DefaultB.numberValue;
|
||||
var b2: string = DefaultB.numberValue;
|
||||
import DefaultC from \"C\";
|
||||
import DefaultD from \"./D\";
|
||||
import { doesntExist1 } from \"CommonJS_Clobbering_Lit\";
|
||||
import { numberValue1 } from \"CommonJS_Clobbering_Lit\";
|
||||
import DefaultC from "C";
|
||||
import DefaultD from "./D";
|
||||
import { doesntExist1 } from "CommonJS_Clobbering_Lit";
|
||||
import { numberValue1 } from "CommonJS_Clobbering_Lit";
|
||||
var c1: number = numberValue1;
|
||||
var c2: string = numberValue1;
|
||||
import { numberValue2 as numVal1 } from \"CommonJS_Clobbering_Lit\";
|
||||
import { numberValue2 as numVal1 } from "CommonJS_Clobbering_Lit";
|
||||
var d1: number = numVal1;
|
||||
var d2: string = numVal1;
|
||||
import CJS_Clobb_Lit from \"CommonJS_Clobbering_Lit\";
|
||||
import CJS_Clobb_Lit from "CommonJS_Clobbering_Lit";
|
||||
var e1: number = CJS_Clobb_Lit.numberValue3;
|
||||
var e2: string = CJS_Clobb_Lit.numberValue3;
|
||||
CJS_Clobb_Lit.doesntExist;
|
||||
import * as CJS_Clobb_Lit_NS from \"CommonJS_Clobbering_Lit\";
|
||||
import * as CJS_Clobb_Lit_NS from "CommonJS_Clobbering_Lit";
|
||||
var f1: number = CJS_Clobb_Lit_NS.numberValue4;
|
||||
var f2: number = CJS_Clobb_Lit_NS.default.numberValue4;
|
||||
CJS_Clobb_Lit_NS.default.default;
|
||||
var f3: string = CJS_Clobb_Lit_NS.numberValue4;
|
||||
var f4: string = CJS_Clobb_Lit_NS.default.numberValue5;
|
||||
import { doesntExist2 } from \"CommonJS_Clobbering_Class\";
|
||||
import { staticNumber1, baseProp, childProp } from \"CommonJS_Clobbering_Class\";
|
||||
import CJS_Clobb_Class from \"CommonJS_Clobbering_Class\";
|
||||
import { doesntExist2 } from "CommonJS_Clobbering_Class";
|
||||
import { staticNumber1, baseProp, childProp } from "CommonJS_Clobbering_Class";
|
||||
import CJS_Clobb_Class from "CommonJS_Clobbering_Class";
|
||||
new CJS_Clobb_Class();
|
||||
new CJS_Clobb_Class().doesntExist;
|
||||
var h1: number = CJS_Clobb_Class.staticNumber2();
|
||||
var h2: string = CJS_Clobb_Class.staticNumber2();
|
||||
var h3: number = new CJS_Clobb_Class().instNumber1();
|
||||
var h4: string = new CJS_Clobb_Class().instNumber1();
|
||||
import * as CJS_Clobb_Class_NS from \"CommonJS_Clobbering_Class\";
|
||||
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();
|
||||
import { doesntExist3 } from \"CommonJS_Named\";
|
||||
import { numberValue2 } from \"CommonJS_Named\";
|
||||
import { doesntExist3 } from "CommonJS_Named";
|
||||
import { numberValue2 } from "CommonJS_Named";
|
||||
var j1: number = numberValue2;
|
||||
var j2: string = numberValue2;
|
||||
import { numberValue3 as numVal3 } from \"CommonJS_Named\";
|
||||
import { numberValue3 as numVal3 } from "CommonJS_Named";
|
||||
var k1: number = numVal3;
|
||||
var k2: string = numVal3;
|
||||
import * as CJS_Named from \"CommonJS_Named\";
|
||||
import * as CJS_Named from "CommonJS_Named";
|
||||
var l1: number = CJS_Named.numberValue1;
|
||||
var l2: string = CJS_Named.numberValue1;
|
||||
CJS_Named.doesntExist;
|
||||
import * as CJS_Named_NS from \"CommonJS_Named\";
|
||||
import * as CJS_Named_NS from "CommonJS_Named";
|
||||
var m1: number = CJS_Named_NS.numberValue4;
|
||||
var m2: string = CJS_Named_NS.default.numberValue4;
|
||||
var m3: string = CJS_Named_NS.numberValue4;
|
||||
import { doesntExist4 } from \"ES6_Default_AnonFunction1\";
|
||||
import ES6_Def_AnonFunc1 from \"ES6_Default_AnonFunction1\";
|
||||
import { doesntExist4 } from "ES6_Default_AnonFunction1";
|
||||
import ES6_Def_AnonFunc1 from "ES6_Default_AnonFunction1";
|
||||
var n1: number = ES6_Def_AnonFunc1();
|
||||
var n2: string = ES6_Def_AnonFunc1();
|
||||
import ES6_Def_NamedFunc1 from \"ES6_Default_NamedFunction1\";
|
||||
import ES6_Def_NamedFunc1 from "ES6_Default_NamedFunction1";
|
||||
var o1: number = ES6_Def_NamedFunc1();
|
||||
var o2: string = ES6_Def_NamedFunc1();
|
||||
import ES6_Def_AnonClass1 from \"ES6_Default_AnonClass1\";
|
||||
import ES6_Def_AnonClass1 from "ES6_Default_AnonClass1";
|
||||
var p1: number = new ES6_Def_AnonClass1().givesANum();
|
||||
var p2: string = new ES6_Def_AnonClass1().givesANum();
|
||||
import ES6_Def_NamedClass1 from \"ES6_Default_NamedClass1\";
|
||||
import ES6_Def_NamedClass1 from "ES6_Default_NamedClass1";
|
||||
var q1: number = new ES6_Def_NamedClass1().givesANum();
|
||||
var q2: string = new ES6_Def_NamedClass1().givesANum();
|
||||
import doesntExist5 from \"ES6_Named1\";
|
||||
import { specifierNumber1 as specifierNumber1_1 } from \"ES6_Named1\";
|
||||
import doesntExist5 from "ES6_Named1";
|
||||
import { specifierNumber1 as specifierNumber1_1 } from "ES6_Named1";
|
||||
var r1: number = specifierNumber1_1;
|
||||
var r2: string = specifierNumber1_1;
|
||||
import { specifierNumber2Renamed } from \"ES6_Named1\";
|
||||
import { specifierNumber2Renamed } from "ES6_Named1";
|
||||
var s1: number = specifierNumber2Renamed;
|
||||
var s2: string = specifierNumber2Renamed;
|
||||
import { specifierNumber3 as specifierNumber3Renamed } from \"ES6_Named1\";
|
||||
import { specifierNumber3 as specifierNumber3Renamed } from "ES6_Named1";
|
||||
var t1: number = specifierNumber3Renamed;
|
||||
var t2: string = specifierNumber3Renamed;
|
||||
import { groupedSpecifierNumber1, groupedSpecifierNumber2 } from \"ES6_Named1\";
|
||||
import { groupedSpecifierNumber1, groupedSpecifierNumber2 } from "ES6_Named1";
|
||||
var u1: number = groupedSpecifierNumber1;
|
||||
var u2: number = groupedSpecifierNumber2;
|
||||
var u3: string = groupedSpecifierNumber1;
|
||||
var u4: string = groupedSpecifierNumber2;
|
||||
import { givesANumber } from \"ES6_Named1\";
|
||||
import { givesANumber } from "ES6_Named1";
|
||||
var v1: number = givesANumber();
|
||||
var v2: string = givesANumber();
|
||||
import { NumberGenerator } from \"ES6_Named1\";
|
||||
import { NumberGenerator } from "ES6_Named1";
|
||||
var w1: number = new NumberGenerator().givesANumber();
|
||||
var w2: string = new NumberGenerator().givesANumber();
|
||||
import { varDeclNumber1, varDeclNumber2 } from \"ES6_Named1\";
|
||||
import { varDeclNumber1, varDeclNumber2 } from "ES6_Named1";
|
||||
var x1: number = varDeclNumber1;
|
||||
var x2: number = varDeclNumber2;
|
||||
var x3: string = varDeclNumber1;
|
||||
var x4: string = varDeclNumber2;
|
||||
import { destructuredObjNumber } from \"ES6_Named1\";
|
||||
import { destructuredObjNumber } from "ES6_Named1";
|
||||
var y1: number = destructuredObjNumber;
|
||||
var y2: string = destructuredObjNumber;
|
||||
import { destructuredArrNumber } from \"ES6_Named1\";
|
||||
import { destructuredArrNumber } from "ES6_Named1";
|
||||
var z1: number = destructuredArrNumber;
|
||||
var z2: string = destructuredArrNumber;
|
||||
import { numberValue1 as numberValue4 } from \"ES6_ExportFrom_Intermediary1\";
|
||||
import { numberValue1 as numberValue4 } from "ES6_ExportFrom_Intermediary1";
|
||||
var aa1: number = numberValue4;
|
||||
var aa2: string = numberValue4;
|
||||
import { numberValue2_renamed } from \"ES6_ExportFrom_Intermediary1\";
|
||||
import { numberValue2_renamed } from "ES6_ExportFrom_Intermediary1";
|
||||
var ab1: number = numberValue2_renamed;
|
||||
var ab2: string = numberValue2_renamed;
|
||||
import { numberValue1 as numberValue5 } from \"ES6_ExportAllFrom_Intermediary1\";
|
||||
import { numberValue1 as numberValue5 } from "ES6_ExportAllFrom_Intermediary1";
|
||||
var ac1: number = numberValue5;
|
||||
var ac2: string = numberValue5;
|
||||
require(\"ES6_Default_AnonFunction2\").doesntExist;
|
||||
var ES6_Def_AnonFunc2 = require(\"ES6_Default_AnonFunction2\").default;
|
||||
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();
|
||||
var ES6_Def_NamedFunc2 = require(\"ES6_Default_NamedFunction2\").default;
|
||||
var ES6_Def_NamedFunc2 = require("ES6_Default_NamedFunction2").default;
|
||||
var ae1: number = ES6_Def_NamedFunc2();
|
||||
var ae2: string = ES6_Def_NamedFunc2();
|
||||
var ES6_Def_AnonClass2 = require(\"ES6_Default_AnonClass2\").default;
|
||||
var ES6_Def_AnonClass2 = require("ES6_Default_AnonClass2").default;
|
||||
var af1: number = new ES6_Def_AnonClass2().givesANum();
|
||||
var af2: string = new ES6_Def_AnonClass2().givesANum();
|
||||
var ES6_Def_NamedClass2 = require(\"ES6_Default_NamedClass2\").default;
|
||||
var ES6_Def_NamedClass2 = require("ES6_Default_NamedClass2").default;
|
||||
var ag1: number = new ES6_Def_NamedClass2().givesANum();
|
||||
var ag2: string = new ES6_Def_NamedClass2().givesANum();
|
||||
var specifierNumber4 = require(\"ES6_Named2\").specifierNumber4;
|
||||
var specifierNumber4 = require("ES6_Named2").specifierNumber4;
|
||||
var ah1: number = specifierNumber4;
|
||||
var ah2: string = specifierNumber4;
|
||||
var specifierNumber5Renamed = require(\"ES6_Named2\").specifierNumber5Renamed;
|
||||
var specifierNumber5Renamed = require("ES6_Named2").specifierNumber5Renamed;
|
||||
var ai1: number = specifierNumber5Renamed;
|
||||
var ai2: string = specifierNumber5Renamed;
|
||||
var groupedSpecifierNumber3 = require(\"ES6_Named2\").groupedSpecifierNumber3;
|
||||
var groupedSpecifierNumber4 = require(\"ES6_Named2\").groupedSpecifierNumber4;
|
||||
var groupedSpecifierNumber3 = require("ES6_Named2").groupedSpecifierNumber3;
|
||||
var groupedSpecifierNumber4 = require("ES6_Named2").groupedSpecifierNumber4;
|
||||
var aj1: number = groupedSpecifierNumber3;
|
||||
var aj2: number = groupedSpecifierNumber4;
|
||||
var aj3: string = groupedSpecifierNumber3;
|
||||
var aj4: string = groupedSpecifierNumber4;
|
||||
var givesANumber2 = require(\"ES6_Named2\").givesANumber2;
|
||||
var givesANumber2 = require("ES6_Named2").givesANumber2;
|
||||
var ak1: number = givesANumber2();
|
||||
var ak2: string = givesANumber2();
|
||||
var NumberGenerator2 = require(\"ES6_Named2\").NumberGenerator2;
|
||||
var NumberGenerator2 = require("ES6_Named2").NumberGenerator2;
|
||||
var al1: number = new NumberGenerator2().givesANumber();
|
||||
var al2: string = new NumberGenerator2().givesANumber();
|
||||
var varDeclNumber3 = require(\"ES6_Named2\").varDeclNumber3;
|
||||
var varDeclNumber4 = require(\"ES6_Named2\").varDeclNumber4;
|
||||
var varDeclNumber3 = require("ES6_Named2").varDeclNumber3;
|
||||
var varDeclNumber4 = require("ES6_Named2").varDeclNumber4;
|
||||
var am1: number = varDeclNumber3;
|
||||
var am2: number = varDeclNumber4;
|
||||
var am3: string = varDeclNumber3;
|
||||
var am4: string = varDeclNumber4;
|
||||
var destructuredObjNumber2 = require(\"ES6_Named2\").destructuredObjNumber2;
|
||||
var destructuredObjNumber2 = require("ES6_Named2").destructuredObjNumber2;
|
||||
var an1: number = destructuredObjNumber2;
|
||||
var an2: string = destructuredObjNumber2;
|
||||
var destructuredArrNumber2 = require(\"ES6_Named2\").destructuredArrNumber2;
|
||||
var destructuredArrNumber2 = require("ES6_Named2").destructuredArrNumber2;
|
||||
var ao1: number = destructuredArrNumber2;
|
||||
var ao2: string = destructuredArrNumber2;
|
||||
var numberValue6 = require(\"ES6_ExportFrom_Intermediary2\").numberValue1;
|
||||
var numberValue6 = require("ES6_ExportFrom_Intermediary2").numberValue1;
|
||||
var ap1: number = numberValue6;
|
||||
var ap2: string = numberValue6;
|
||||
var numberValue2_renamed2 = require(
|
||||
\"ES6_ExportFrom_Intermediary2\"
|
||||
"ES6_ExportFrom_Intermediary2"
|
||||
).numberValue2_renamed2;
|
||||
var aq1: number = numberValue2_renamed2;
|
||||
var aq2: string = numberValue2_renamed2;
|
||||
var numberValue7 = require(\"ES6_ExportAllFrom_Intermediary2\").numberValue2;
|
||||
var numberValue7 = require("ES6_ExportAllFrom_Intermediary2").numberValue2;
|
||||
var ar1: number = numberValue7;
|
||||
var ar2: string = numberValue7;
|
||||
import defaultNum, { str as namedStr } from \"./ES6_DefaultAndNamed\";
|
||||
import defaultNum, { str as namedStr } from "./ES6_DefaultAndNamed";
|
||||
var as1: number = defaultNum;
|
||||
var as2: string = defaultNum;
|
||||
var as3: string = namedStr;
|
||||
var as4: number = namedStr;
|
||||
import \"./SideEffects\";
|
||||
import specifierNumber1 from \"ES6_Named1\";
|
||||
import { specifierNumber } from \"ES6_Named1\";
|
||||
import { numberValue1 as numberValue8, numberValue2 as numberValue9 } from \"./ES6_ExportAllFromMulti\";
|
||||
import "./SideEffects";
|
||||
import specifierNumber1 from "ES6_Named1";
|
||||
import { specifierNumber } from "ES6_Named1";
|
||||
import { numberValue1 as numberValue8, numberValue2 as numberValue9 } from "./ES6_ExportAllFromMulti";
|
||||
var at1: number = numberValue8;
|
||||
var at2: string = numberValue8;
|
||||
var at3: number = numberValue9;
|
||||
var at4: string = numberValue9;
|
||||
import { typeAlias } from \"./ExportType\";
|
||||
import { typeAlias } from "./ExportType";
|
||||
"
|
||||
`;
|
||||
|
||||
@@ -1259,27 +1259,27 @@ exports[`test test_imports_are_frozen.js 1`] = `
|
||||
//
|
||||
|
||||
// CommonJS module
|
||||
import * as DefaultA from \"A\";
|
||||
import * as DefaultA from "A";
|
||||
DefaultA.numberValue1 = 123; // Error: DefaultA is frozen
|
||||
|
||||
// ES6 module
|
||||
import * as ES6_Named1 from \"ES6_Named1\";
|
||||
import * as ES6_Named1 from "ES6_Named1";
|
||||
ES6_Named1.varDeclNumber1 = 123; // Error: ES6_Named1 is frozen
|
||||
|
||||
// CommonJS module that clobbers module.exports
|
||||
import * as CommonJS_Star from \"CommonJS_Clobbering_Lit\";
|
||||
import * as CommonJS_Star from "CommonJS_Clobbering_Lit";
|
||||
CommonJS_Star.numberValue1 = 123; // Error: frozen
|
||||
CommonJS_Star.default.numberValue1 = 123; // ok
|
||||
|
||||
import CommonJS_Clobbering_Lit from \"CommonJS_Clobbering_Lit\";
|
||||
import CommonJS_Clobbering_Lit from "CommonJS_Clobbering_Lit";
|
||||
CommonJS_Clobbering_Lit.numberValue1 = 123; // ok
|
||||
|
||||
// CommonJS module that clobbers module.exports with a frozen object
|
||||
import * as CommonJS_Frozen_Star from \"CommonJS_Clobbering_Frozen\";
|
||||
import * as CommonJS_Frozen_Star from "CommonJS_Clobbering_Frozen";
|
||||
CommonJS_Frozen_Star.numberValue1 = 123; // Error: frozen
|
||||
CommonJS_Frozen_Star.default.numberValue1 = 123; // Error: frozen
|
||||
|
||||
import CommonJS_Clobbering_Frozen from \"CommonJS_Clobbering_Frozen\";
|
||||
import CommonJS_Clobbering_Frozen from "CommonJS_Clobbering_Frozen";
|
||||
CommonJS_Clobbering_Frozen.numberValue1 = 123; // Error: exports are frozen
|
||||
|
||||
|
||||
@@ -1289,19 +1289,19 @@ CommonJS_Clobbering_Frozen.numberValue1 = 123; // Error: exports are frozen
|
||||
|
||||
function testRequires() {
|
||||
// CommonJS module
|
||||
var DefaultA = require(\"A\");
|
||||
var DefaultA = require("A");
|
||||
DefaultA.numberValue1 = 123; // ok, not frozen by default
|
||||
|
||||
// ES6 module
|
||||
var ES6_Named1 = require(\"ES6_Named1\");
|
||||
var ES6_Named1 = require("ES6_Named1");
|
||||
ES6_Named1.numberValue = 123; // error, es6 exports are frozen
|
||||
|
||||
// CommonJS module that clobbers module.exports
|
||||
var CommonJS_Star = require(\"CommonJS_Clobbering_Lit\");
|
||||
var CommonJS_Star = require("CommonJS_Clobbering_Lit");
|
||||
CommonJS_Star.numberValue1 = 123; // ok, not frozen by default
|
||||
|
||||
// CommonJS module that clobbers module.exports with a frozen object
|
||||
var CommonJS_Frozen_Star = require(\"CommonJS_Clobbering_Frozen\");
|
||||
var CommonJS_Frozen_Star = require("CommonJS_Clobbering_Frozen");
|
||||
CommonJS_Frozen_Star.numberValue1 = 123; // Error: frozen
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@@ -1332,28 +1332,28 @@ function testRequires() {
|
||||
// ok, not frozen by default
|
||||
// CommonJS module that clobbers module.exports with a frozen object
|
||||
// Error: frozen
|
||||
import * as DefaultA from \"A\";
|
||||
import * as DefaultA from "A";
|
||||
DefaultA.numberValue1 = 123;
|
||||
import * as ES6_Named1 from \"ES6_Named1\";
|
||||
import * as ES6_Named1 from "ES6_Named1";
|
||||
ES6_Named1.varDeclNumber1 = 123;
|
||||
import * as CommonJS_Star from \"CommonJS_Clobbering_Lit\";
|
||||
import * as CommonJS_Star from "CommonJS_Clobbering_Lit";
|
||||
CommonJS_Star.numberValue1 = 123;
|
||||
CommonJS_Star.default.numberValue1 = 123;
|
||||
import CommonJS_Clobbering_Lit from \"CommonJS_Clobbering_Lit\";
|
||||
import CommonJS_Clobbering_Lit from "CommonJS_Clobbering_Lit";
|
||||
CommonJS_Clobbering_Lit.numberValue1 = 123;
|
||||
import * as CommonJS_Frozen_Star from \"CommonJS_Clobbering_Frozen\";
|
||||
import * as CommonJS_Frozen_Star from "CommonJS_Clobbering_Frozen";
|
||||
CommonJS_Frozen_Star.numberValue1 = 123;
|
||||
CommonJS_Frozen_Star.default.numberValue1 = 123;
|
||||
import CommonJS_Clobbering_Frozen from \"CommonJS_Clobbering_Frozen\";
|
||||
import CommonJS_Clobbering_Frozen from "CommonJS_Clobbering_Frozen";
|
||||
CommonJS_Clobbering_Frozen.numberValue1 = 123;
|
||||
function testRequires() {
|
||||
var DefaultA = require(\"A\");
|
||||
var DefaultA = require("A");
|
||||
DefaultA.numberValue1 = 123;
|
||||
var ES6_Named1 = require(\"ES6_Named1\");
|
||||
var ES6_Named1 = require("ES6_Named1");
|
||||
ES6_Named1.numberValue = 123;
|
||||
var CommonJS_Star = require(\"CommonJS_Clobbering_Lit\");
|
||||
var CommonJS_Star = require("CommonJS_Clobbering_Lit");
|
||||
CommonJS_Star.numberValue1 = 123;
|
||||
var CommonJS_Frozen_Star = require(\"CommonJS_Clobbering_Frozen\");
|
||||
var CommonJS_Frozen_Star = require("CommonJS_Clobbering_Frozen");
|
||||
CommonJS_Frozen_Star.numberValue1 = 123;
|
||||
}
|
||||
"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
exports[`test es_declare_module.js 1`] = `
|
||||
"// @flow
|
||||
|
||||
import {num1, str1} from \"CJS_Named\";
|
||||
import CJS_Named from \"CJS_Named\";
|
||||
import {num1, str1} from "CJS_Named";
|
||||
import CJS_Named from "CJS_Named";
|
||||
(num1: number);
|
||||
(num1: string); // Error: number ~> string
|
||||
(str1: string);
|
||||
@@ -10,36 +10,36 @@ import CJS_Named from \"CJS_Named\";
|
||||
(CJS_Named: {num1: number, str1: string});
|
||||
(CJS_Named: number); // Error: Module ~> number
|
||||
|
||||
import {num2} from \"CJS_Clobbered\"; // Error: No such export!
|
||||
import {numExport} from \"CJS_Clobbered\";
|
||||
import {num2} from "CJS_Clobbered"; // Error: No such export!
|
||||
import {numExport} from "CJS_Clobbered";
|
||||
(numExport: number);
|
||||
(numExport: string); // Error: number ~> string
|
||||
import type {numType} from \"CJS_Clobbered\";
|
||||
import type {numType} from "CJS_Clobbered";
|
||||
(42: numType);
|
||||
(\'asdf\': numType); // Error: string ~> number
|
||||
('asdf': numType); // Error: string ~> number
|
||||
|
||||
import {strHidden} from \"ES\"; // Error: No such export!
|
||||
import {str3} from \"ES\";
|
||||
import {strHidden} from "ES"; // Error: No such export!
|
||||
import {str3} from "ES";
|
||||
(str3: string);
|
||||
(str3: number); // Error: string ~> number
|
||||
|
||||
import {num3} from \"ES\";
|
||||
import {num3} from "ES";
|
||||
(num3: number);
|
||||
(num3: string); // Error: number ~> string
|
||||
|
||||
import {C} from \"ES\";
|
||||
import type {C as CType} from \"ES\";
|
||||
import {C} from "ES";
|
||||
import type {C as CType} from "ES";
|
||||
(new C(): C);
|
||||
(42: C); // Error: number ~> C
|
||||
(new C(): CType);
|
||||
(42: CType); // Error: number ~> CType
|
||||
|
||||
import {T} from \"ES\"; // Error: T is a type import, not a value
|
||||
import type {T as T2} from \"ES\";
|
||||
import {T} from "ES"; // Error: T is a type import, not a value
|
||||
import type {T as T2} from "ES";
|
||||
(42: T2);
|
||||
(\'asdf\': T2); // Error: string ~> number
|
||||
('asdf': T2); // Error: string ~> number
|
||||
|
||||
import {exports as nope} from \"ES\"; // Error: Not an export
|
||||
import {exports as nope} from "ES"; // Error: Not an export
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// @flow
|
||||
// Error: number ~> string
|
||||
@@ -56,38 +56,38 @@ import {exports as nope} from \"ES\"; // Error: Not an export
|
||||
// Error: T is a type import, not a value
|
||||
// Error: string ~> number
|
||||
// Error: Not an export
|
||||
import { num1, str1 } from \"CJS_Named\";
|
||||
import CJS_Named from \"CJS_Named\";
|
||||
import { num1, str1 } from "CJS_Named";
|
||||
import CJS_Named from "CJS_Named";
|
||||
(num1: number);
|
||||
(num1: string);
|
||||
(str1: string);
|
||||
(str1: number);
|
||||
(CJS_Named: { num1: number, str1: string });
|
||||
(CJS_Named: { num1: number; str1: string });
|
||||
(CJS_Named: number);
|
||||
import { num2 } from \"CJS_Clobbered\";
|
||||
import { numExport } from \"CJS_Clobbered\";
|
||||
import { num2 } from "CJS_Clobbered";
|
||||
import { numExport } from "CJS_Clobbered";
|
||||
(numExport: number);
|
||||
(numExport: string);
|
||||
import type { numType } from \"CJS_Clobbered\";
|
||||
import type { numType } from "CJS_Clobbered";
|
||||
(42: numType);
|
||||
(\"asdf\": numType);
|
||||
import { strHidden } from \"ES\";
|
||||
import { str3 } from \"ES\";
|
||||
("asdf": numType);
|
||||
import { strHidden } from "ES";
|
||||
import { str3 } from "ES";
|
||||
(str3: string);
|
||||
(str3: number);
|
||||
import { num3 } from \"ES\";
|
||||
import { num3 } from "ES";
|
||||
(num3: number);
|
||||
(num3: string);
|
||||
import { C } from \"ES\";
|
||||
import type { C as CType } from \"ES\";
|
||||
import { C } from "ES";
|
||||
import type { C as CType } from "ES";
|
||||
(new C(): C);
|
||||
(42: C);
|
||||
(new C(): CType);
|
||||
(42: CType);
|
||||
import { T } from \"ES\";
|
||||
import type { T as T2 } from \"ES\";
|
||||
import { T } from "ES";
|
||||
import type { T as T2 } from "ES";
|
||||
(42: T2);
|
||||
(\"asdf\": T2);
|
||||
import { exports as nope } from \"ES\";
|
||||
("asdf": T2);
|
||||
import { exports as nope } from "ES";
|
||||
"
|
||||
`;
|
||||
@@ -1,10 +1,10 @@
|
||||
exports[`test declares.js 1`] = `
|
||||
"declare module "CJS_Named" {
|
||||
"declare module \"CJS_Named\" {
|
||||
declare var num1: number;
|
||||
declare var str1: string;
|
||||
}
|
||||
|
||||
declare module "CJS_Clobbered" {
|
||||
declare module \"CJS_Clobbered\" {
|
||||
declare var num2: number;
|
||||
declare type numType = number;
|
||||
declare var exports: {
|
||||
@@ -12,7 +12,7 @@ declare module "CJS_Clobbered" {
|
||||
};
|
||||
}
|
||||
|
||||
declare module "ES" {
|
||||
declare module \"ES\" {
|
||||
declare var strHidden: string;
|
||||
declare export {strHidden as str3};
|
||||
declare export var num3: number;
|
||||
@@ -21,16 +21,16 @@ declare module "ES" {
|
||||
declare var exports: number;
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
declare module "CJS_Named" {
|
||||
declare module \"CJS_Named\" {
|
||||
declare var num1: number;
|
||||
declare var str1: string;
|
||||
}
|
||||
declare module "CJS_Clobbered" {
|
||||
declare module \"CJS_Clobbered\" {
|
||||
declare var num2: number;
|
||||
type numType = number;
|
||||
declare type numType = number;
|
||||
declare var exports: { numExport: number };
|
||||
}
|
||||
declare module "ES" {
|
||||
declare module \"ES\" {
|
||||
declare var strHidden: string;
|
||||
declare export { strHidden as str3 }
|
||||
declare export var num3: number;
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
exports[`test test.js 1`] = `
|
||||
"/* @flow */
|
||||
|
||||
class Foo {
|
||||
annotationOnly: string;
|
||||
initOnly = 'asdf'
|
||||
initWithAnnotation: string = 'asdf';
|
||||
[computed]: string;
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
class Foo {
|
||||
annotationOnly: string;
|
||||
initOnly;
|
||||
=(initWithAnnotation: string = "asdf", [ computed ], }) {
|
||||
|
||||
}
|
||||
}
|
||||
"
|
||||
`;
|
||||
@@ -1 +0,0 @@
|
||||
run_spec(__dirname);
|
||||
@@ -1,8 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
class Foo {
|
||||
annotationOnly: string;
|
||||
initOnly = 'asdf'
|
||||
initWithAnnotation: string = 'asdf';
|
||||
[computed]: string;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
exports[`test test.js 1`] = `
|
||||
"/* @flow */
|
||||
|
||||
class Foo {
|
||||
annotationOnly: string;
|
||||
initOnly = 'asdf';
|
||||
initWithAnnotation: string = 'asdf';
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/* @flow */
|
||||
class Foo {
|
||||
annotationOnly: string;
|
||||
initOnly;
|
||||
=(;, :, =, ;) {
|
||||
|
||||
}
|
||||
}
|
||||
"
|
||||
`;
|
||||
@@ -1 +0,0 @@
|
||||
run_spec(__dirname);
|
||||
@@ -1,7 +0,0 @@
|
||||
/* @flow */
|
||||
|
||||
class Foo {
|
||||
annotationOnly: string;
|
||||
initOnly = 'asdf';
|
||||
initWithAnnotation: string = 'asdf';
|
||||
}
|
||||
Loaded 100 of 286 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user