Sync the Flow tests (#1638)

master
Simon Lydell 2017-05-20 12:16:28 +02:00 committed by Christopher Chedeau
parent fc60d548aa
commit 8ad3aeff6a
56 changed files with 405 additions and 167 deletions

View File

@ -39,7 +39,7 @@ a.append('foo', 'bar'); // correct
a.append('foo', {}); // incorrect
a.append(2, 'bar'); // incorrect
a.append('foo', 'bar', 'baz'); // incorrect
a.append('foo', 'bar'); // incorrect
a.append('foo', 'bar'); // correct
a.append('bar', new File([], 'q')) // correct
a.append('bar', new File([], 'q'), 'x') // correct
a.append('bar', new File([], 'q'), 2) // incorrect

View File

@ -42,7 +42,7 @@ a.append('foo', 'bar'); // correct
a.append('foo', {}); // incorrect
a.append(2, 'bar'); // incorrect
a.append('foo', 'bar', 'baz'); // incorrect
a.append('foo', 'bar'); // incorrect
a.append('foo', 'bar'); // correct
a.append('bar', new File([], 'q')) // correct
a.append('bar', new File([], 'q'), 'x') // correct
a.append('bar', new File([], 'q'), 2) // incorrect
@ -110,7 +110,7 @@ a.append("foo", "bar"); // correct
a.append("foo", {}); // incorrect
a.append(2, "bar"); // incorrect
a.append("foo", "bar", "baz"); // incorrect
a.append("foo", "bar"); // incorrect
a.append("foo", "bar"); // correct
a.append("bar", new File([], "q")); // correct
a.append("bar", new File([], "q"), "x"); // correct
a.append("bar", new File([], "q"), 2); // incorrect

View File

@ -20,6 +20,7 @@ interface IFoo extends IFooPrototype {
x: boolean; // error, should have declared x: number instead
static (): void;
static y: boolean; // error, should have declared static y: number instead
constructor(): void;
}
exports.Foo2 = (Foo: Class<IFoo>);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -45,7 +46,8 @@ interface IFooPrototype {
interface IFoo extends IFooPrototype {
x: boolean, // error, should have declared x: number instead
static (): void,
static y: boolean // error, should have declared static y: number instead
static y: boolean, // error, should have declared static y: number instead
constructor(): void
}
exports.Foo2 = (Foo: Class<IFoo>);

View File

@ -17,5 +17,6 @@ interface IFoo extends IFooPrototype {
x: boolean; // error, should have declared x: number instead
static (): void;
static y: boolean; // error, should have declared static y: number instead
constructor(): void;
}
exports.Foo2 = (Foo: Class<IFoo>);

View File

@ -25,10 +25,8 @@ 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);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var d = new Date(0);
var x: string = d.getTime();
@ -54,9 +52,7 @@ 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);
`;

View File

@ -22,7 +22,5 @@ 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);

View File

@ -4,6 +4,8 @@ exports[`declare_class.js 1`] = `
declare class C {
static x: number;
static foo(x: number): void;
constructor(x: string): void;
}
C.x = "";
@ -11,10 +13,15 @@ C.foo("");
(C.name: string);
(C.name: number); // error, it's a string
declare class D extends C { }
new D(123); // error, number ~> string
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
declare class C {
static x: number,
static foo(x: number): void
static foo(x: number): void,
constructor(x: string): void
}
C.x = "";
@ -23,4 +30,7 @@ C.foo("");
(C.name: string);
(C.name: number); // error, it's a string
declare class D extends C {}
new D(123); // error, number ~> string
`;

View File

@ -1,6 +1,8 @@
declare class C {
static x: number;
static foo(x: number): void;
constructor(x: string): void;
}
C.x = "";
@ -8,3 +10,6 @@ C.foo("");
(C.name: string);
(C.name: number); // error, it's a string
declare class D extends C { }
new D(123); // error, number ~> string

View File

@ -8,5 +8,6 @@ let tests = [
(document.createElement('option'): HTMLOptionElement);
(document.createElement('select'): HTMLSelectElement);
(document.querySelector('select'): HTMLSelectElement | null);
(document.createElement('hr'): HTMLElement); // GH #3752
}
];

View File

@ -65,6 +65,7 @@ let tests = [
(document.createElement('option'): HTMLOptionElement);
(document.createElement('select'): HTMLSelectElement);
(document.querySelector('select'): HTMLSelectElement | null);
(document.createElement('hr'): HTMLElement); // GH #3752
}
];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -78,6 +79,7 @@ let tests = [
(document.createElement("option"): HTMLOptionElement);
(document.createElement("select"): HTMLSelectElement);
(document.querySelector("select"): HTMLSelectElement | null);
(document.createElement("hr"): HTMLElement); // GH #3752
}
];

View File

@ -81,7 +81,11 @@ for (let v of e.entries()) {
const [i, j]: [string, string] = v; // correct
}
e.getAll('content-type').forEach((v: string) => {}); // correct
e.getAll('content-type'); // incorrect
e.forEach((val: string) => val); // correct
e.forEach((val: string, key: string) => \`\${key}: \${val}\`); // correct
e.forEach((val: string, key: string, o: Headers) => {}); // correct
e.forEach(() => {}, {}); // correct
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
@ -110,7 +114,11 @@ for (let v of e.entries()) {
const [i, j]: [string, string] = v; // correct
}
e.getAll("content-type").forEach((v: string) => {}); // correct
e.getAll("content-type"); // incorrect
e.forEach((val: string) => val); // correct
e.forEach((val: string, key: string) => \`\${key}: \${val}\`); // correct
e.forEach((val: string, key: string, o: Headers) => {}); // correct
e.forEach(() => {}, {}); // correct
`;
@ -124,6 +132,7 @@ const e: Request = new Request(b, c); // incorrect
const f: Request = new Request({}) // incorrect
const g: Request = new Request('http://example.org', {}) // correct
new Request(new URL('http://example.org')); // correct
const h: Request = new Request('http://example.org', {
method: 'GET',
@ -174,14 +183,9 @@ const l: Request = new Request('http://example.org', {
cache: 'default'
}) // incorrect - headers is string
const m: Request = new Request('http://example.org', {
method: 'CONNECT',
headers: {
'Content-Type': 'image/jpeg'
},
mode: 'cors',
cache: 'default'
}) // incorrect - CONNECT is forbidden
new Request('/', { method: 'post' }); // correct
new Request('/', { method: 'hello' }); // correct
new Request('/', { method: null }); // incorrect
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
const a: Request = new Request(); // incorrect
@ -192,6 +196,7 @@ const e: Request = new Request(b, c); // incorrect
const f: Request = new Request({}); // incorrect
const g: Request = new Request("http://example.org", {}); // correct
new Request(new URL("http://example.org")); // correct
const h: Request = new Request("http://example.org", {
method: "GET",
@ -242,14 +247,9 @@ const l: Request = new Request("http://example.org", {
cache: "default"
}); // incorrect - headers is string
const m: Request = new Request("http://example.org", {
method: "CONNECT",
headers: {
"Content-Type": "image/jpeg"
},
mode: "cors",
cache: "default"
}); // incorrect - CONNECT is forbidden
new Request("/", { method: "post" }); // correct
new Request("/", { method: "hello" }); // correct
new Request("/", { method: null }); // incorrect
`;
@ -259,13 +259,10 @@ const a: Response = new Response(); // correct
const b: Response = new Response(new Blob()); // correct
const c: Response = new Response(new FormData()); // correct
const d: Response = new Response(new FormData(), {
status: 404
}); // correct
const e: Response = new Response("responsebody", {
status: "404"
}); // incorrect
new Response("", { status: 404 }); // correct
new Response(null, { status: 204 }); // correct
new Response("", { status: "404" }); // incorrect
new Response("", { status: null }); // incorrect
const f: Response = new Response("responsebody", {
status: 404,
@ -294,6 +291,7 @@ const i: Response = new Response({
}); // incorrect
const ok: boolean = h.ok;
const redirected: boolean = h.redirected;
const status: number = h.status;
h.text().then((t: string) => t); // correct
@ -306,13 +304,10 @@ const a: Response = new Response(); // correct
const b: Response = new Response(new Blob()); // correct
const c: Response = new Response(new FormData()); // correct
const d: Response = new Response(new FormData(), {
status: 404
}); // correct
const e: Response = new Response("responsebody", {
status: "404"
}); // incorrect
new Response("", { status: 404 }); // correct
new Response(null, { status: 204 }); // correct
new Response("", { status: "404" }); // incorrect
new Response("", { status: null }); // incorrect
const f: Response = new Response("responsebody", {
status: 404,
@ -341,6 +336,7 @@ const i: Response = new Response({
}); // incorrect
const ok: boolean = h.ok;
const redirected: boolean = h.redirected;
const status: number = h.status;
h.text().then((t: string) => t); // correct
@ -379,6 +375,11 @@ for (let v of e.entries()) {
}
e.getAll('key1').forEach((v: string) => {}); // correct
e.forEach((val: string) => val); // correct
e.forEach((val: string, key: string) => \`\${key}: \${val}\`); // correct
e.forEach((val: string, key: string, o: URLSearchParams) => {}); // correct
e.forEach(() => {}, {}); // correct
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
@ -409,4 +410,9 @@ for (let v of e.entries()) {
e.getAll("key1").forEach((v: string) => {}); // correct
e.forEach((val: string) => val); // correct
e.forEach((val: string, key: string) => \`\${key}: \${val}\`); // correct
e.forEach((val: string, key: string, o: URLSearchParams) => {}); // correct
e.forEach(() => {}, {}); // correct
`;

View File

@ -25,4 +25,8 @@ for (let v of e.entries()) {
const [i, j]: [string, string] = v; // correct
}
e.getAll('content-type').forEach((v: string) => {}); // correct
e.getAll('content-type'); // incorrect
e.forEach((val: string) => val); // correct
e.forEach((val: string, key: string) => `${key}: ${val}`); // correct
e.forEach((val: string, key: string, o: Headers) => {}); // correct
e.forEach(() => {}, {}); // correct

View File

@ -7,6 +7,7 @@ const e: Request = new Request(b, c); // incorrect
const f: Request = new Request({}) // incorrect
const g: Request = new Request('http://example.org', {}) // correct
new Request(new URL('http://example.org')); // correct
const h: Request = new Request('http://example.org', {
method: 'GET',
@ -57,11 +58,6 @@ const l: Request = new Request('http://example.org', {
cache: 'default'
}) // incorrect - headers is string
const m: Request = new Request('http://example.org', {
method: 'CONNECT',
headers: {
'Content-Type': 'image/jpeg'
},
mode: 'cors',
cache: 'default'
}) // incorrect - CONNECT is forbidden
new Request('/', { method: 'post' }); // correct
new Request('/', { method: 'hello' }); // correct
new Request('/', { method: null }); // incorrect

View File

@ -3,13 +3,10 @@ const a: Response = new Response(); // correct
const b: Response = new Response(new Blob()); // correct
const c: Response = new Response(new FormData()); // correct
const d: Response = new Response(new FormData(), {
status: 404
}); // correct
const e: Response = new Response("responsebody", {
status: "404"
}); // incorrect
new Response("", { status: 404 }); // correct
new Response(null, { status: 204 }); // correct
new Response("", { status: "404" }); // incorrect
new Response("", { status: null }); // incorrect
const f: Response = new Response("responsebody", {
status: 404,
@ -38,6 +35,7 @@ const i: Response = new Response({
}); // incorrect
const ok: boolean = h.ok;
const redirected: boolean = h.redirected;
const status: number = h.status;
h.text().then((t: string) => t); // correct

View File

@ -26,3 +26,8 @@ for (let v of e.entries()) {
}
e.getAll('key1').forEach((v: string) => {}); // correct
e.forEach((val: string) => val); // correct
e.forEach((val: string, key: string) => `${key}: ${val}`); // correct
e.forEach((val: string, key: string, o: URLSearchParams) => {}); // correct
e.forEach(() => {}, {}); // correct

View File

@ -457,6 +457,9 @@ function return_rest_param<Args:Array<mixed>>(
return args; // Error: Array ~> number
}
}
function requires_first_param(x: number, ...rest: Array<number>): void {}
requires_first_param(); // Error: missing first arg
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* regression tests */
@ -529,6 +532,9 @@ function return_rest_param<Args: Array<mixed>>(
};
}
function requires_first_param(x: number, ...rest: Array<number>): void {}
requires_first_param(); // Error: missing first arg
`;
exports[`rest_type.js 1`] = `

View File

@ -59,3 +59,6 @@ function return_rest_param<Args:Array<mixed>>(
return args; // Error: Array ~> number
}
}
function requires_first_param(x: number, ...rest: Array<number>): void {}
requires_first_param(); // Error: missing first arg

View File

@ -37,6 +37,7 @@ let foo = require('./Parent').ParentFoo.foo;
foo;
import type {Foo} from './types';
function takesFoo(foo: Foo) { }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow
@ -61,6 +62,7 @@ let foo = require("./Parent").ParentFoo.foo;
foo;
import type { Foo } from "./types";
function takesFoo(foo: Foo) {}
`;

View File

@ -21,3 +21,4 @@ let foo = require('./Parent').ParentFoo.foo;
foo;
import type {Foo} from './types';
function takesFoo(foo: Foo) { }

View File

@ -0,0 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
// @flow
(123: string); // Normal error
// $FlowFixMe
(123: string); // Suppressed error
// $FlowFixMe - unused suppression comment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow
(123: string); // Normal error
// $FlowFixMe
(123: string); // Suppressed error
// $FlowFixMe - unused suppression comment
`;

View File

@ -0,0 +1,8 @@
// @flow
(123: string); // Normal error
// $FlowFixMe
(123: string); // Suppressed error
// $FlowFixMe - unused suppression comment

View File

@ -0,0 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`text.js 1`] = `
// @flow
// Example found at
// https://github.com/sebmarkbage/art/blob/51ffce8164a555d652843241c2fdda52e186cbbd/parsers/svg/text.js#L137
const evil_regex_as_a_string = "/[\\s<>]*$/";
const error: string = 123; // Should be an error, but can't lex this file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow
// Example found at
// https://github.com/sebmarkbage/art/blob/51ffce8164a555d652843241c2fdda52e186cbbd/parsers/svg/text.js#L137
const evil_regex_as_a_string = "/[s<>]*$/";
const error: string = 123; // Should be an error, but can't lex this file
`;

View File

@ -0,0 +1 @@
run_spec(__dirname);

View File

@ -0,0 +1,6 @@
// @flow
// Example found at
// https://github.com/sebmarkbage/art/blob/51ffce8164a555d652843241c2fdda52e186cbbd/parsers/svg/text.js#L137
const evil_regex_as_a_string = "/[\s<>]*$/";
const error: string = 123; // Should be an error, but can't lex this file

View File

@ -243,8 +243,8 @@ function fun(x: 'hi', y: 123) {}
fun(...['hi', 123]); // No error
fun(...['hi'], ...[123]); // No error
fun(...['hi'], ...[], ...[123]); // No error
fun(...['hi'], ...[], ...[123], ...[true]); // No error
fun(...['hi'], ...[true], ...[123]); // Error: true ~> 123
fun(...['hi'], ...[], ...[123], ...[true]); // Error - true is unused
fun(...['hi'], ...[true], ...[123]); // Error: true ~> 123 and 123 is unused
declare var arrOf123: Array<123>;
fun('hi', ...arrOf123); // No error - ignore the fact arrOf123 could be empty
@ -272,8 +272,8 @@ function fun(x: "hi", y: 123) {}
fun(...["hi", 123]); // No error
fun(...["hi"], ...[123]); // No error
fun(...["hi"], ...[], ...[123]); // No error
fun(...["hi"], ...[], ...[123], ...[true]); // No error
fun(...["hi"], ...[true], ...[123]); // Error: true ~> 123
fun(...["hi"], ...[], ...[123], ...[true]); // Error - true is unused
fun(...["hi"], ...[true], ...[123]); // Error: true ~> 123 and 123 is unused
declare var arrOf123: Array<123>;
fun("hi", ...arrOf123); // No error - ignore the fact arrOf123 could be empty

View File

@ -4,8 +4,8 @@ function fun(x: 'hi', y: 123) {}
fun(...['hi', 123]); // No error
fun(...['hi'], ...[123]); // No error
fun(...['hi'], ...[], ...[123]); // No error
fun(...['hi'], ...[], ...[123], ...[true]); // No error
fun(...['hi'], ...[true], ...[123]); // Error: true ~> 123
fun(...['hi'], ...[], ...[123], ...[true]); // Error - true is unused
fun(...['hi'], ...[true], ...[123]); // Error: true ~> 123 and 123 is unused
declare var arrOf123: Array<123>;
fun('hi', ...arrOf123); // No error - ignore the fact arrOf123 could be empty

View File

@ -53,11 +53,11 @@ buffer = Buffer.from(typedArray.buffer, typedArray.byteOffset, typedArray.byteLe
buffer = Buffer.from(new Buffer(0));
buffer = Buffer.from("foo", "utf8");
// This call to from() does type check ok, but should not. Unfortunately, Buffer
// This call to from() used to type check ok, but should not. Buffer
// extends Uint8Array but gets rid of this signature to .from(). Understandably,
// flow doesn't support a subclass hiding a superclass member, so this checks out as
// ok, even though it is not correct.
buffer = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72], (a:number) => a + 1, {}); // should error but doesn't
// flow didn't used to support a subclass hiding a superclass member, so this
// used to check out as ok, even though it is not correct.
buffer = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72], (a:number) => a + 1, {}); // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
@ -128,14 +128,14 @@ buffer = Buffer.from(
buffer = Buffer.from(new Buffer(0));
buffer = Buffer.from("foo", "utf8");
// This call to from() does type check ok, but should not. Unfortunately, Buffer
// This call to from() used to type check ok, but should not. Buffer
// extends Uint8Array but gets rid of this signature to .from(). Understandably,
// flow doesn't support a subclass hiding a superclass member, so this checks out as
// ok, even though it is not correct.
// flow didn't used to support a subclass hiding a superclass member, so this
// used to check out as ok, even though it is not correct.
buffer = Buffer.from(
[0x62, 0x75, 0x66, 0x66, 0x65, 0x72],
(a: number) => a + 1,
{}
); // should error but doesn't
); // error
`;

View File

@ -50,8 +50,8 @@ buffer = Buffer.from(typedArray.buffer, typedArray.byteOffset, typedArray.byteLe
buffer = Buffer.from(new Buffer(0));
buffer = Buffer.from("foo", "utf8");
// This call to from() does type check ok, but should not. Unfortunately, Buffer
// This call to from() used to type check ok, but should not. Buffer
// extends Uint8Array but gets rid of this signature to .from(). Understandably,
// flow doesn't support a subclass hiding a superclass member, so this checks out as
// ok, even though it is not correct.
buffer = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72], (a:number) => a + 1, {}); // should error but doesn't
// flow didn't used to support a subclass hiding a superclass member, so this
// used to check out as ok, even though it is not correct.
buffer = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72], (a:number) => a + 1, {}); // error

View File

@ -0,0 +1,57 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`nextTick.js 1`] = `
/* @flow */
process.nextTick(() => {});
process.nextTick(
(a: string, b: number, c: boolean) => {},
'z',
1,
true
);
process.nextTick(
(a: string, b: number, c: boolean) => {},
0, // Error: number ~> string
1,
null // Error: null ~> boolean
);
process.nextTick(
(a: string, b: number, c: boolean) => {},
'z',
'y', // Error: string ~> number
true
);
process.nextTick(
(a: string, b: number, c: boolean) => {} // Error: too few arguments
);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
process.nextTick(() => {});
process.nextTick((a: string, b: number, c: boolean) => {}, "z", 1, true);
process.nextTick(
(a: string, b: number, c: boolean) => {},
0, // Error: number ~> string
1,
null // Error: null ~> boolean
);
process.nextTick(
(a: string, b: number, c: boolean) => {},
"z",
"y", // Error: string ~> number
true
);
process.nextTick(
(a: string, b: number, c: boolean) => {} // Error: too few arguments
);
`;

View File

@ -0,0 +1 @@
run_spec(__dirname);

View File

@ -0,0 +1,28 @@
/* @flow */
process.nextTick(() => {});
process.nextTick(
(a: string, b: number, c: boolean) => {},
'z',
1,
true
);
process.nextTick(
(a: string, b: number, c: boolean) => {},
0, // Error: number ~> string
1,
null // Error: null ~> boolean
);
process.nextTick(
(a: string, b: number, c: boolean) => {},
'z',
'y', // Error: string ~> number
true
);
process.nextTick(
(a: string, b: number, c: boolean) => {} // Error: too few arguments
);

View File

@ -1,42 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`objectTypeProperty.js 1`] = `
/* @flow */
declare var BAZ: {stuff?: (x: number) => void} | void;
declare class Foo<T> {
constructor(): void;
foo: () => void;
}
let x: { x?: number }
type T = {
get goodGetterWithAnnotation(): number,
set goodSetterWithAnnotation(x: number): void,
get getterWithMultipleSpacesPrecedingName(): number,
set setterWithMultipleSpacesPrecedingName(x: number): void,
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
declare var BAZ: { stuff?: (x: number) => void } | void;
declare class Foo<T> {
constructor(): void,
foo: () => void
}
let x: { x?: number };
type T = {
get goodGetterWithAnnotation(): number,
set goodSetterWithAnnotation(x: number): void,
get getterWithMultipleSpacesPrecedingName(): number,
set setterWithMultipleSpacesPrecedingName(x: number): void
};
`;

View File

@ -1,18 +0,0 @@
/* @flow */
declare var BAZ: {stuff?: (x: number) => void} | void;
declare class Foo<T> {
constructor(): void;
foo: () => void;
}
let x: { x?: number }
type T = {
get goodGetterWithAnnotation(): number,
set goodSetterWithAnnotation(x: number): void,
get getterWithMultipleSpacesPrecedingName(): number,
set setterWithMultipleSpacesPrecedingName(x: number): void,
}

View File

@ -22,7 +22,7 @@ Object.is(squared, squared);
var a: boolean = Object.is('a', 'a');
var b: string = Object.is('a', 'a');
var c: boolean = Object.is('a');
var d: boolean = Object.is('a', 'b', 'c');
var d: boolean = Object.is('a', 'b', 'c'); // Error - 'c' is unused
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Object.is(1, 1);
Object.is(1, 2);
@ -45,6 +45,6 @@ Object.is(squared, squared);
var a: boolean = Object.is("a", "a");
var b: string = Object.is("a", "a");
var c: boolean = Object.is("a");
var d: boolean = Object.is("a", "b", "c");
var d: boolean = Object.is("a", "b", "c"); // Error - 'c' is unused
`;

View File

@ -19,4 +19,4 @@ Object.is(squared, squared);
var a: boolean = Object.is('a', 'a');
var b: string = Object.is('a', 'a');
var c: boolean = Object.is('a');
var d: boolean = Object.is('a', 'b', 'c');
var d: boolean = Object.is('a', 'b', 'c'); // Error - 'c' is unused

View File

@ -340,13 +340,11 @@ Promise.reject(0)
var b: number = str; // Error: string ~> number
});
// TODO: resolvedPromise<T> -> catch() -> then():T
// resolvedPromise<T> -> catch() -> then():?T
Promise.resolve(0)
.catch(function(err) {})
.then(function(num) {
var a: number = num;
// TODO
var a: ?number = num;
var b: string = num; // Error: string ~> number
});
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -588,11 +586,9 @@ Promise.reject(0)
var b: number = str; // Error: string ~> number
});
// TODO: resolvedPromise<T> -> catch() -> then():T
// resolvedPromise<T> -> catch() -> then():?T
Promise.resolve(0).catch(function(err) {}).then(function(num) {
var a: number = num;
// TODO
var a: ?number = num;
var b: string = num; // Error: string ~> number
});

View File

@ -217,12 +217,10 @@ Promise.reject(0)
var b: number = str; // Error: string ~> number
});
// TODO: resolvedPromise<T> -> catch() -> then():T
// resolvedPromise<T> -> catch() -> then():?T
Promise.resolve(0)
.catch(function(err) {})
.then(function(num) {
var a: number = num;
// TODO
var a: ?number = num;
var b: string = num; // Error: string ~> number
});

View File

@ -409,3 +409,10 @@ const foo = require("./j1");
foo.p = 0;
`;
exports[`k.js 1`] = `
/* @flow */
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
`;

1
tests/flow/recheck/k.js Normal file
View File

@ -0,0 +1 @@
/* @flow */

View File

@ -0,0 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`k.js 1`] = `
/* @flow */
declare var x: LibK;
(x.p: string);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
declare var x: LibK;
(x.p: string);
`;

View File

@ -0,0 +1 @@
run_spec(__dirname);

View File

@ -0,0 +1,4 @@
/* @flow */
declare var x: LibK;
(x.p: string);

View File

@ -0,0 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`libk1.js 1`] = `
type LibK = {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
type LibK = {};
`;
exports[`libk2.js 1`] = `
type LibK = {
p: string;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
type LibK = {
p: string
};
`;

View File

@ -0,0 +1 @@
run_spec(__dirname);

View File

@ -0,0 +1 @@
type LibK = {}

View File

@ -0,0 +1,3 @@
type LibK = {
p: string;
}

View File

@ -76,12 +76,12 @@ exports[`ProvidesModuleD.js 1`] = `
exports[`not_builtin_require.js 1`] = `
// @flow
function require() {}
function require(x: string) {}
require("not a module name");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow
function require() {}
function require(x: string) {}
require("not a module name");
`;

View File

@ -1,4 +1,4 @@
// @flow
function require() {}
function require(x: string) {}
require("not a module name");

View File

@ -4,13 +4,11 @@ exports[`symbol.js 1`] = `
var FOO = Symbol();
var BAR = Symbol('bar');
// TODO: Expected error
var WAT = Symbol('foo', 'bar');
var WAT = Symbol('foo', 'bar'); // Error - unused argument
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var FOO = Symbol();
var BAR = Symbol("bar");
// TODO: Expected error
var WAT = Symbol("foo", "bar");
var WAT = Symbol("foo", "bar"); // Error - unused argument
`;

View File

@ -1,5 +1,4 @@
var FOO = Symbol();
var BAR = Symbol('bar');
// TODO: Expected error
var WAT = Symbol('foo', 'bar');
var WAT = Symbol('foo', 'bar'); // Error - unused argument

View File

@ -9,7 +9,7 @@ declare class SomeLibClass {}
exports[`test25_lib.js 1`] = `
declare class Set<T> {
add(): Set<T>;
add(x: any): Set<T>;
}
declare class Row {
@ -31,7 +31,7 @@ declare class Rows {
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
declare class Set<T> {
add(): Set<T>
add(x: any): Set<T>
}
declare class Row {

View File

@ -1,5 +1,5 @@
declare class Set<T> {
add(): Set<T>;
add(x: any): Set<T>;
}
declare class Row {

View File

@ -0,0 +1,54 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
function foo() {}
const args = [3, 4];
foo(1, 2); // 2 errors
foo(
1, // error
2, // error
);
foo(...args); // 2 errors
foo.call(null, 1, 2); // 2 errors
foo.call(null, ...args); // 2 errors
foo.call(null, 1, 2, ...args); // 4 errors
foo.apply(null, [1, 2]); // 2 errors
foo.apply(null, args); // 2 errors
foo.bind(null, 1, 2); // 2 errors
foo.bind(null, ...args); // 2 errors
foo.bind(null, 1, 2, ...args); // 4 errors
new foo(1, 2); // 2 errors
new foo(...args); // 2 errors
new foo(1, 2, ...args); // 4 errors
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function foo() {}
const args = [3, 4];
foo(1, 2); // 2 errors
foo(
1, // error
2 // error
);
foo(...args); // 2 errors
foo.call(null, 1, 2); // 2 errors
foo.call(null, ...args); // 2 errors
foo.call(null, 1, 2, ...args); // 4 errors
foo.apply(null, [1, 2]); // 2 errors
foo.apply(null, args); // 2 errors
foo.bind(null, 1, 2); // 2 errors
foo.bind(null, ...args); // 2 errors
foo.bind(null, 1, 2, ...args); // 4 errors
new foo(1, 2); // 2 errors
new foo(...args); // 2 errors
new foo(1, 2, ...args); // 4 errors
`;

View File

@ -0,0 +1 @@
run_spec(__dirname);

View File

@ -0,0 +1,24 @@
function foo() {}
const args = [3, 4];
foo(1, 2); // 2 errors
foo(
1, // error
2, // error
);
foo(...args); // 2 errors
foo.call(null, 1, 2); // 2 errors
foo.call(null, ...args); // 2 errors
foo.call(null, 1, 2, ...args); // 4 errors
foo.apply(null, [1, 2]); // 2 errors
foo.apply(null, args); // 2 errors
foo.bind(null, 1, 2); // 2 errors
foo.bind(null, ...args); // 2 errors
foo.bind(null, 1, 2, ...args); // 4 errors
new foo(1, 2); // 2 errors
new foo(...args); // 2 errors
new foo(1, 2, ...args); // 4 errors