Upgrade to Jest 19 (#762)

* Upgrade to Jest 19

* Use exact versions for Jest
master
Rogelio Guzman 2017-02-21 13:59:19 -08:00 committed by Christopher Chedeau
parent 278b489f38
commit d45e157563
435 changed files with 11036 additions and 10223 deletions

View File

@ -24,19 +24,19 @@
"flow-parser": "0.38.0",
"get-stdin": "5.0.1",
"glob": "7.1.1",
"jest-validate": "18.2.0",
"jest-validate": "19.0.0",
"minimist": "1.2.0"
},
"devDependencies": {
"jest": "18.0.0",
"diff": "3.2.0",
"jest": "19.0.0",
"rollup": "0.41.1",
"rollup-plugin-commonjs": "7.0.0",
"rollup-plugin-json": "2.1.0",
"rollup-plugin-node-builtins": "2.0.0",
"rollup-plugin-node-globals": "1.1.0",
"rollup-plugin-node-resolve": "2.0.0",
"rollup-plugin-real-babili": "1.0.0-alpha3",
"diff": "3.2.0"
"rollup-plugin-real-babili": "1.0.0-alpha3"
},
"scripts": {
"test": "jest",

View File

@ -1,4 +1,6 @@
exports[`test multiple.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`multiple.js 1`] = `
"[...a, ...b,];
[...a, ...b];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -1,4 +1,6 @@
exports[`test last.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`last.js 1`] = `
"[,];
[,,];
[,,1,];
@ -11,7 +13,7 @@ exports[`test last.js 1`] = `
"
`;
exports[`test preserve_empty_lines.js 1`] = `
exports[`preserve_empty_lines.js 1`] = `
"a = [
1,

View File

@ -1,4 +1,6 @@
exports[`test arrow_function_expression.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`arrow_function_expression.js 1`] = `
"(a => {}).length
typeof (() => {});
export default (() => {})();
@ -18,14 +20,14 @@ if ((() => {}) ? 1 : 0) {
"
`;
exports[`test block_like.js 1`] = `
exports[`block_like.js 1`] = `
"a = () => ({} = this);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a = () => ({} = this);
"
`;
exports[`test long-call-no-args.js 1`] = `
exports[`long-call-no-args.js 1`] = `
"veryLongCall(VERY_VERY_VERY_VERY_VERY_VERY_VERY_VERY_VERY_VERY_LONG_CONSTANT, () => {})
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
veryLongCall(
@ -35,17 +37,17 @@ veryLongCall(
"
`;
exports[`test long-contents.js 1`] = `
exports[`long-contents.js 1`] = `
"const foo = () => {
expect(arg1, arg2, arg3).toEqual({message: \'test\', messageType: \'SMS\', status: \'Unknown\', created: \'11/01/2017 13:36\'});
expect(arg1, arg2, arg3).toEqual({message: 'test', messageType: 'SMS', status: 'Unknown', created: '11/01/2017 13:36'});
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const foo = () => {
expect(arg1, arg2, arg3).toEqual({
message: \"test\",
messageType: \"SMS\",
status: \"Unknown\",
created: \"11/01/2017 13:36\"
message: \\"test\\",
messageType: \\"SMS\\",
status: \\"Unknown\\",
created: \\"11/01/2017 13:36\\"
});
};
"

View File

@ -1,4 +1,6 @@
exports[`test await_parse.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`await_parse.js 1`] = `
"async function f() { (await f()).length }
async function g() {
invariant(
@ -27,23 +29,23 @@ async function f() {
"
`;
exports[`test conditional-expression.js 1`] = `
exports[`conditional-expression.js 1`] = `
"async function f() {
const result = typeof fn === \'function\' ? await fn() : null;
const result = typeof fn === 'function' ? await fn() : null;
}
(async function() {
console.log(
await (true ? Promise.resolve(\"A\") : Promise.resolve(\"B\"))
await (true ? Promise.resolve(\\"A\\") : Promise.resolve(\\"B\\"))
);
})()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
async function f() {
const result = typeof fn === \"function\" ? await fn() : null;
const result = typeof fn === \\"function\\" ? await fn() : null;
}
(async function() {
console.log(await (true ? Promise.resolve(\"A\") : Promise.resolve(\"B\")));
console.log(await (true ? Promise.resolve(\\"A\\") : Promise.resolve(\\"B\\")));
})();
"
`;

View File

@ -1,4 +1,6 @@
exports[`test arrow.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`arrow.js 1`] = `
"function f() {
const appEntitys = getAppEntitys(loadObject).filter(
entity => entity && entity.isInstallAvailable() && !entity.isQueue() && entity.isDisabled()
@ -17,19 +19,19 @@ function f() {
"
`;
exports[`test inline-object-array.js 1`] = `
exports[`inline-object-array.js 1`] = `
"prevState = prevState || {
catalogs: [],
loadState: LOADED,
opened: false,
searchQuery: \'\',
searchQuery: '',
selectedCatalog: null,
};
this.steps = steps || [
{
name: \'mock-module\',
path: \'/nux/mock-module\',
name: 'mock-module',
path: '/nux/mock-module',
},
];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -37,20 +39,20 @@ prevState = prevState || {
catalogs: [],
loadState: LOADED,
opened: false,
searchQuery: \"\",
searchQuery: \\"\\",
selectedCatalog: null
};
this.steps = steps || [
{
name: \"mock-module\",
path: \"/nux/mock-module\"
name: \\"mock-module\\",
path: \\"/nux/mock-module\\"
}
];
"
`;
exports[`test short-right.js 1`] = `
exports[`short-right.js 1`] = `
"this._cumulativeHeights &&
Math.abs(
this._cachedItemHeight(this._firstVisibleIndex + i) -
@ -64,7 +66,7 @@ foooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(
a;
const isPartOfPackageJSON = dependenciesArray.indexOf(
dependencyWithOutRelativePath.split(\'/\')[0],
dependencyWithOutRelativePath.split('/')[0],
) !== -1;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
this._cumulativeHeights &&
@ -78,12 +80,12 @@ foooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(
) + a;
const isPartOfPackageJSON = dependenciesArray.indexOf(
dependencyWithOutRelativePath.split(\"/\")[0]
dependencyWithOutRelativePath.split(\\"/\\")[0]
) !== -1;
"
`;
exports[`test test.js 1`] = `
exports[`test.js 1`] = `
"// It should always break the highest precedence operators first, and
// break them all at the same time.

View File

@ -1,4 +1,6 @@
exports[`test array.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`array.js 1`] = `
"const arr1 = [1,2,3,4];
const arr2 = [1, 2, 3, 4];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -7,7 +9,7 @@ const arr2 = [1, 2, 3, 4];
"
`;
exports[`test array.js 2`] = `
exports[`array.js 2`] = `
"const arr1 = [1,2,3,4];
const arr2 = [1, 2, 3, 4];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -16,7 +18,7 @@ const arr2 = [1, 2, 3, 4];
"
`;
exports[`test object.js 1`] = `
exports[`object.js 1`] = `
"const obj1 = {a:1, b:2, c:3}
const obj2 = { a:1, b:2, c:3 };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -25,7 +27,7 @@ const obj2 = { a: 1, b: 2, c: 3 };
"
`;
exports[`test object.js 2`] = `
exports[`object.js 2`] = `
"const obj1 = {a:1, b:2, c:3}
const obj2 = { a:1, b:2, c:3 };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -1,4 +1,6 @@
exports[`test break.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`break.js 1`] = `
"h(f(g(() => {
a
})))

View File

@ -1,55 +1,57 @@
exports[`test extends.js 1`] = `
"// \"ArrowFunctionExpression\"
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`extends.js 1`] = `
"// \\"ArrowFunctionExpression\\"
class a extends (() => {}) {}
// \"AssignmentExpression\"
// \\"AssignmentExpression\\"
class a extends (b = c) {}
// \"AwaitExpression\"
// \\"AwaitExpression\\"
async function f() {
class a extends (await b) {}
}
// \"BinaryExpression\"
// \\"BinaryExpression\\"
class a extends (b + c) {}
// \"CallExpression\"
// \\"CallExpression\\"
class a extends b() {}
// \"ClassExpression\"
// \\"ClassExpression\\"
class a extends class {} {}
// \"ConditionalExpression\"
// \\"ConditionalExpression\\"
class a extends (b ? c : d) {}
// \"FunctionExpression\"
// \\"FunctionExpression\\"
class a extends (function() {}) {}
// \"LogicalExpression\"
// \\"LogicalExpression\\"
class a extends (b || c) {}
// \"MemberExpression\"
// \\"MemberExpression\\"
class a extends b.c {}
// \"NewExpression\"
// \\"NewExpression\\"
class a extends (new B()) {}
// \"ObjectExpression\"
// \\"ObjectExpression\\"
class a extends ({}) {}
// \"SequenceExpression\"
// \\"SequenceExpression\\"
class a extends (b, c) {}
// \"TaggedTemplateExpression\"
// \\"TaggedTemplateExpression\\"
class a extends \`\` {}
// \"UnaryExpression\"
// \\"UnaryExpression\\"
class a extends (void b) {}
// \"UpdateExpression\"
// \\"UpdateExpression\\"
class a extends (++b) {}
// \"YieldExpression\"
// \\"YieldExpression\\"
function* f() {
// Flow has a bug parsing it.
// class a extends (yield 1) {}
@ -57,57 +59,57 @@ function* f() {
x = class extends (++b) {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// \"ArrowFunctionExpression\"
// \\"ArrowFunctionExpression\\"
class a extends (() => {}) {}
// \"AssignmentExpression\"
// \\"AssignmentExpression\\"
class a extends (b = c) {}
// \"AwaitExpression\"
// \\"AwaitExpression\\"
async function f() {
class a extends (await b) {}
}
// \"BinaryExpression\"
// \\"BinaryExpression\\"
class a extends (b + c) {}
// \"CallExpression\"
// \\"CallExpression\\"
class a extends b() {}
// \"ClassExpression\"
// \\"ClassExpression\\"
class a extends class {} {}
// \"ConditionalExpression\"
// \\"ConditionalExpression\\"
class a extends (b ? c : d) {}
// \"FunctionExpression\"
// \\"FunctionExpression\\"
class a extends function() {} {}
// \"LogicalExpression\"
// \\"LogicalExpression\\"
class a extends (b || c) {}
// \"MemberExpression\"
// \\"MemberExpression\\"
class a extends b.c {}
// \"NewExpression\"
// \\"NewExpression\\"
class a extends (new B()) {}
// \"ObjectExpression\"
// \\"ObjectExpression\\"
class a extends ({}) {}
// \"SequenceExpression\"
// \\"SequenceExpression\\"
class a extends (b, c) {}
// \"TaggedTemplateExpression\"
// \\"TaggedTemplateExpression\\"
class a extends \`\` {}
// \"UnaryExpression\"
// \\"UnaryExpression\\"
class a extends (void b) {}
// \"UpdateExpression\"
// \\"UpdateExpression\\"
class a extends (++b) {}
// \"YieldExpression\"
// \\"YieldExpression\\"
function* f() {
// Flow has a bug parsing it.
// class a extends (yield 1) {}

View File

@ -1,4 +1,6 @@
exports[`test binary.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`binary.js 1`] = `
"(class {}) + 1;
(class a {}) + 1;
(class extends b {}) + 1;
@ -11,7 +13,7 @@ exports[`test binary.js 1`] = `
"
`;
exports[`test break.js 1`] = `
exports[`break.js 1`] = `
"class MyContractSelectionWidget extends React.Component<void, MyContractSelectionWidgetPropsType, void> implements SomethingLarge {
method() {}
}
@ -24,14 +26,14 @@ class MyContractSelectionWidget
"
`;
exports[`test call.js 1`] = `
exports[`call.js 1`] = `
"(class {})(class {});
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(class {})(class {});
"
`;
exports[`test empty.js 1`] = `
exports[`empty.js 1`] = `
"class A {
// comment
}
@ -62,7 +64,7 @@ class A {
"
`;
exports[`test member.js 1`] = `
exports[`member.js 1`] = `
"(class {})[1];
(class {}).a;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -71,7 +73,7 @@ exports[`test member.js 1`] = `
"
`;
exports[`test ternary.js 1`] = `
exports[`ternary.js 1`] = `
"if (1) (class {}) ? 1 : 2;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (1) (class {}) ? 1 : 2;

View File

@ -1,4 +1,28 @@
exports[`test blank.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`assignment-pattern.js 1`] = `
"const { a /* comment */ = 1 } = b;
const { c = 1 /* comment */ } = d;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const { a /* comment */ = 1 } = b;
const { c = 1 /* comment */ } = d;
"
`;
exports[`assignment-pattern.js 2`] = `
"const { a /* comment */ = 1 } = b;
const { c = 1 /* comment */ } = d;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const { a /* comment */ = 1 } = b;
const { c = 1 /* comment */ } = d;
"
`;
exports[`blank.js 1`] = `
"// This file only
// has comments. This comment
// should still exist
@ -13,7 +37,7 @@ exports[`test blank.js 1`] = `
"
`;
exports[`test blank.js 2`] = `
exports[`blank.js 2`] = `
"// This file only
// has comments. This comment
// should still exist
@ -28,7 +52,7 @@ exports[`test blank.js 2`] = `
"
`;
exports[`test dangling.js 1`] = `
exports[`dangling.js 1`] = `
"var x = {/* dangling */};
var x = {
// dangling
@ -59,7 +83,7 @@ export /* dangling */{};
"
`;
exports[`test dangling.js 2`] = `
exports[`dangling.js 2`] = `
"var x = {/* dangling */};
var x = {
// dangling
@ -90,7 +114,7 @@ export /* dangling */{};
"
`;
exports[`test dangling_array.js 1`] = `
exports[`dangling_array.js 1`] = `
"expect(() => {}).toTriggerReadyStateChanges([
// Nothing.
]);
@ -107,7 +131,7 @@ expect(() => {}).toTriggerReadyStateChanges(
"
`;
exports[`test dangling_array.js 2`] = `
exports[`dangling_array.js 2`] = `
"expect(() => {}).toTriggerReadyStateChanges([
// Nothing.
]);
@ -124,7 +148,7 @@ expect(() => {}).toTriggerReadyStateChanges(
"
`;
exports[`test dangling_for.js 1`] = `
exports[`dangling_for.js 1`] = `
"for // comment
(;;);
@ -138,7 +162,7 @@ for (;;);
"
`;
exports[`test dangling_for.js 2`] = `
exports[`dangling_for.js 2`] = `
"for // comment
(;;);
@ -152,7 +176,7 @@ for (;;);
"
`;
exports[`test first-line.js 1`] = `
exports[`first-line.js 1`] = `
"a // comment
b
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -161,7 +185,7 @@ b;
"
`;
exports[`test first-line.js 2`] = `
exports[`first-line.js 2`] = `
"a // comment
b
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -170,7 +194,7 @@ b;
"
`;
exports[`test if.js 1`] = `
exports[`if.js 1`] = `
"if (1)
// comment
{
@ -214,7 +238,7 @@ else if (4) {
"
`;
exports[`test if.js 2`] = `
exports[`if.js 2`] = `
"if (1)
// comment
{
@ -258,7 +282,7 @@ else if (4) {
"
`;
exports[`test issues.js 1`] = `
exports[`issues.js 1`] = `
"// Does not need to break as it fits in 80 columns
this.call(a, /* comment */ b);
@ -279,23 +303,23 @@ throw new ProcessSystemError({
// squished in a single line afterward
export type BuckWebSocketMessage = {
// Not actually from Buck - this is to let the receiver know that the socket is connected.
type: \'SocketConnected\',
type: 'SocketConnected',
} | {
type: \'BuildProgressUpdated\',
type: 'BuildProgressUpdated',
progressValue: number,
} | {
type: \'BuildFinished\',
type: 'BuildFinished',
exitCode: number,
} | {
type: \'BuildStarted\',
type: 'BuildStarted',
} | {
type: \'ParseStarted\',
type: 'ParseStarted',
} | {
type: \'ParseFinished\',
type: 'ParseFinished',
} | {
type: \'RunStarted\',
type: 'RunStarted',
} | {
type: \'RunComplete\',
type: 'RunComplete',
};
// Missing one level of indentation because of the comment
@ -317,20 +341,20 @@ export type AsyncExecuteOptions = child_process$execFileOpts & {
// optional trailing comma gets moved all the way to the beginning
const regex = new RegExp(
\'^\\\\s*\' + // beginning of the line
\'name\\\\s*=\\\\s*\' + // name =
\'[\\\'\"]\' + // opening quotation mark
'^\\\\\\\\s*' + // beginning of the line
'name\\\\\\\\s*=\\\\\\\\s*' + // name =
'[\\\\'\\"]' + // opening quotation mark
escapeStringRegExp(target.name) + // target name
\'[\\\'\"]\' + // closing quotation mark
\',?$\', // optional trailing comma
'[\\\\'\\"]' + // closing quotation mark
',?$', // optional trailing comma
);
// The comment is moved and doesn\'t trigger the eslint rule anymore
import path from \'path\'; // eslint-disable-line nuclide-internal/prefer-nuclide-uri
// The comment is moved and doesn't trigger the eslint rule anymore
import path from 'path'; // eslint-disable-line nuclide-internal/prefer-nuclide-uri
// Comments disappear in-between MemberExpressions
Observable.of(process)
// Don\'t complete until we say so!
// Don't complete until we say so!
.merge(Observable.never())
// Get the errors.
.takeUntil(throwOnError ? errors.flatMap(Observable.throw) : errors)
@ -360,7 +384,7 @@ else {
}
// The comment makes the line break in a weird way
const result = asyncExecute(\'non_existing_command\', /* args */ []);
const result = asyncExecute('non_existing_command', /* args */ []);
// The closing paren is printed on the same line as the comment
foo({}
@ -389,30 +413,30 @@ throw new ProcessSystemError({
export type BuckWebSocketMessage =
| {
// Not actually from Buck - this is to let the receiver know that the socket is connected.
type: \"SocketConnected\"
type: \\"SocketConnected\\"
}
| {
type: \"BuildProgressUpdated\",
type: \\"BuildProgressUpdated\\",
progressValue: number
}
| {
type: \"BuildFinished\",
type: \\"BuildFinished\\",
exitCode: number
}
| {
type: \"BuildStarted\"
type: \\"BuildStarted\\"
}
| {
type: \"ParseStarted\"
type: \\"ParseStarted\\"
}
| {
type: \"ParseFinished\"
type: \\"ParseFinished\\"
}
| {
type: \"RunStarted\"
type: \\"RunStarted\\"
}
| {
type: \"RunComplete\"
type: \\"RunComplete\\"
};
// Missing one level of indentation because of the comment
@ -432,20 +456,20 @@ export type AsyncExecuteOptions = child_process$execFileOpts & {
// optional trailing comma gets moved all the way to the beginning
const regex = new RegExp(
\"^\\\\s*\" + // beginning of the line
\"name\\\\s*=\\\\s*\" + // name =
\"[\'\\\"]\" + // opening quotation mark
\\"^\\\\\\\\s*\\" + // beginning of the line
\\"name\\\\\\\\s*=\\\\\\\\s*\\" + // name =
\\"['\\\\\\"]\\" + // opening quotation mark
escapeStringRegExp(target.name) + // target name
\"[\'\\\"]\" + // closing quotation mark
\",?$\" // optional trailing comma
\\"['\\\\\\"]\\" + // closing quotation mark
\\",?$\\" // optional trailing comma
);
// The comment is moved and doesn\'t trigger the eslint rule anymore
import path from \"path\"; // eslint-disable-line nuclide-internal/prefer-nuclide-uri
// The comment is moved and doesn't trigger the eslint rule anymore
import path from \\"path\\"; // eslint-disable-line nuclide-internal/prefer-nuclide-uri
// Comments disappear in-between MemberExpressions
Observable.of(process)
// Don\'t complete until we say so!
// Don't complete until we say so!
.merge(Observable.never())
// Get the errors.
.takeUntil(throwOnError ? errors.flatMap(Observable.throw) : errors)
@ -473,7 +497,7 @@ if (1) {
}
// The comment makes the line break in a weird way
const result = asyncExecute(\"non_existing_command\", /* args */ []);
const result = asyncExecute(\\"non_existing_command\\", /* args */ []);
// The closing paren is printed on the same line as the comment
foo(
@ -483,7 +507,7 @@ foo(
"
`;
exports[`test issues.js 2`] = `
exports[`issues.js 2`] = `
"// Does not need to break as it fits in 80 columns
this.call(a, /* comment */ b);
@ -504,23 +528,23 @@ throw new ProcessSystemError({
// squished in a single line afterward
export type BuckWebSocketMessage = {
// Not actually from Buck - this is to let the receiver know that the socket is connected.
type: \'SocketConnected\',
type: 'SocketConnected',
} | {
type: \'BuildProgressUpdated\',
type: 'BuildProgressUpdated',
progressValue: number,
} | {
type: \'BuildFinished\',
type: 'BuildFinished',
exitCode: number,
} | {
type: \'BuildStarted\',
type: 'BuildStarted',
} | {
type: \'ParseStarted\',
type: 'ParseStarted',
} | {
type: \'ParseFinished\',
type: 'ParseFinished',
} | {
type: \'RunStarted\',
type: 'RunStarted',
} | {
type: \'RunComplete\',
type: 'RunComplete',
};
// Missing one level of indentation because of the comment
@ -542,20 +566,20 @@ export type AsyncExecuteOptions = child_process$execFileOpts & {
// optional trailing comma gets moved all the way to the beginning
const regex = new RegExp(
\'^\\\\s*\' + // beginning of the line
\'name\\\\s*=\\\\s*\' + // name =
\'[\\\'\"]\' + // opening quotation mark
'^\\\\\\\\s*' + // beginning of the line
'name\\\\\\\\s*=\\\\\\\\s*' + // name =
'[\\\\'\\"]' + // opening quotation mark
escapeStringRegExp(target.name) + // target name
\'[\\\'\"]\' + // closing quotation mark
\',?$\', // optional trailing comma
'[\\\\'\\"]' + // closing quotation mark
',?$', // optional trailing comma
);
// The comment is moved and doesn\'t trigger the eslint rule anymore
import path from \'path\'; // eslint-disable-line nuclide-internal/prefer-nuclide-uri
// The comment is moved and doesn't trigger the eslint rule anymore
import path from 'path'; // eslint-disable-line nuclide-internal/prefer-nuclide-uri
// Comments disappear in-between MemberExpressions
Observable.of(process)
// Don\'t complete until we say so!
// Don't complete until we say so!
.merge(Observable.never())
// Get the errors.
.takeUntil(throwOnError ? errors.flatMap(Observable.throw) : errors)
@ -585,7 +609,7 @@ else {
}
// The comment makes the line break in a weird way
const result = asyncExecute(\'non_existing_command\', /* args */ []);
const result = asyncExecute('non_existing_command', /* args */ []);
// The closing paren is printed on the same line as the comment
foo({}
@ -614,30 +638,30 @@ throw new ProcessSystemError({
export type BuckWebSocketMessage =
| {
// Not actually from Buck - this is to let the receiver know that the socket is connected.
type: \"SocketConnected\"
type: \\"SocketConnected\\"
}
| {
type: \"BuildProgressUpdated\",
type: \\"BuildProgressUpdated\\",
progressValue: number
}
| {
type: \"BuildFinished\",
type: \\"BuildFinished\\",
exitCode: number
}
| {
type: \"BuildStarted\"
type: \\"BuildStarted\\"
}
| {
type: \"ParseStarted\"
type: \\"ParseStarted\\"
}
| {
type: \"ParseFinished\"
type: \\"ParseFinished\\"
}
| {
type: \"RunStarted\"
type: \\"RunStarted\\"
}
| {
type: \"RunComplete\"
type: \\"RunComplete\\"
};
// Missing one level of indentation because of the comment
@ -657,20 +681,20 @@ export type AsyncExecuteOptions = child_process$execFileOpts & {
// optional trailing comma gets moved all the way to the beginning
const regex = new RegExp(
\"^\\\\s*\" + // beginning of the line
\"name\\\\s*=\\\\s*\" + // name =
\"[\'\\\"]\" + // opening quotation mark
\\"^\\\\\\\\s*\\" + // beginning of the line
\\"name\\\\\\\\s*=\\\\\\\\s*\\" + // name =
\\"['\\\\\\"]\\" + // opening quotation mark
escapeStringRegExp(target.name) + // target name
\"[\'\\\"]\" + // closing quotation mark
\",?$\" // optional trailing comma
\\"['\\\\\\"]\\" + // closing quotation mark
\\",?$\\" // optional trailing comma
);
// The comment is moved and doesn\'t trigger the eslint rule anymore
import path from \"path\"; // eslint-disable-line nuclide-internal/prefer-nuclide-uri
// The comment is moved and doesn't trigger the eslint rule anymore
import path from \\"path\\"; // eslint-disable-line nuclide-internal/prefer-nuclide-uri
// Comments disappear in-between MemberExpressions
Observable.of(process)
// Don\'t complete until we say so!
// Don't complete until we say so!
.merge(Observable.never())
// Get the errors.
.takeUntil(throwOnError ? errors.flatMap(Observable.throw) : errors)
@ -698,7 +722,7 @@ if (1) {
}
// The comment makes the line break in a weird way
const result = asyncExecute(\"non_existing_command\", /* args */ []);
const result = asyncExecute(\\"non_existing_command\\", /* args */ []);
// The closing paren is printed on the same line as the comment
foo(
@ -708,7 +732,7 @@ foo(
"
`;
exports[`test jsx.js 1`] = `
exports[`jsx.js 1`] = `
"<div>
{
/* comment */
@ -784,7 +808,7 @@ exports[`test jsx.js 1`] = `
"
`;
exports[`test jsx.js 2`] = `
exports[`jsx.js 2`] = `
"<div>
{
/* comment */
@ -860,7 +884,7 @@ exports[`test jsx.js 2`] = `
"
`;
exports[`test preserve-new-line-last.js 1`] = `
exports[`preserve-new-line-last.js 1`] = `
"function f() {
a
/* eslint-disable */
@ -907,7 +931,7 @@ function name() {
"
`;
exports[`test preserve-new-line-last.js 2`] = `
exports[`preserve-new-line-last.js 2`] = `
"function f() {
a
/* eslint-disable */
@ -954,7 +978,7 @@ function name() {
"
`;
exports[`test return-statement.js 1`] = `
exports[`return-statement.js 1`] = `
"function a() {
return (
// Comment
@ -993,7 +1017,7 @@ function c() {
"
`;
exports[`test return-statement.js 2`] = `
exports[`return-statement.js 2`] = `
"function a() {
return (
// Comment
@ -1032,7 +1056,7 @@ function c() {
"
`;
exports[`test try.js 1`] = `
exports[`try.js 1`] = `
"// comment 1
try {
// comment 2
@ -1060,7 +1084,7 @@ try {
"
`;
exports[`test try.js 2`] = `
exports[`try.js 2`] = `
"// comment 1
try {
// comment 2
@ -1087,25 +1111,3 @@ try {
}
"
`;
exports[`test assignment-pattern.js 1`] = `
"const { a /* comment */ = 1 } = b;
const { c = 1 /* comment */ } = d;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const { a /* comment */ = 1 } = b;
const { c = 1 /* comment */ } = d;
"
`;
exports[`test assignment-pattern.js 2`] = `
"const { a /* comment */ = 1 } = b;
const { c = 1 /* comment */ } = d;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const { a /* comment */ = 1 } = b;
const { c = 1 /* comment */ } = d;
"
`;

View File

@ -1,10 +1,12 @@
exports[`test classes.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`classes.js 1`] = `
"class c {
[\"i\"]() {}
[\\"i\\"]() {}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class c {
[\"i\"]() {}
[\\"i\\"]() {}
}
"
`;

View File

@ -1,4 +1,6 @@
exports[`test comments.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`comments.js 1`] = `
"var inspect = 4 === util.inspect.length
? // node <= 0.8.x
(function(v, colors) {
@ -21,21 +23,21 @@ var inspect = 4 === util.inspect.length
const extractTextPluginOptions = shouldUseRelativeAssetPaths
// Making sure that the publicPath goes back to to build folder.
? { publicPath: Array(cssFilename.split(\'/\').length).join(\'../\') } :
? { publicPath: Array(cssFilename.split('/').length).join('../') } :
{};
const extractTextPluginOptions = shouldUseRelativeAssetPaths
? // Making sure that the publicPath goes back to to build folder.
{ publicPath: Array(cssFilename.split(\"/\").length).join(\"../\") }
{ publicPath: Array(cssFilename.split(\\"/\\").length).join(\\"../\\") }
: {};
const extractTextPluginOptions = shouldUseRelativeAssetPaths // Making sure that the publicPath goes back to to build folder.
? { publicPath: Array(cssFilename.split(\"/\").length).join(\"../\") }
? { publicPath: Array(cssFilename.split(\\"/\\").length).join(\\"../\\") }
: {};
const { configureStore } = process.env.NODE_ENV === \"production\"
? require(\"./configureProdStore\") // a
: require(\"./configureDevStore\"); // b
const { configureStore } = process.env.NODE_ENV === \\"production\\"
? require(\\"./configureProdStore\\") // a
: require(\\"./configureDevStore\\"); // b
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var inspect = 4 === util.inspect.length
? // node <= 0.8.x
@ -59,20 +61,20 @@ var inspect = 4 === util.inspect.length
const extractTextPluginOptions = shouldUseRelativeAssetPaths
? // Making sure that the publicPath goes back to to build folder.
{ publicPath: Array(cssFilename.split(\"/\").length).join(\"../\") }
{ publicPath: Array(cssFilename.split(\\"/\\").length).join(\\"../\\") }
: {};
const extractTextPluginOptions = shouldUseRelativeAssetPaths
? // Making sure that the publicPath goes back to to build folder.
{ publicPath: Array(cssFilename.split(\"/\").length).join(\"../\") }
{ publicPath: Array(cssFilename.split(\\"/\\").length).join(\\"../\\") }
: {};
const extractTextPluginOptions = shouldUseRelativeAssetPaths // Making sure that the publicPath goes back to to build folder.
? { publicPath: Array(cssFilename.split(\"/\").length).join(\"../\") }
? { publicPath: Array(cssFilename.split(\\"/\\").length).join(\\"../\\") }
: {};
const { configureStore } = process.env.NODE_ENV === \"production\"
? require(\"./configureProdStore\") // a
: require(\"./configureDevStore\"); // b
const { configureStore } = process.env.NODE_ENV === \\"production\\"
? require(\\"./configureProdStore\\") // a
: require(\\"./configureDevStore\\"); // b
"
`;

View File

@ -1,5 +1,7 @@
exports[`test mobx.js 1`] = `
"import {observable} from \"mobx\";
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`mobx.js 1`] = `
"import {observable} from \\"mobx\\";
@observer class OrderLine {
@observable price:number = 0;
@ -14,7 +16,7 @@ exports[`test mobx.js 1`] = `
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import { observable } from \"mobx\";
import { observable } from \\"mobx\\";
@observer class OrderLine {
@observable price: number = 0;
@ -31,7 +33,7 @@ import { observable } from \"mobx\";
"
`;
exports[`test multiple.js 1`] = `
exports[`multiple.js 1`] = `
"const dog = {
@readonly
@nonenumerable
@ -48,7 +50,7 @@ const dog = {
"
`;
exports[`test redux.js 1`] = `
exports[`redux.js 1`] = `
"@connect(mapStateToProps, mapDispatchToProps)
export class MyApp extends React.Component {}

View File

@ -1,127 +1,129 @@
exports[`test last-line-0.js 1`] = `
"\'use strict\';~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\"use strict\";
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`last-line-0.js 1`] = `
"'use strict';~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\\"use strict\\";
"
`;
exports[`test last-line-0.js 2`] = `
"\'use strict\';~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\"use strict\";
exports[`last-line-0.js 2`] = `
"'use strict';~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\\"use strict\\";
"
`;
exports[`test last-line-1.js 1`] = `
"\'use strict\';
exports[`last-line-1.js 1`] = `
"'use strict';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\"use strict\";
\\"use strict\\";
"
`;
exports[`test last-line-1.js 2`] = `
"\'use strict\';
exports[`last-line-1.js 2`] = `
"'use strict';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\"use strict\";
\\"use strict\\";
"
`;
exports[`test last-line-2.js 1`] = `
"\'use strict\';
exports[`last-line-2.js 1`] = `
"'use strict';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\"use strict\";
\\"use strict\\";
"
`;
exports[`test last-line-2.js 2`] = `
"\'use strict\';
exports[`last-line-2.js 2`] = `
"'use strict';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\"use strict\";
\\"use strict\\";
"
`;
exports[`test newline.js 1`] = `
exports[`newline.js 1`] = `
"/* @flow */
\"use strict\";
\\"use strict\\";
import a from \"a\";
import a from \\"a\\";
a();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
\"use strict\";
\\"use strict\\";
import a from \"a\";
import a from \\"a\\";
a();
"
`;
exports[`test newline.js 2`] = `
exports[`newline.js 2`] = `
"/* @flow */
\"use strict\";
\\"use strict\\";
import a from \"a\";
import a from \\"a\\";
a();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
\"use strict\";
\\"use strict\\";
import a from \"a\";
import a from \\"a\\";
a();
"
`;
exports[`test no-newline.js 1`] = `
"\"use strict\";
exports[`no-newline.js 1`] = `
"\\"use strict\\";
a
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\"use strict\";
\\"use strict\\";
a;
"
`;
exports[`test no-newline.js 2`] = `
"\"use strict\";
exports[`no-newline.js 2`] = `
"\\"use strict\\";
a
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\"use strict\";
\\"use strict\\";
a;
"
`;
exports[`test test.js 1`] = `
"\"use strict\";
exports[`test.js 1`] = `
"\\"use strict\\";
function fn() {
\"use strict\";
\\"use strict\\";
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\"use strict\";
\\"use strict\\";
function fn() {
\"use strict\";
\\"use strict\\";
}
"
`;
exports[`test test.js 2`] = `
"\"use strict\";
exports[`test.js 2`] = `
"\\"use strict\\";
function fn() {
\"use strict\";
\\"use strict\\";
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\"use strict\";
\\"use strict\\";
function fn() {
\"use strict\";
\\"use strict\\";
}
"
`;

View File

@ -1,8 +1,10 @@
exports[`test test.js 1`] = `
"import(\"module.js\");
import(\"module.js\").then((a) => a);
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"import(\\"module.js\\");
import(\\"module.js\\").then((a) => a);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import(\"module.js\");
import(\"module.js\").then(a => a);
import(\\"module.js\\");
import(\\"module.js\\").then(a => a);
"
`;

View File

@ -1,4 +1,6 @@
exports[`test body.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`body.js 1`] = `
"with (a);
if (1); else if (2); else;
for (;;);

View File

@ -1,60 +1,62 @@
exports[`test export_default_arrow_expression.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`export_default_arrow_expression.js 1`] = `
"export default () => {};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export default () => {};
"
`;
exports[`test export_default_call_expression.js 1`] = `
exports[`export_default_call_expression.js 1`] = `
"export default foo()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export default foo();
"
`;
exports[`test export_default_class_declaration.js 1`] = `
exports[`export_default_class_declaration.js 1`] = `
"export default class Foo {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export default class Foo {}
"
`;
exports[`test export_default_class_expression.js 1`] = `
exports[`export_default_class_expression.js 1`] = `
"export default (class foobar {})
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export default (class foobar {});
"
`;
exports[`test export_default_function_declaration.js 1`] = `
exports[`export_default_function_declaration.js 1`] = `
"export default function() {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export default function() {}
"
`;
exports[`test export_default_function_declaration_named.js 1`] = `
exports[`export_default_function_declaration_named.js 1`] = `
"export default function f(){}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export default function f() {}
"
`;
exports[`test export_default_function_expression.js 1`] = `
exports[`export_default_function_expression.js 1`] = `
"export default (function() {});
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export default (function() {});
"
`;
exports[`test export_default_function_expression_named.js 1`] = `
exports[`export_default_function_expression_named.js 1`] = `
"export default (function f(){})
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export default (function f() {});
"
`;
exports[`test export_default_new_expression.js 1`] = `
exports[`export_default_new_expression.js 1`] = `
"export default new Foo();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export default new Foo();

View File

@ -1,4 +1,6 @@
exports[`test bracket.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`bracket.js 1`] = `
"export {
runTaskForChanged,
description,
@ -25,7 +27,7 @@ export { fitsIn, oneLine };
"
`;
exports[`test bracket.js 2`] = `
exports[`bracket.js 2`] = `
"export {
runTaskForChanged,
description,
@ -52,20 +54,20 @@ export {fitsIn, oneLine};
"
`;
exports[`test empty.js 1`] = `
exports[`empty.js 1`] = `
"export {};
export {} from \".\";
export {} from \\".\\";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export {};
export {} from \".\";
export {} from \\".\\";
"
`;
exports[`test empty.js 2`] = `
exports[`empty.js 2`] = `
"export {};
export {} from \".\";
export {} from \\".\\";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export {};
export {} from \".\";
export {} from \\".\\";
"
`;

View File

@ -1,4 +1,6 @@
exports[`test body.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`body.js 1`] = `
"export default (class {}[1] = 1);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export default ((class {})[1] = 1);

View File

@ -1,8 +1,10 @@
exports[`test export.js 1`] = `
"export * as ns from \'mod\';
export v from \'mod\';
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`export.js 1`] = `
"export * as ns from 'mod';
export v from 'mod';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export * as ns from \"mod\";
export v from \"mod\";
export * as ns from \\"mod\\";
export v from \\"mod\\";
"
`;

View File

@ -1,5 +1,7 @@
exports[`test test.js 1`] = `
"export { value1, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from \"exports\";
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"export { value1, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from \\"exports\\";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export {
value1,
@ -7,6 +9,6 @@ export {
value3,
value4 as value4_renamed,
value5
} from \"exports\";
} from \\"exports\\";
"
`;

View File

@ -1,17 +1,19 @@
exports[`test no_regression.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`no_regression.js 1`] = `
"// Ensure no regression.
\"use strict\";
\\"use strict\\";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Ensure no regression.
\"use strict\";
\\"use strict\\";
"
`;
exports[`test use_strict.js 1`] = `
exports[`use_strict.js 1`] = `
"// Parentheses around expression statement should be preserved in this case.
(\"use strict\");
(\\"use strict\\");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Parentheses around expression statement should be preserved in this case.
(\"use strict\");
(\\"use strict\\");
"
`;

View File

@ -1,4 +1,6 @@
exports[`test break-continue.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`break-continue.js 1`] = `
"function foo() {
while(true) { break; }
}
@ -22,7 +24,7 @@ function bar() {
"
`;
exports[`test return.js 1`] = `
exports[`return.js 1`] = `
"function bar(x:number) { }
function foo() {
var x = null;

View File

@ -1,4 +1,6 @@
exports[`test annot.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`annot.js 1`] = `
"function foo(str:string, i:number):string {
return str;
}
@ -6,12 +8,12 @@ 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} = {str: \"...\", i: \"...\", k: false};
var obj: {str:string; i:number; j:boolean} = {str: \\"...\\", i: \\"...\\", k: false};
var arr: Array<number> = [1,2,\"...\"];
var arr: Array<number> = [1,2,\\"...\\"];
// array sugar
var array: number[] = [1,2,\"...\"];
var array: number[] = [1,2,\\"...\\"];
var matrix: number[][] = [[1,2],[3,4]];
var matrix_parens: (number[])[] = matrix;
@ -21,15 +23,15 @@ var nullable_array_parens: ?(number[]) = nullable_array;
var array_of_nullable: (?number)[] = [null, 3];
var array_of_tuple: [number, string][] = [[0, \"foo\"], [1, \"bar\"]];
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\' };
type ObjType = { 'bar-foo': string; 'foo-bar': number; };
var test_obj: ObjType = { 'bar-foo': '23' };
// param type annos are strict UBs like var type annos
function param_anno(n:number):void {
n = \"hey\"; // error
n = \\"hey\\"; // error
}
// another error on param UB, more typical of www (mis)use-cases
@ -38,7 +40,7 @@ function param_anno2(
batchRequests: Array<{method: string; path: string; params: ?Object}>,
): void {
// error below, since we\'re assigning elements to batchRequests
// error below, since we're assigning elements to batchRequests
// which lack a path property.
// just assign result to new var instead of reassigning to param.
@ -70,15 +72,15 @@ var qux = function(str: string, i: number): number {
};
var obj: { str: string, i: number, j: boolean } = {
str: \"...\",
i: \"...\",
str: \\"...\\",
i: \\"...\\",
k: false
};
var arr: Array<number> = [1, 2, \"...\"];
var arr: Array<number> = [1, 2, \\"...\\"];
// array sugar
var array: number[] = [1, 2, \"...\"];
var array: number[] = [1, 2, \\"...\\"];
var matrix: number[][] = [[1, 2], [3, 4]];
var matrix_parens: number[][] = matrix;
@ -88,15 +90,15 @@ var nullable_array_parens: ?(number[]) = nullable_array;
var array_of_nullable: (?number)[] = [null, 3];
var array_of_tuple: [number, string][] = [[0, \"foo\"], [1, \"bar\"]];
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\" };
type ObjType = { \\"bar-foo\\": string, \\"foo-bar\\": number };
var test_obj: ObjType = { \\"bar-foo\\": \\"23\\" };
// param type annos are strict UBs like var type annos
function param_anno(n: number): void {
n = \"hey\"; // error
n = \\"hey\\"; // error
}
// another error on param UB, more typical of www (mis)use-cases
@ -104,7 +106,7 @@ function param_anno(n: number): void {
function param_anno2(
batchRequests: Array<{ method: string, path: string, params: ?Object }>
): void {
// error below, since we\'re assigning elements to batchRequests
// error below, since we're assigning elements to batchRequests
// which lack a path property.
// just assign result to new var instead of reassigning to param.
@ -132,7 +134,7 @@ function barfoo(n: number | null | void): ?number {
"
`;
exports[`test forward_ref.js 1`] = `
exports[`forward_ref.js 1`] = `
"let myClassInstance: MyClass = null; // forward ref ok, null ~> class error
function bar(): MyClass {
@ -167,7 +169,7 @@ function foo() {
"
`;
exports[`test issue-530.js 1`] = `
exports[`issue-530.js 1`] = `
"function foo(...args: any) { }
module.exports = foo;
@ -178,7 +180,7 @@ module.exports = foo;
"
`;
exports[`test leak.js 1`] = `
exports[`leak.js 1`] = `
"/** @flow */
/* This test documents an example we ran into of a type annotation leaking.
@ -187,7 +189,7 @@ exports[`test leak.js 1`] = `
* annotation for y and stop. We should type the body of bar() with the type
* annotation of y.
*
* However, the leaky type annotation meant that we were flowing x\'s type to y
* However, the leaky type annotation meant that we were flowing x's type to y
* and type checking the body of bar() using the stricter dictionary type,
* leading to an error.
*/
@ -210,7 +212,7 @@ function bar(y: MyObj): string {
* annotation for y and stop. We should type the body of bar() with the type
* annotation of y.
*
* However, the leaky type annotation meant that we were flowing x\'s type to y
* However, the leaky type annotation meant that we were flowing x's type to y
* and type checking the body of bar() using the stricter dictionary type,
* leading to an error.
*/
@ -227,7 +229,7 @@ function bar(y: MyObj): string {
"
`;
exports[`test other.js 1`] = `
exports[`other.js 1`] = `
"class C { }
module.exports = (C: any);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -236,7 +238,7 @@ module.exports = (C: any);
"
`;
exports[`test scope.js 1`] = `
exports[`scope.js 1`] = `
"type Merge<T> = (a: T, b: T) => T;
// hypothetical immutable map
@ -293,11 +295,11 @@ class Foo<A> {
"
`;
exports[`test test.js 1`] = `
"var C = require(\'./other\');
exports[`test.js 1`] = `
"var C = require('./other');
((0: C): string);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var C = require(\"./other\");
var C = require(\\"./other\\");
((0: C): string);
"
`;

View File

@ -1,4 +1,6 @@
exports[`test A.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`A.js 1`] = `
"type T = any;
export default class {
@ -21,14 +23,14 @@ export default class {
"
`;
exports[`test B.js 1`] = `
"import A from \"./A\"
exports[`B.js 1`] = `
"import A from \\"./A\\"
class B extends A {
p: string; // OK, string ~> any
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import A from \"./A\";
import A from \\"./A\\";
class B extends A {
p: string; // OK, string ~> any

View File

@ -1,10 +1,12 @@
exports[`test A.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`A.js 1`] = `
"/**
* @providesModule A
* @flow
*/
import type T from \"T\";
import type T from \\"T\\";
export default class {
p: T;
@ -19,7 +21,7 @@ export default class {
* @flow
*/
import type T from \"T\";
import type T from \\"T\\";
export default class {
p: T;
@ -31,12 +33,12 @@ export default class {
"
`;
exports[`test B.js 1`] = `
exports[`B.js 1`] = `
"/**
* @flow
*/
import A from \"A\"
import A from \\"A\\"
class B extends A {
p: string; // OK, string ~> any
@ -46,7 +48,7 @@ class B extends A {
* @flow
*/
import A from \"A\";
import A from \\"A\\";
class B extends A {
p: string; // OK, string ~> any
@ -54,7 +56,7 @@ class B extends A {
"
`;
exports[`test T.js 1`] = `
exports[`T.js 1`] = `
"/**
* @providesModule T
*/

View File

@ -1,4 +1,6 @@
exports[`test any.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`any.js 1`] = `
"// @flow
function foo(x:any):any { return x; }
@ -27,7 +29,7 @@ var z: string = qux(0);
"
`;
exports[`test anyexportflowfile.js 1`] = `
exports[`anyexportflowfile.js 1`] = `
"// @flow
module.exports = ((x: any) => x: any);
@ -38,7 +40,7 @@ module.exports = ((x: any) => x: any);
"
`;
exports[`test flowfixme.js 1`] = `
exports[`flowfixme.js 1`] = `
"/*
FlowFixMe is a synonym for any, used by the Flow team to
signal a needed mod to JS devs.
@ -89,7 +91,7 @@ var w: string = baz(0);
"
`;
exports[`test flowissue.js 1`] = `
exports[`flowissue.js 1`] = `
"/*
$FlowIssue is a synonym for any, used by JS devs to signal
a potential typechecker bug to the Flow team.
@ -140,7 +142,7 @@ var w: string = baz(0);
"
`;
exports[`test nonflowfile.js 1`] = `
exports[`nonflowfile.js 1`] = `
"// @noflow
module.exports = (x) => x;
@ -151,7 +153,7 @@ module.exports = x => x;
"
`;
exports[`test propagate.js 1`] = `
exports[`propagate.js 1`] = `
"// @flow
declare class C {
@ -164,14 +166,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);
@ -190,14 +192,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);
@ -206,7 +208,7 @@ function bar2(x: mixed) {
"
`;
exports[`test reach.js 1`] = `
exports[`reach.js 1`] = `
"/**
* like class and function values, any-typed values may be used in
* type annotations. Here we test propagation of any through the

View File

@ -1,4 +1,6 @@
exports[`test Arith.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Arith.js 1`] = `
"
/* @providesModule Arith */
@ -8,7 +10,7 @@ function str(x:string) { }
function foo() {
var x = 0;
var y = \"...\";
var y = \\"...\\";
var z = {};
num(x+x);
num(x+y); // error
@ -54,20 +56,20 @@ num(true + null); // === 1
num(undefined + true); // === NaN
num(true + undefined); // === NaN
str(\"foo\" + true); // error
str(true + \"foo\"); // error
str(\"foo\" + null); // error
str(null + \"foo\"); // error
str(\"foo\" + undefined); // error
str(undefined + \"foo\"); // error
str(\\"foo\\" + true); // error
str(true + \\"foo\\"); // error
str(\\"foo\\" + null); // error
str(null + \\"foo\\"); // error
str(\\"foo\\" + undefined); // error
str(undefined + \\"foo\\"); // error
let tests = [
function(x: mixed, y: mixed) {
(x + y); // error
(x + 0); // error
(0 + x); // error
(x + \"\"); // error
(\"\" + x); // error
(x + \\"\\"); // error
(\\"\\" + x); // error
(x + {}); // error
({} + x); // error
},
@ -78,8 +80,8 @@ let tests = [
function() {
((1 + {}): number); // error: object !~> number
(({} + 1): number); // error: object !~> number
((\"1\" + {}): string); // error: object !~> string
(({} + \"1\"): string); // error: object !~> string
((\\"1\\" + {}): string); // error: object !~> string
(({} + \\"1\\"): string); // error: object !~> string
},
function(x: any, y: number, z: string) {
@ -99,7 +101,7 @@ function str(x: string) {}
function foo() {
var x = 0;
var y = \"...\";
var y = \\"...\\";
var z = {};
num(x + x);
num(x + y); // error
@ -145,20 +147,20 @@ num(true + null); // === 1
num(undefined + true); // === NaN
num(true + undefined); // === NaN
str(\"foo\" + true); // error
str(true + \"foo\"); // error
str(\"foo\" + null); // error
str(null + \"foo\"); // error
str(\"foo\" + undefined); // error
str(undefined + \"foo\"); // error
str(\\"foo\\" + true); // error
str(true + \\"foo\\"); // error
str(\\"foo\\" + null); // error
str(null + \\"foo\\"); // error
str(\\"foo\\" + undefined); // error
str(undefined + \\"foo\\"); // error
let tests = [
function(x: mixed, y: mixed) {
x + y; // error
x + 0; // error
0 + x; // error
x + \"\"; // error
\"\" + x; // error
x + \\"\\"; // error
\\"\\" + x; // error
x + {}; // error
({}) + x; // error
},
@ -169,8 +171,8 @@ let tests = [
function() {
(1 + {}: number); // error: object !~> number
({} + 1: number); // error: object !~> number
(\"1\" + {}: string); // error: object !~> string
({} + \"1\": string); // error: object !~> string
(\\"1\\" + {}: string); // error: object !~> string
({} + \\"1\\": string); // error: object !~> string
},
function(x: any, y: number, z: string) {
@ -184,13 +186,13 @@ let tests = [
"
`;
exports[`test exponent.js 1`] = `
exports[`exponent.js 1`] = `
"/* @flow */
let x: number = 2 ** 3;
x **= 4;
let y: string = \"123\";
let y: string = \\"123\\";
y **= 2; // error
1 + 2 ** 3 + 4;
@ -202,7 +204,7 @@ y **= 2; // error
let x: number = 2 ** 3;
x **= 4;
let y: string = \"123\";
let y: string = \\"123\\";
y **= 2; // error
1 + 2 ** 3 + 4;
@ -211,7 +213,7 @@ y **= 2; // error
"
`;
exports[`test generic.js 1`] = `
exports[`generic.js 1`] = `
"/* @flow */
function f<A>(a: A): A { return a + a; } // error
@ -240,7 +242,7 @@ function f<A, B>(a: A, b: B): B {
"
`;
exports[`test mult.js 1`] = `
exports[`mult.js 1`] = `
"/* @flow */
function num(x:number) { }
@ -251,7 +253,7 @@ num(1 * null);
let x: number = 2 * 3;
x *= 4;
let y: string = \"123\";
let y: string = \\"123\\";
y *= 2; // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
@ -264,23 +266,23 @@ num(1 * null);
let x: number = 2 * 3;
x *= 4;
let y: string = \"123\";
let y: string = \\"123\\";
y *= 2; // error
"
`;
exports[`test relational.js 1`] = `
exports[`relational.js 1`] = `
"/* @flow */
(1 < 2);
(1 < \"foo\"); // error
(\"foo\" < 1); // error
(\"foo\" < \"bar\");
(1 < \\"foo\\"); // error
(\\"foo\\" < 1); // error
(\\"foo\\" < \\"bar\\");
(1 < {foo: 1}); // error
({foo: 1} < 1); // error
({foo: 1} < {foo: 1}); // error
(\"foo\" < {foo: 1}); // error
({foo: 1} < \"foo\"); // error
(\\"foo\\" < {foo: 1}); // error
({foo: 1} < \\"foo\\"); // error
var x = (null : ?number);
(1 < x); // 2 errors: null !~> number; undefined !~> number
@ -304,14 +306,14 @@ let tests = [
/* @flow */
1 < 2;
1 < \"foo\"; // error
\"foo\" < 1; // error
\"foo\" < \"bar\";
1 < \\"foo\\"; // error
\\"foo\\" < 1; // error
\\"foo\\" < \\"bar\\";
1 < { foo: 1 }; // error
({ foo: 1 }) < 1; // error
({ foo: 1 }) < { foo: 1 }; // error
\"foo\" < { foo: 1 }; // error
({ foo: 1 }) < \"foo\"; // error
\\"foo\\" < { foo: 1 }; // error
({ foo: 1 }) < \\"foo\\"; // error
var x = (null: ?number);
1 < x; // 2 errors: null !~> number; undefined !~> number

View File

@ -1,4 +1,6 @@
exports[`test test.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"/* @flow */
function filterOutVoids<T> (arr: Array<?T>): Array<T> {
@ -21,12 +23,12 @@ function filterOutSmall(arr: Array<?number>): Array<?number> {
"
`;
exports[`test test2.js 1`] = `
exports[`test2.js 1`] = `
"/* @flow */
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;
@ -34,7 +36,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);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -43,7 +45,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;
@ -52,7 +54,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);
"

View File

@ -1,12 +1,14 @@
exports[`test test.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"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];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var A = [1, 2, 3];
var B = [...A];
@ -14,7 +16,7 @@ var C = [1, 2, 3];
B.sort((a, b) => a - b);
C.sort((a, b) => a - b);
var x: Array<string> = [\"1\", \"2\"];
var y: Array<string> = [\"3\", ...x];
var x: Array<string> = [\\"1\\", \\"2\\"];
var y: Array<string> = [\\"3\\", ...x];
"
`;

View File

@ -1,25 +1,27 @@
exports[`test array_lib.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`array_lib.js 1`] = `
"/* @flow */
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 +46,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);
@ -63,7 +65,7 @@ function foo(x: string) {}
var a = [0];
var b = a.map(function(x) {
foo(x);
return \"\" + x;
return \\"\\" + x;
});
var c: number = a[0];
@ -71,18 +73,18 @@ 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:
@ -110,13 +112,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);

View File

@ -1,4 +1,6 @@
exports[`test Arrays.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Arrays.js 1`] = `
"
/* @providesModule Arrays */
@ -6,7 +8,7 @@ function foo(x:string) { }
var a = [];
a[0] = 1;
a[1] = \"...\";
a[1] = \\"...\\";
foo(a[1]);
var y;
@ -32,12 +34,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 */
@ -45,7 +47,7 @@ function foo(x: string) {}
var a = [];
a[0] = 1;
a[1] = \"...\";
a[1] = \\"...\\";
foo(a[1]);
var y;
@ -71,16 +73,16 @@ 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\\";
"
`;
exports[`test numeric_elem.js 1`] = `
exports[`numeric_elem.js 1`] = `
"var arr = [];
var day = new Date;

View File

@ -1,4 +1,6 @@
exports[`test advanced_arrows.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`advanced_arrows.js 1`] = `
"/**
* @flow
*/
@ -9,7 +11,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
@ -21,18 +23,18 @@ 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
"
`;
exports[`test arrows.js 1`] = `
exports[`arrows.js 1`] = `
"function selectBestEffortImageForWidth(
maxWidth: number,
images: Array<Image>
): 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];
}
@ -43,7 +45,7 @@ function selectBestEffortImageForWidth(
): 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];
}

View File

@ -1,8 +1,10 @@
exports[`test async.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`async.js 1`] = `
"// @flow
// \"For async functions, a Promise<T> is returned,
// and the type of return expressions must be T.\"
// \\"For async functions, a Promise<T> is returned,
// and the type of return expressions must be T.\\"
//
async function f0(): Promise<number> {
@ -27,7 +29,7 @@ async function f3(p: Promise<number>): Promise<number> {
}
// TODO: this is one of those bad generic errors, currently:
// \"inconsistent use of library definitions\" with two core.js locs
// \\"inconsistent use of library definitions\\" with two core.js locs
async function f4(p: Promise<number>): Promise<bool> {
return await p; // error, number != bool
}
@ -54,8 +56,8 @@ var objf : () => Promise<number> = obj.f;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow
// \"For async functions, a Promise<T> is returned,
// and the type of return expressions must be T.\"
// \\"For async functions, a Promise<T> is returned,
// and the type of return expressions must be T.\\"
//
async function f0(): Promise<number> {
@ -80,7 +82,7 @@ async function f3(p: Promise<number>): Promise<number> {
}
// TODO: this is one of those bad generic errors, currently:
// \"inconsistent use of library definitions\" with two core.js locs
// \\"inconsistent use of library definitions\\" with two core.js locs
async function f4(p: Promise<number>): Promise<boolean> {
return await p; // error, number != bool
}
@ -115,10 +117,10 @@ var objf: () => Promise<number> = obj.f;
"
`;
exports[`test async_base_class.js 1`] = `
exports[`async_base_class.js 1`] = `
"// This is kind of weird, but it should parse. This works in babel without the
// parens around (await promise). From the es6 and async/await specs I (nmote)
// am not clear on whether it should. In any case it\'s a strange corner case
// am not clear on whether it should. In any case it's a strange corner case
// that is probably not important to support.
class C {};
@ -133,7 +135,7 @@ async function foo() {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// This is kind of weird, but it should parse. This works in babel without the
// parens around (await promise). From the es6 and async/await specs I (nmote)
// am not clear on whether it should. In any case it\'s a strange corner case
// am not clear on whether it should. In any case it's a strange corner case
// that is probably not important to support.
class C {}
@ -148,7 +150,7 @@ async function foo() {
"
`;
exports[`test async_parse.js 1`] = `
exports[`async_parse.js 1`] = `
"async function f() {}
async function ft<T>(a: T) {}
@ -201,7 +203,7 @@ var y = { async };
"
`;
exports[`test async_promise.js 1`] = `
exports[`async_promise.js 1`] = `
"async function f(): Promise<number> {
return Promise.resolve(1);
}
@ -212,7 +214,7 @@ async function f(): Promise<number> {
"
`;
exports[`test async_return_void.js 1`] = `
exports[`async_return_void.js 1`] = `
"// @flow
async function foo1(): Promise<string> {
@ -245,7 +247,7 @@ async function foo3(): Promise<string> {
"
`;
exports[`test async2.js 1`] = `
exports[`async2.js 1`] = `
"// @flow
// misc basic
@ -272,7 +274,7 @@ function test1() {
function test2() {
async function voidoid1() {
console.log(\"HEY\");
console.log(\\"HEY\\");
}
var voidoid2: () => Promise<void> = voidoid1; // ok
@ -285,7 +287,7 @@ function test2() {
function test3() {
async function voidoid4(): Promise<void> { // ok
console.log(\"HEY\");
console.log(\\"HEY\\");
}
}
@ -296,14 +298,14 @@ function test3() {
function test4() {
async function voidoid5(): void { // error, void != Promise<void>
console.log(\"HEY\");
console.log(\\"HEY\\");
}
}
function test5() {
async function voidoid6()
: Promise<number> { // error, number != void
console.log(\"HEY\");
console.log(\\"HEY\\");
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -333,7 +335,7 @@ function test1() {
function test2() {
async function voidoid1() {
console.log(\"HEY\");
console.log(\\"HEY\\");
}
var voidoid2: () => Promise<void> = voidoid1; // ok
@ -347,7 +349,7 @@ function test2() {
function test3() {
async function voidoid4(): Promise<void> {
// ok
console.log(\"HEY\");
console.log(\\"HEY\\");
}
}
@ -359,27 +361,27 @@ function test3() {
function test4() {
async function voidoid5(): void {
// error, void != Promise<void>
console.log(\"HEY\");
console.log(\\"HEY\\");
}
}
function test5() {
async function voidoid6(): Promise<number> {
// error, number != void
console.log(\"HEY\");
console.log(\\"HEY\\");
}
}
"
`;
exports[`test async3.js 1`] = `
exports[`async3.js 1`] = `
"// @flow
/**
* test nested-promise unwrapping.
* Note: currently we don\'t do this properly in the underlying
* Note: currently we don't do this properly in the underlying
* type of the Promise class, which causes spurious errors to
* be raised here. Once that\'s fixed, the errors here will go
* be raised here. Once that's fixed, the errors here will go
* away.
*/
@ -410,9 +412,9 @@ async function baz() {
/**
* test nested-promise unwrapping.
* Note: currently we don\'t do this properly in the underlying
* Note: currently we don't do this properly in the underlying
* type of the Promise class, which causes spurious errors to
* be raised here. Once that\'s fixed, the errors here will go
* be raised here. Once that's fixed, the errors here will go
* away.
*/
@ -440,7 +442,7 @@ async function baz() {
"
`;
exports[`test await_parse.js 1`] = `
exports[`await_parse.js 1`] = `
"async function f() { await 1; }
async function ft<T>(a: T) { await 1; }

View File

@ -1,4 +1,6 @@
exports[`test delegate_yield.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`delegate_yield.js 1`] = `
"async function *delegate_next() {
async function *inner() {
var x: void = yield; // error: number ~> void
@ -55,7 +57,7 @@ async function* delegate_return() {
"
`;
exports[`test generator.js 1`] = `
exports[`generator.js 1`] = `
"declare interface File {
readLine(): Promise<string>;
close(): void;
@ -77,7 +79,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); // error: string ~> void
}
}
@ -103,23 +105,23 @@ 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
}
}
"
`;
exports[`test return.js 1`] = `
exports[`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 {
@ -128,7 +130,7 @@ 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
}
@ -136,13 +138,13 @@ refuse_return().return(\"string\").then(result => {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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 {
@ -151,7 +153,7 @@ 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
}
@ -159,7 +161,7 @@ refuse_return().return(\"string\").then(result => {
"
`;
exports[`test throw.js 1`] = `
exports[`throw.js 1`] = `
"async function *catch_return() {
try {
yield 0;
@ -169,7 +171,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
}
@ -186,7 +188,7 @@ async function *yield_return() {
}
(async () => {
yield_return().throw(\"\").then(({value}) => {
yield_return().throw(\\"\\").then(({value}) => {
if (value !== undefined) {
(value: void); // error: number ~> void
}
@ -202,7 +204,7 @@ async function* catch_return() {
}
(async () => {
catch_return().throw(\"\").then(({ value }) => {
catch_return().throw(\\"\\").then(({ value }) => {
if (value !== undefined) {
(value: void); // error: number ~> void
}
@ -219,7 +221,7 @@ async function* yield_return() {
}
(async () => {
yield_return().throw(\"\").then(({ value }) => {
yield_return().throw(\\"\\").then(({ value }) => {
if (value !== undefined) {
(value: void); // error: number ~> void
}

View File

@ -1,4 +1,6 @@
exports[`test customfun.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`customfun.js 1`] = `
"// @flow
declare var idx: $Facebookism$Idx;
@ -25,11 +27,11 @@ m;
"
`;
exports[`test unknown.js 1`] = `
exports[`unknown.js 1`] = `
"// @noflow
module.exports = { x: { y: \"\" } };
module.exports = { x: { y: \\"\\" } };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @noflow
module.exports = { x: { y: \"\" } };
module.exports = { x: { y: \\"\\" } };
"
`;

View File

@ -1,4 +1,6 @@
exports[`test client.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`client.js 1`] = `
"var y:number = x;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var y: number = x;

View File

@ -1,4 +1,6 @@
exports[`test lib.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`lib.js 1`] = `
"declare var x: string;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
declare var x: string;

View File

@ -1,34 +1,36 @@
exports[`test in.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`in.js 1`] = `
"// @flow
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 +44,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
},
]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -59,31 +61,31 @@ let tests = [
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
@ -97,18 +99,18 @@ let tests = [
// in predicates
function() {
if (\"foo\" in 123) {
if (\\"foo\\" in 123) {
} // error
if (!\"foo\" in {}) {
} // error, !\'foo\' is a boolean
if (!(\"foo\" in {})) {
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
}
];
"

View File

@ -1,4 +1,6 @@
exports[`test const.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`const.js 1`] = `
"const x = 0;
// errors: const cannot be reassigned
@ -17,8 +19,8 @@ x &= 0;
// regression tests -- OK to assign consts like this:
const { foo } = { foo: \"foo\" }
const [ bar ] = [\"bar\"];
const { foo } = { foo: \\"foo\\" }
const [ bar ] = [\\"bar\\"];
(foo: number); // error: string ~> number
(bar: number); // error: string ~> number
@ -45,8 +47,8 @@ x &= 0;
// regression tests -- OK to assign consts like this:
const { foo } = { foo: \"foo\" };
const [bar] = [\"bar\"];
const { foo } = { foo: \\"foo\\" };
const [bar] = [\\"bar\\"];
(foo: number); // error: string ~> number
(bar: number); // error: string ~> number
@ -57,7 +59,7 @@ for (const { baz } of bazzes) {
"
`;
exports[`test rebinding.js 1`] = `
exports[`rebinding.js 1`] = `
"/* @flow
* test errors on illegal rebinding/reassignment
*
@ -98,7 +100,7 @@ function type_var() {
function type_reassign() {
type A = number;
A = 42; // error: type alias ref\'d from value pos
A = 42; // error: type alias ref'd from value pos
}
// class x *
@ -296,7 +298,7 @@ function type_var() {
function type_reassign() {
type A = number;
A = 42; // error: type alias ref\'d from value pos
A = 42; // error: type alias ref'd from value pos
}
// class x *
@ -456,13 +458,13 @@ function fn_params_clash_fn_binding(x, y) {
"
`;
exports[`test scope.js 1`] = `
exports[`scope.js 1`] = `
"function block_scope() {
let a: number = 0;
var b: number = 0;
{
let a = \"\"; // ok: local to block
var b = \"\"; // error: string ~> number
let a = \\"\\"; // ok: local to block
var b = \\"\\"; // error: string ~> number
}
}
@ -470,12 +472,12 @@ function switch_scope(x: string) {
let a: number = 0;
var b: number = 0;
switch (x) {
case \"foo\":
let a = \"\"; // ok: local to switch
var b = \"\"; // error: string ~> number
case \\"foo\\":
let a = \\"\\"; // ok: local to switch
var b = \\"\\"; // error: string ~> number
break;
case \"bar\":
let a = \"\"; // error: a already bound in switch
case \\"bar\\":
let a = \\"\\"; // error: a already bound in switch
break;
}
}
@ -486,43 +488,43 @@ function switch_scope(x: string) {
function switch_scope2(x: number) {
switch (x) {
case 0:
a = \"\"; // error: assign before declaration
a = \\"\\"; // error: assign before declaration
break;
case 1:
var b = a; // error: use before declaration
break;
case 2:
let a = \"\";
let a = \\"\\";
break;
case 3:
a = \"\"; // error: skipped initializer
a = \\"\\"; // error: skipped initializer
break;
case 4:
var c:string = a; // error: skipped initializer
break;
}
a = \"\"; // error: a no longer in scope
a = \\"\\"; // error: a no longer in scope
}
function try_scope() {
let a: number = 0;
try {
let a = \"\"; // ok
let a = \\"\\"; // ok
} catch (e) {
let a = \"\"; // ok
let a = \\"\\"; // ok
} finally {
let a = \"\"; // ok
let a = \\"\\"; // ok
}
}
function for_scope_let() {
let a: number = 0;
for (let a = \"\" /* ok: local to init */;;) {}
for (let a = \\"\\" /* ok: local to init */;;) {}
}
function for_scope_var() {
var a: number = 0;
for (var a = \"\" /* error: string ~> number */;;) {}
for (var a = \\"\\" /* error: string ~> number */;;) {}
}
function for_in_scope_let(o: Object) {
@ -556,7 +558,7 @@ function default_param_1() {
function default_param_2() {
// fn body bindings not visible from param scope
let a = \"\";
let a = \\"\\";
function f0(x = () => a): number {
let a = 0;
return x(); // error: string ~> number
@ -571,8 +573,8 @@ function block_scope() {
let a: number = 0;
var b: number = 0;
{
let a = \"\"; // ok: local to block
var b = \"\"; // error: string ~> number
let a = \\"\\"; // ok: local to block
var b = \\"\\"; // error: string ~> number
}
}
@ -580,12 +582,12 @@ function switch_scope(x: string) {
let a: number = 0;
var b: number = 0;
switch (x) {
case \"foo\":
let a = \"\"; // ok: local to switch
var b = \"\"; // error: string ~> number
case \\"foo\\":
let a = \\"\\"; // ok: local to switch
var b = \\"\\"; // error: string ~> number
break;
case \"bar\":
let a = \"\"; // error: a already bound in switch
case \\"bar\\":
let a = \\"\\"; // error: a already bound in switch
break;
}
}
@ -596,44 +598,44 @@ function switch_scope(x: string) {
function switch_scope2(x: number) {
switch (x) {
case 0:
a = \"\"; // error: assign before declaration
a = \\"\\"; // error: assign before declaration
break;
case 1:
var b = a; // error: use before declaration
break;
case 2:
let a = \"\";
let a = \\"\\";
break;
case 3:
a = \"\"; // error: skipped initializer
a = \\"\\"; // error: skipped initializer
break;
case 4:
var c: string = a; // error: skipped initializer
break;
}
a = \"\"; // error: a no longer in scope
a = \\"\\"; // error: a no longer in scope
}
function try_scope() {
let a: number = 0;
try {
let a = \"\"; // ok
let a = \\"\\"; // ok
} catch (e) {
let a = \"\"; // ok
let a = \\"\\"; // ok
} finally {
let a = \"\"; // ok
let a = \\"\\"; // ok
}
}
function for_scope_let() {
let a: number = 0;
for (let a = \"\" /* ok: local to init */; ; ) {
for (let a = \\"\\" /* ok: local to init */; ; ) {
}
}
function for_scope_var() {
var a: number = 0;
for (var a = \"\" /* error: string ~> number */; ; ) {
for (var a = \\"\\" /* error: string ~> number */; ; ) {
}
}
@ -672,7 +674,7 @@ function default_param_1() {
function default_param_2() {
// fn body bindings not visible from param scope
let a = \"\";
let a = \\"\\";
function f0(x = () => a): number {
let a = 0;
return x(); // error: string ~> number
@ -685,7 +687,7 @@ function default_param_2() {
"
`;
exports[`test tdz.js 1`] = `
exports[`tdz.js 1`] = `
"/** @flow */
// -- types ---
@ -702,7 +704,7 @@ type T2 = number;
// while let is in TDZ.
// - allow forward refs to lets from type positions.
//
// currently we\'re too lenient about TDZ in closures -
// currently we're too lenient about TDZ in closures -
// from value positions, we currently enforce TDZ only in-scope.
// this is unsound - a let or const may remain uninitialized when
// a lambda runs. But a simple conservative approach would prohibit
@ -740,12 +742,12 @@ function f3() {
function foo() { return 0; }
}
var s2: string = foo(); // ok, hoisted outer not clobbered
function foo() { return \"\"; }
function foo() { return \\"\\"; }
}
// out-of-scope TDZ not enforced. sometimes right...
function f4() {
function g() { return x + c; } // ok, g doesn\'t run in TDZ
function g() { return x + c; } // ok, g doesn't run in TDZ
let x = 0;
const c = 0;
}
@ -753,7 +755,7 @@ function f4() {
// ...sometimes wrong
function f5() {
function g() { return x; }
g(); // should error, but doesn\'t currently
g(); // should error, but doesn't currently
let x = 0;
const c = 0;
}
@ -773,8 +775,8 @@ var z: C = new C(); // ok
// --- vars ---
// it\'s possible to annotate a var with a non-maybe type,
// but leave it uninitialized until later (as long as it\'s
// it's possible to annotate a var with a non-maybe type,
// but leave it uninitialized until later (as long as it's
// initialized before use)
var a: number; // not an error per se - only if used before init
@ -803,7 +805,7 @@ type T2 = number;
// while let is in TDZ.
// - allow forward refs to lets from type positions.
//
// currently we\'re too lenient about TDZ in closures -
// currently we're too lenient about TDZ in closures -
// from value positions, we currently enforce TDZ only in-scope.
// this is unsound - a let or const may remain uninitialized when
// a lambda runs. But a simple conservative approach would prohibit
@ -844,7 +846,7 @@ function f3() {
}
var s2: string = foo(); // ok, hoisted outer not clobbered
function foo() {
return \"\";
return \\"\\";
}
}
@ -852,7 +854,7 @@ function f3() {
function f4() {
function g() {
return x + c;
} // ok, g doesn\'t run in TDZ
} // ok, g doesn't run in TDZ
let x = 0;
const c = 0;
}
@ -862,7 +864,7 @@ function f5() {
function g() {
return x;
}
g(); // should error, but doesn\'t currently
g(); // should error, but doesn't currently
let x = 0;
const c = 0;
}
@ -882,8 +884,8 @@ var z: C = new C(); // ok
// --- vars ---
// it\'s possible to annotate a var with a non-maybe type,
// but leave it uninitialized until later (as long as it\'s
// it's possible to annotate a var with a non-maybe type,
// but leave it uninitialized until later (as long as it's
// initialized before use)
var a: number; // not an error per se - only if used before init

View File

@ -1,55 +1,57 @@
exports[`test FormData.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`FormData.js 1`] = `
"/* @flow */
// constructor
const a: FormData = new FormData(); // correct
new FormData(\'\'); // incorrect
new FormData(document.createElement(\'input\')); // incorrect
new FormData(document.createElement(\'form\')); // correct
new FormData(''); // incorrect
new FormData(document.createElement('input')); // incorrect
new FormData(document.createElement('form')); // correct
// has
const b: boolean = a.has(\'foo\'); // correct
const b: boolean = a.has('foo'); // correct
// get
const c: ?(string | File) = a.get(\'foo\'); // correct
const d: string = a.get(\'foo\'); // incorrect
const e: Blob = a.get(\'foo\'); // incorrect
const f: ?(string | File | Blob) = a.get(\'foo\'); // incorrect
const c: ?(string | File) = a.get('foo'); // correct
const d: string = a.get('foo'); // incorrect
const e: Blob = a.get('foo'); // incorrect
const f: ?(string | File | Blob) = a.get('foo'); // incorrect
a.get(2); // incorrect
// getAll
const a1: Array<string | File> = a.getAll(\'foo\'); // correct
const a2: Array<string | File | number> = a.getAll(\'foo\'); // incorrect
const a3: Array<string | Blob | File> = a.getAll(\'foo\'); // incorrect
const a1: Array<string | File> = a.getAll('foo'); // correct
const a2: Array<string | File | number> = a.getAll('foo'); // incorrect
const a3: Array<string | Blob | File> = a.getAll('foo'); // incorrect
a.getAll(23); // incorrect
// set
a.set(\'foo\', \'bar\'); // correct
a.set(\'foo\', {}); // incorrect
a.set(2, \'bar\'); // incorrect
a.set(\'foo\', \'bar\', \'baz\'); // incorrect
a.set(\'bar\', new File([], \'q\')) // correct
a.set(\'bar\', new File([], \'q\'), \'x\') // correct
a.set(\'bar\', new File([], \'q\'), 2) // incorrect
a.set(\'bar\', new Blob) // correct
a.set(\'bar\', new Blob, \'x\') // correct
a.set(\'bar\', new Blob, 2) // incorrect
a.set('foo', 'bar'); // correct
a.set('foo', {}); // incorrect
a.set(2, 'bar'); // incorrect
a.set('foo', 'bar', 'baz'); // incorrect
a.set('bar', new File([], 'q')) // correct
a.set('bar', new File([], 'q'), 'x') // correct
a.set('bar', new File([], 'q'), 2) // incorrect
a.set('bar', new Blob) // correct
a.set('bar', new Blob, 'x') // correct
a.set('bar', new Blob, 2) // incorrect
// append
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(\'bar\', new File([], \'q\')) // correct
a.append(\'bar\', new File([], \'q\'), \'x\') // correct
a.append(\'bar\', new File([], \'q\'), 2) // incorrect
a.append(\'bar\', new Blob) // correct
a.append(\'bar\', new Blob, \'x\') // correct
a.append(\'bar\', new Blob, 2) // incorrect
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('bar', new File([], 'q')) // correct
a.append('bar', new File([], 'q'), 'x') // correct
a.append('bar', new File([], 'q'), 2) // incorrect
a.append('bar', new Blob) // correct
a.append('bar', new Blob, 'x') // correct
a.append('bar', new Blob, 2) // incorrect
// delete
a.delete(\'xx\'); // correct
a.delete('xx'); // correct
a.delete(3); // incorrect
// keys
@ -71,53 +73,53 @@ for (let [x, y]: [number, number] of a.entries()) {} // incorrect
// constructor
const a: FormData = new FormData(); // correct
new FormData(\"\"); // incorrect
new FormData(document.createElement(\"input\")); // incorrect
new FormData(document.createElement(\"form\")); // correct
new FormData(\\"\\"); // incorrect
new FormData(document.createElement(\\"input\\")); // incorrect
new FormData(document.createElement(\\"form\\")); // correct
// has
const b: boolean = a.has(\"foo\"); // correct
const b: boolean = a.has(\\"foo\\"); // correct
// get
const c: ?(string | File) = a.get(\"foo\"); // correct
const d: string = a.get(\"foo\"); // incorrect
const e: Blob = a.get(\"foo\"); // incorrect
const f: ?(string | File | Blob) = a.get(\"foo\"); // incorrect
const c: ?(string | File) = a.get(\\"foo\\"); // correct
const d: string = a.get(\\"foo\\"); // incorrect
const e: Blob = a.get(\\"foo\\"); // incorrect
const f: ?(string | File | Blob) = a.get(\\"foo\\"); // incorrect
a.get(2); // incorrect
// getAll
const a1: Array<string | File> = a.getAll(\"foo\"); // correct
const a2: Array<string | File | number> = a.getAll(\"foo\"); // incorrect
const a3: Array<string | Blob | File> = a.getAll(\"foo\"); // incorrect
const a1: Array<string | File> = a.getAll(\\"foo\\"); // correct
const a2: Array<string | File | number> = a.getAll(\\"foo\\"); // incorrect
const a3: Array<string | Blob | File> = a.getAll(\\"foo\\"); // incorrect
a.getAll(23); // incorrect
// set
a.set(\"foo\", \"bar\"); // correct
a.set(\"foo\", {}); // incorrect
a.set(2, \"bar\"); // incorrect
a.set(\"foo\", \"bar\", \"baz\"); // incorrect
a.set(\"bar\", new File([], \"q\")); // correct
a.set(\"bar\", new File([], \"q\"), \"x\"); // correct
a.set(\"bar\", new File([], \"q\"), 2); // incorrect
a.set(\"bar\", new Blob()); // correct
a.set(\"bar\", new Blob(), \"x\"); // correct
a.set(\"bar\", new Blob(), 2); // incorrect
a.set(\\"foo\\", \\"bar\\"); // correct
a.set(\\"foo\\", {}); // incorrect
a.set(2, \\"bar\\"); // incorrect
a.set(\\"foo\\", \\"bar\\", \\"baz\\"); // incorrect
a.set(\\"bar\\", new File([], \\"q\\")); // correct
a.set(\\"bar\\", new File([], \\"q\\"), \\"x\\"); // correct
a.set(\\"bar\\", new File([], \\"q\\"), 2); // incorrect
a.set(\\"bar\\", new Blob()); // correct
a.set(\\"bar\\", new Blob(), \\"x\\"); // correct
a.set(\\"bar\\", new Blob(), 2); // incorrect
// append
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(\"bar\", new File([], \"q\")); // correct
a.append(\"bar\", new File([], \"q\"), \"x\"); // correct
a.append(\"bar\", new File([], \"q\"), 2); // incorrect
a.append(\"bar\", new Blob()); // correct
a.append(\"bar\", new Blob(), \"x\"); // correct
a.append(\"bar\", new Blob(), 2); // incorrect
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(\\"bar\\", new File([], \\"q\\")); // correct
a.append(\\"bar\\", new File([], \\"q\\"), \\"x\\"); // correct
a.append(\\"bar\\", new File([], \\"q\\"), 2); // incorrect
a.append(\\"bar\\", new Blob()); // correct
a.append(\\"bar\\", new Blob(), \\"x\\"); // correct
a.append(\\"bar\\", new Blob(), 2); // incorrect
// delete
a.delete(\"xx\"); // correct
a.delete(\\"xx\\"); // correct
a.delete(3); // incorrect
// keys
@ -146,7 +148,7 @@ for (let [x, y]: [number, number] of a.entries()) {
"
`;
exports[`test MutationObserver.js 1`] = `
exports[`MutationObserver.js 1`] = `
"/* @flow */
// constructor
@ -161,11 +163,11 @@ new MutationObserver(42); // incorrect
new MutationObserver((n: number) => {}); // incorrect
// observe
const div = document.createElement(\'div\');
o.observe(div, { attributes: true, attributeFilter: [\'style\'] }); // correct
const div = document.createElement('div');
o.observe(div, { attributes: true, attributeFilter: ['style'] }); // correct
o.observe(div, { characterData: true, invalid: true }); // correct
o.observe(); // incorrect
o.observe(\'invalid\'); // incorrect
o.observe('invalid'); // incorrect
o.observe(div); // incorrect
o.observe(div, {}); // incorrect
o.observe(div, { subtree: true }); // incorrect
@ -194,11 +196,11 @@ new MutationObserver(42); // incorrect
new MutationObserver((n: number) => {}); // incorrect
// observe
const div = document.createElement(\"div\");
o.observe(div, { attributes: true, attributeFilter: [\"style\"] }); // correct
const div = document.createElement(\\"div\\");
o.observe(div, { attributes: true, attributeFilter: [\\"style\\"] }); // correct
o.observe(div, { characterData: true, invalid: true }); // correct
o.observe(); // incorrect
o.observe(\"invalid\"); // incorrect
o.observe(\\"invalid\\"); // incorrect
o.observe(div); // incorrect
o.observe(div, {}); // incorrect
o.observe(div, { subtree: true }); // incorrect

View File

@ -1,11 +1,13 @@
exports[`test scope.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`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;
@ -13,7 +15,7 @@ function bar<X: number, Y: X>(x: X, y: Y): number {
"
`;
exports[`test test.js 1`] = `
exports[`test.js 1`] = `
"function foo<T: number>(x: T): T {
var _ = x * 1; // OK
var y: string = x; // error
@ -32,7 +34,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
@ -61,7 +63,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(); // error, since T = string is incompatible with number

View File

@ -1,9 +1,11 @@
exports[`test break.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`break.js 1`] = `
"function foo(b) {
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 +14,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 +29,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 +47,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 +56,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;
}
@ -73,7 +75,7 @@ function foo(b) {
var z;
while (b) {
if (x == null) {
z = \"\";
z = \\"\\";
break;
}
var y: number = x; // error: boolean !~> number
@ -84,10 +86,10 @@ function foo(b) {
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;
@ -99,10 +101,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
@ -118,7 +120,7 @@ function qux(b) {
while (b) {
var y: number = z;
if (b) {
z = \"\";
z = \\"\\";
continue;
} // error: string !~> number
z = 0;
@ -129,10 +131,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;
}

View File

@ -1,4 +1,6 @@
exports[`test test.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"var o = Object.freeze({ foo: 0 });
(o.foo: string);
module.exports = o;
@ -9,11 +11,11 @@ module.exports = o;
"
`;
exports[`test test2.js 1`] = `
"var o = require(\'./test\');
exports[`test2.js 1`] = `
"var o = require('./test');
(o.foo: string);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var o = require(\"./test\");
var o = require(\\"./test\\");
(o.foo: string);
"
`;

View File

@ -1,23 +1,25 @@
exports[`test array.js 1`] = `
"var a = [\"...\"];
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`array.js 1`] = `
"var a = [\\"...\\"];
var b = a.map (function (x) { return 0; });
var c: string = b[0]; // error: number !~> string
var array = [];
function f() {
array = array.map (function () { return \"...\"; });
array = array.map (function () { return \\"...\\"; });
var x:number = array[0]; // error: string !~> number
}
var Foo = require(\'./genericfoo\');
var Foo = require('./genericfoo');
var foo = new Foo();
function g() {
var foo1 = foo.map (function() { return \"...\"; });
var foo1 = foo.map (function() { return \\"...\\"; });
var x:number = foo1.get(); // error: string !~> number
foo = foo1;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var a = [\"...\"];
var a = [\\"...\\"];
var b = a.map(function(x) {
return 0;
});
@ -26,16 +28,16 @@ var c: string = b[0]; // error: number !~> string
var array = [];
function f() {
array = array.map(function() {
return \"...\";
return \\"...\\";
});
var x: number = array[0]; // error: string !~> number
}
var Foo = require(\"./genericfoo\");
var Foo = require(\\"./genericfoo\\");
var foo = new Foo();
function g() {
var foo1 = foo.map(function() {
return \"...\";
return \\"...\\";
});
var x: number = foo1.get(); // error: string !~> number
foo = foo1;
@ -43,7 +45,7 @@ function g() {
"
`;
exports[`test genericfoo.js 1`] = `
exports[`genericfoo.js 1`] = `
"class Foo<T> {
x:T;
self():Foo<T> { return this; }

View File

@ -1,4 +1,6 @@
exports[`test A.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`A.js 1`] = `
"// You should be able to call objects with call properties
function a(f: { (): string }, g: { (x: number): string } ): string {
return f() + g(123);
@ -11,7 +13,7 @@ function b(f: { (): string }): number {
// ...or if the param type is wrong
function c(f: { (x: number): number }): number {
return f(\"hello\");
return f(\\"hello\\");
}
// ...or if the arity is wrong
@ -42,7 +44,7 @@ function b(f: { (): string }): number {
// ...or if the param type is wrong
function c(f: { (x: number): number }): number {
return f(\"hello\");
return f(\\"hello\\");
}
// ...or if the arity is wrong
@ -63,66 +65,66 @@ function f(): number {
"
`;
exports[`test B.js 1`] = `
exports[`B.js 1`] = `
"// You should be able to use a function as an object with a call property
var a: { (x: number): string } = function (x: number): string { return \"hi\"; };
var a: { (x: number): string } = function (x: number): string { return \\"hi\\"; };
// ...and it should notice when the return type is wrong
var b: { (x: number): number } = function (x: number): string { return \"hi\"; };
var b: { (x: number): number } = function (x: number): string { return \\"hi\\"; };
// ...or if the param type is wrong
var c: { (x: string): string } = function (x: number): string { return \"hi\"; };
var c: { (x: string): string } = function (x: number): string { return \\"hi\\"; };
// ...or if the arity is wrong
var d: { (): string } = function (x: number): string { return \"hi\"; };
var d: { (): string } = function (x: number): string { return \\"hi\\"; };
// ...but subtyping rules still apply
var e: { (x: any): void } = function() { } // arity
var f: { (): mixed } = function(): string { return \"hi\" } // return type
var f: { (): mixed } = function(): string { return \\"hi\\" } // return type
var g: { (x: string): void } = function(x: mixed) { } // param type
// A function can be an object
var y : {} = function (x: number): string { return \"hi\"; };
var z : Object = function (x: number): string { return \"hi\"; };
var y : {} = function (x: number): string { return \\"hi\\"; };
var z : Object = function (x: number): string { return \\"hi\\"; };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// You should be able to use a function as an object with a call property
var a: { (x: number): string } = function(x: number): string {
return \"hi\";
return \\"hi\\";
};
// ...and it should notice when the return type is wrong
var b: { (x: number): number } = function(x: number): string {
return \"hi\";
return \\"hi\\";
};
// ...or if the param type is wrong
var c: { (x: string): string } = function(x: number): string {
return \"hi\";
return \\"hi\\";
};
// ...or if the arity is wrong
var d: { (): string } = function(x: number): string {
return \"hi\";
return \\"hi\\";
};
// ...but subtyping rules still apply
var e: { (x: any): void } = function() {}; // arity
var f: { (): mixed } = function(): string {
return \"hi\";
return \\"hi\\";
}; // return type
var g: { (x: string): void } = function(x: mixed) {}; // param type
// A function can be an object
var y: {} = function(x: number): string {
return \"hi\";
return \\"hi\\";
};
var z: Object = function(x: number): string {
return \"hi\";
return \\"hi\\";
};
"
`;
exports[`test C.js 1`] = `
exports[`C.js 1`] = `
"// You should be able to use an object as a function
function a(x: { (z: number): string }): (z: number) => string {
return x;
@ -143,7 +145,7 @@ function d(x: { (z: number): string }): () => string {
return x;
}
// ...or if it doesn\'t have a call property
// ...or if it doesn't have a call property
function e(x: {}): () => string {
return x;
}
@ -178,7 +180,7 @@ function d(x: { (z: number): string }): () => string {
return x;
}
// ...or if it doesn\'t have a call property
// ...or if it doesn't have a call property
function e(x: {}): () => string {
return x;
}
@ -195,7 +197,7 @@ function g(x: {}): Function {
"
`;
exports[`test D.js 1`] = `
exports[`D.js 1`] = `
"// Multiple call properties should also be supported
function a(f: { (): string; (x: number): string }): string {
return f() + f(123);
@ -203,11 +205,11 @@ function a(f: { (): string; (x: number): string }): string {
// It should be fine when a function satisfies them all
var b: { (): string; (x: number): string } =
function (x?: number): string { return \"hi\"; };
function (x?: number): string { return \\"hi\\"; };
// ...but should notice when a function doesn\'t satisfy them all
// ...but should notice when a function doesn't satisfy them all
var c: { (): string; (x: number): string } =
function (x: number): string { return \"hi\"; };
function (x: number): string { return \\"hi\\"; };
// Only one call property needs to match the function
function d(x: { (): string; (x: number): string }): () => string {
@ -226,12 +228,12 @@ function a(f: { (): string, (x: number): string }): string {
// It should be fine when a function satisfies them all
var b: { (): string, (x: number): string } = function(x?: number): string {
return \"hi\";
return \\"hi\\";
};
// ...but should notice when a function doesn\'t satisfy them all
// ...but should notice when a function doesn't satisfy them all
var c: { (): string, (x: number): string } = function(x: number): string {
return \"hi\";
return \\"hi\\";
};
// Only one call property needs to match the function
@ -246,8 +248,8 @@ function e(x: { (): string, (x: number): string }): () => number {
"
`;
exports[`test E.js 1`] = `
"// Expecting properties that don\'t exist should be an error
exports[`E.js 1`] = `
"// Expecting properties that don't exist should be an error
var a : { someProp: number } = function () {};
// Expecting properties that do exist should be fine
@ -258,7 +260,7 @@ var f = function () {};
f.myProp = 123;
var c : { myProp: number } = f;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Expecting properties that don\'t exist should be an error
// Expecting properties that don't exist should be an error
var a: { someProp: number } = function() {};
// Expecting properties that do exist should be fine
@ -271,51 +273,51 @@ var c: { myProp: number } = f;
"
`;
exports[`test F.js 1`] = `
exports[`F.js 1`] = `
"// You should be able to use an arrow function as an object with a call property
var a: { (x: number): string } = (x) => x.toString()
// ...and it should notice when the return type is wrong
var b: { (x: number): number } = (x) => \"hi\"
var b: { (x: number): number } = (x) => \\"hi\\"
// ...or if the param type is wrong
var c: { (x: string): string } = (x) => x.toFixed()
// ...or if the arity is wrong
var d: { (): string } = (x) => \"hi\"
var d: { (): string } = (x) => \\"hi\\"
// ...but subtyping rules still apply
var e: { (x: any): void } = () => { } // arity
var f: { (): mixed } = () => \"hi\" // return type
var f: { (): mixed } = () => \\"hi\\" // return type
var g: { (x: Date): void } = (x) => { x * 2 } // param type (date < number)
// A function can be an object
var y : {} = (x) => \"hi\"
var z : Object = (x) => \"hi\"
var y : {} = (x) => \\"hi\\"
var z : Object = (x) => \\"hi\\"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// You should be able to use an arrow function as an object with a call property
var a: { (x: number): string } = x => x.toString();
// ...and it should notice when the return type is wrong
var b: { (x: number): number } = x => \"hi\";
var b: { (x: number): number } = x => \\"hi\\";
// ...or if the param type is wrong
var c: { (x: string): string } = x => x.toFixed();
// ...or if the arity is wrong
var d: { (): string } = x => \"hi\";
var d: { (): string } = x => \\"hi\\";
// ...but subtyping rules still apply
var e: { (x: any): void } = () => {}; // arity
var f: { (): mixed } = () => \"hi\"; // return type
var f: { (): mixed } = () => \\"hi\\"; // return type
var g: { (x: Date): void } = x => {
x * 2;
}; // param type (date < number)
// A function can be an object
var y: {} = x => \"hi\";
var z: Object = x => \"hi\";
var y: {} = x => \\"hi\\";
var z: Object = x => \\"hi\\";
"
`;

View File

@ -1,4 +1,6 @@
exports[`test optional.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`optional.js 1`] = `
"type F = {
(x: string): number;
p?: string;
@ -23,7 +25,7 @@ function f(x) {
"
`;
exports[`test primitives.js 1`] = `
exports[`primitives.js 1`] = `
"var x = Boolean(4);
function foo(fn:(value:any)=>boolean) { }
foo(Boolean);

View File

@ -1,6 +1,8 @@
exports[`test not_flow.js 1`] = `
"1 * \'foo\';
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`not_flow.js 1`] = `
"1 * 'foo';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 * \"foo\";
1 * \\"foo\\";
"
`;

View File

@ -1,11 +1,13 @@
exports[`test with_munging.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`with_munging.js 1`] = `
"/**
* @flow
*/
class Foo {
_method(): string {
return \'this is private\';
return 'this is private';
}
}
@ -21,7 +23,7 @@ class Bar extends Foo {
class Foo {
_method(): string {
return \"this is private\";
return \\"this is private\\";
}
}
@ -33,7 +35,7 @@ class Bar extends Foo {
"
`;
exports[`test without_munging.js 1`] = `
exports[`without_munging.js 1`] = `
"/**
* @flow
* @preventMunge
@ -41,7 +43,7 @@ exports[`test without_munging.js 1`] = `
class Foo {
_method(): string {
return \'this is not private\';
return 'this is not private';
}
}
@ -58,7 +60,7 @@ class Bar extends Foo {
class Foo {
_method(): string {
return \"this is not private\";
return \\"this is not private\\";
}
}

View File

@ -1,4 +1,6 @@
exports[`test test.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"class A {
static x: number;
static y: string;
@ -12,9 +14,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
@ -74,9 +76,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

View File

@ -1,4 +1,6 @@
exports[`test test.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"/* @flow */
class A {}
class B {}
@ -13,9 +15,9 @@ module.exports = { A, B };
"
`;
exports[`test test2.js 1`] = `
exports[`test2.js 1`] = `
"/* @flow */
var I = require(\"./test.js\");
var I = require(\\"./test.js\\");
class C extends I.A {}
@ -23,7 +25,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 {}
@ -32,7 +34,7 @@ var y: I.B = new C();
"
`;
exports[`test test3.js 1`] = `
exports[`test3.js 1`] = `
"class A<X, Y, Z> {}
class B extends A<string, number, bool> {}
class C<X, Y, Z> extends B {}
@ -49,7 +51,7 @@ var a: A<string, number, Array<boolean>> = c; // the third type arg is incorrect
"
`;
exports[`test test4.js 1`] = `
exports[`test4.js 1`] = `
"class C<X> { x: X; }
function foo<X>(c: C<X>, x: X) { }

View File

@ -1,4 +1,6 @@
exports[`test test.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"class A { }
function foo(x: Class<A>): A {
return new x(); // OK
@ -25,7 +27,7 @@ function bar(x: Class<B>): B {
"
`;
exports[`test test2.js 1`] = `
exports[`test2.js 1`] = `
"// 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\`.

View File

@ -1,4 +1,6 @@
exports[`test A.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`A.js 1`] = `
"class A {
foo(x:number):void { }
}
@ -13,8 +15,8 @@ module.exports = A;
"
`;
exports[`test B.js 1`] = `
"var A = require(\'./A\');
exports[`B.js 1`] = `
"var A = require('./A');
class B extends A { }
@ -23,7 +25,7 @@ let b = new B();
module.exports = B;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var A = require(\"./A\");
var A = require(\\"./A\\");
class B extends A {}
@ -34,8 +36,8 @@ module.exports = B;
"
`;
exports[`test C.js 1`] = `
"var B = require(\'./B\');
exports[`C.js 1`] = `
"var B = require('./B');
class C extends B {
foo(x:string):void { }
@ -46,7 +48,7 @@ let c = new C();
module.exports = C;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var B = require(\"./B\");
var B = require(\\"./B\\");
class C extends B {
foo(x: string): void {}
@ -59,7 +61,7 @@ module.exports = C;
"
`;
exports[`test D.js 1`] = `
exports[`D.js 1`] = `
"class D { }
class E { }
new E().x
@ -70,14 +72,14 @@ new E().x;
"
`;
exports[`test class_shapes.js 1`] = `
exports[`class_shapes.js 1`] = `
"/* @flow */
type Foo = {
a: string; // exists in TestClass
b: string; // doesn\'t exist
b: string; // doesn't exist
c?: ?string; // exists in TestClass, optional
d?: number; // doesn\'t exist
d?: number; // doesn't exist
}
class TestClass {
@ -93,8 +95,8 @@ x.c; // ok
x.d; // error, TestClass has no d
var y : Foo = x;
y.b; // error, doesn\'t exist in TestClass
y.d; // ok, it\'s optional
y.b; // error, doesn't exist in TestClass
y.d; // ok, it's optional
class Test2Superclass {
a: number; // conflicts with cast to Foo
@ -111,9 +113,9 @@ var w : Foo = z;
type Foo = {
a: string, // exists in TestClass
b: string, // doesn\'t exist
b: string, // doesn't exist
c?: ?string, // exists in TestClass, optional
d?: number /* doesn\'t exist*/
d?: number /* doesn't exist*/
};
class TestClass {
@ -129,8 +131,8 @@ x.c; // ok
x.d; // error, TestClass has no d
var y: Foo = x;
y.b; // error, doesn\'t exist in TestClass
y.d; // ok, it\'s optional
y.b; // error, doesn't exist in TestClass
y.d; // ok, it's optional
class Test2Superclass {
a: number; // conflicts with cast to Foo
@ -145,7 +147,7 @@ var w: Foo = z;
"
`;
exports[`test expr.js 1`] = `
exports[`expr.js 1`] = `
"var Bar = class Foo {
static factory(): Foo { // OK: Foo is a type in this scope
return new Foo() // OK: Foo is a runtime binding in this scope
@ -155,7 +157,7 @@ exports[`test expr.js 1`] = `
var bar1: Bar = new Bar() // OK
var bar2: Bar = Bar.factory() // OK
// NB: Don\'t write expected errors using Foo to avoid error collapse hiding an
// NB: Don't write expected errors using Foo to avoid error collapse hiding an
// unexpected failure in the above code.
var B = class Baz { }
@ -187,7 +189,7 @@ var Bar = class Foo {
var bar1: Bar = new Bar(); // OK
var bar2: Bar = Bar.factory(); // OK
// NB: Don\'t write expected errors using Foo to avoid error collapse hiding an
// NB: Don't write expected errors using Foo to avoid error collapse hiding an
// unexpected failure in the above code.
var B = class Baz {};
@ -211,7 +213,7 @@ var alias2: Alias = _Alias.factory(); // error: bad pun
"
`;
exports[`test loc.js 1`] = `
exports[`loc.js 1`] = `
"/* @flow */
type Foo = number
@ -226,13 +228,13 @@ class Foo {} // error, shadows type Foo
"
`;
exports[`test statics.js 1`] = `
exports[`statics.js 1`] = `
"/* @flow */
class C {
static p: string;
}
C.p = \"hi\";
C.p = \\"hi\\";
// Class static fields are compatible with object types
(C: {p:string}); // ok
@ -246,7 +248,7 @@ declare var o: {p:number};
class C {
static p: string;
}
C.p = \"hi\";
C.p = \\"hi\\";
// Class static fields are compatible with object types
(C: { p: string }); // ok

View File

@ -1,4 +1,6 @@
exports[`test Closure.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Closure.js 1`] = `
"/***
* Test tracking of variable types across closure calls.
* @flow
@ -9,7 +11,7 @@ function takes_string(_:string) { }
// global write from function
//
var global_x = \"hello\";
var global_x = \\"hello\\";
function global_f() { }
function global_g() { global_x = 42; }
@ -20,14 +22,14 @@ takes_string(global_x); // ok
global_g();
takes_string(global_x); // error
global_x = 42; // shouldn\'t pollute linear refinement
global_x = 42; // shouldn't pollute linear refinement
// local write from function
//
function local_func() {
var local_x = \"hello\";
var local_x = \\"hello\\";
function local_f() { }
function local_g() { local_x = 42; }
@ -38,13 +40,13 @@ function local_func() {
local_g();
takes_string(local_x); // error
local_x = 42; // shouldn\'t pollute linear refinement
local_x = 42; // shouldn't pollute linear refinement
}
// global write from method
//
var global_y = \"hello\";
var global_y = \\"hello\\";
var global_o = {
f: function() { },
@ -57,14 +59,14 @@ takes_string(global_y); // ok
global_o.g();
takes_string(global_y); // error
global_y = 42; // shouldn\'t pollute linear refinement
global_y = 42; // shouldn't pollute linear refinement
// local write from method
//
function local_meth() {
var local_y = \"hello\";
var local_y = \\"hello\\";
var local_o = {
f: function() { },
@ -77,7 +79,7 @@ function local_meth() {
local_o.g();
takes_string(local_y); // error
local_y = 42; // shouldn\'t pollute linear refinement
local_y = 42; // shouldn't pollute linear refinement
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/***
@ -90,7 +92,7 @@ function takes_string(_: string) {}
// global write from function
//
var global_x = \"hello\";
var global_x = \\"hello\\";
function global_f() {}
function global_g() {
@ -103,13 +105,13 @@ takes_string(global_x); // ok
global_g();
takes_string(global_x); // error
global_x = 42; // shouldn\'t pollute linear refinement
global_x = 42; // shouldn't pollute linear refinement
// local write from function
//
function local_func() {
var local_x = \"hello\";
var local_x = \\"hello\\";
function local_f() {}
function local_g() {
@ -122,13 +124,13 @@ function local_func() {
local_g();
takes_string(local_x); // error
local_x = 42; // shouldn\'t pollute linear refinement
local_x = 42; // shouldn't pollute linear refinement
}
// global write from method
//
var global_y = \"hello\";
var global_y = \\"hello\\";
var global_o = {
f: function() {},
@ -143,13 +145,13 @@ takes_string(global_y); // ok
global_o.g();
takes_string(global_y); // error
global_y = 42; // shouldn\'t pollute linear refinement
global_y = 42; // shouldn't pollute linear refinement
// local write from method
//
function local_meth() {
var local_y = \"hello\";
var local_y = \\"hello\\";
var local_o = {
f: function() {},
@ -164,12 +166,12 @@ function local_meth() {
local_o.g();
takes_string(local_y); // error
local_y = 42; // shouldn\'t pollute linear refinement
local_y = 42; // shouldn't pollute linear refinement
}
"
`;
exports[`test cond_havoc.js 1`] = `
exports[`cond_havoc.js 1`] = `
"// @flow
// from sam, https://github.com/facebook/flow/issues/780
@ -177,7 +179,7 @@ exports[`test cond_havoc.js 1`] = `
//
function example(b: bool): number {
var x = 0;
function f() { x = \"\" }
function f() { x = \\"\\" }
if (b) {
f();
}
@ -192,7 +194,7 @@ function example(b: bool): number {
function example(b: boolean): number {
var x = 0;
function f() {
x = \"\";
x = \\"\\";
}
if (b) {
f();
@ -202,7 +204,7 @@ function example(b: boolean): number {
"
`;
exports[`test const.js 1`] = `
exports[`const.js 1`] = `
"/***
* consts retain refinements
* @flow
@ -215,7 +217,7 @@ function g(x: ?number) {
const const_x = x;
if (const_x) {
// ok: if const_x is truthy here, it\'s truthy everywhere
// ok: if const_x is truthy here, it's truthy everywhere
call_me = () => { var y:number = const_x; };
}
@ -230,20 +232,20 @@ function g(x: ?number) {
function h(x: number | string | boolean) {
const const_x = x;
if (typeof(const_x) == \"number\") {
if (typeof(const_x) == \\"number\\") {
call_me = () => { var y:number = const_x; }; // ok
} else if (typeof(const_x) == \"string\") {
} else if (typeof(const_x) == \\"string\\") {
call_me = () => { var y:string = const_x; }; // ok
} else if (typeof(const_x) == \"boolean\") {
} else if (typeof(const_x) == \\"boolean\\") {
call_me = () => { var y:boolean = const_x; }; // ok
}
var var_x = x;
if (typeof(var_x) == \"number\") {
if (typeof(var_x) == \\"number\\") {
call_me = () => { var y:number = var_x; }; // error
} else if (typeof(var_x) == \"string\") {
} else if (typeof(var_x) == \\"string\\") {
call_me = () => { var y:string = var_x; }; // error
} else if (typeof(var_x) == \"boolean\") {
} else if (typeof(var_x) == \\"boolean\\") {
call_me = () => { var y:boolean = var_x; }; // error
}
}
@ -262,7 +264,7 @@ var call_me: () => void = () => {};
function g(x: ?number) {
const const_x = x;
if (const_x) {
// ok: if const_x is truthy here, it\'s truthy everywhere
// ok: if const_x is truthy here, it's truthy everywhere
call_me = () => {
var y: number = const_x;
};
@ -280,30 +282,30 @@ function g(x: ?number) {
function h(x: number | string | boolean) {
const const_x = x;
if (typeof const_x == \"number\") {
if (typeof const_x == \\"number\\") {
call_me = () => {
var y: number = const_x;
}; // ok
} else if (typeof const_x == \"string\") {
} else if (typeof const_x == \\"string\\") {
call_me = () => {
var y: string = const_x;
}; // ok
} else if (typeof const_x == \"boolean\") {
} else if (typeof const_x == \\"boolean\\") {
call_me = () => {
var y: boolean = const_x;
}; // ok
}
var var_x = x;
if (typeof var_x == \"number\") {
if (typeof var_x == \\"number\\") {
call_me = () => {
var y: number = var_x;
}; // error
} else if (typeof var_x == \"string\") {
} else if (typeof var_x == \\"string\\") {
call_me = () => {
var y: string = var_x;
}; // error
} else if (typeof var_x == \"boolean\") {
} else if (typeof var_x == \\"boolean\\") {
call_me = () => {
var y: boolean = var_x;
}; // error

View File

@ -1,4 +1,6 @@
exports[`test Abs.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Abs.js 1`] = `
"
function f(x:string) { }
@ -10,13 +12,13 @@ module.exports = f;
"
`;
exports[`test Rel.js 1`] = `
exports[`Rel.js 1`] = `
"
var f = require(\'./Abs\');
var f = require('./Abs');
f(0);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var f = require(\"./Abs\");
var f = require(\\"./Abs\\");
f(0);
"

View File

@ -1,14 +1,16 @@
exports[`test test.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`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,22 +19,22 @@ var ColorIdToNumber = {
[ColorId.BLUE]: ColorNumber.BLUE,
};
(ColorIdToNumber[ColorId.RED]: \'ffffff\'); // oops
(ColorIdToNumber[ColorId.RED]: 'ffffff'); // oops
ColorIdToNumber.XXX; // oops
module.exports = { ColorId, ColorNumber };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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 = {
@ -41,7 +43,7 @@ var ColorIdToNumber = {
[ColorId.BLUE]: ColorNumber.BLUE
};
(ColorIdToNumber[ColorId.RED]: \"ffffff\"); // oops
(ColorIdToNumber[ColorId.RED]: \\"ffffff\\"); // oops
ColorIdToNumber.XXX; // oops
@ -49,82 +51,82 @@ module.exports = { ColorId, ColorNumber };
"
`;
exports[`test test2.js 1`] = `
"var { ColorId, ColorNumber } = require(\'./test\');
exports[`test2.js 1`] = `
"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;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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;
"
`;
exports[`test test3.js 1`] = `
"var { ColorId } = require(\'./test\');
var ColorIdToNumber = require(\'./test2\');
exports[`test3.js 1`] = `
"var { ColorId } = require('./test');
var ColorIdToNumber = require('./test2');
(ColorIdToNumber[ColorId.BLUE]: \'ffffff\'); // oops
(ColorIdToNumber[ColorId.BLUE]: 'ffffff'); // oops
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
"
`;
exports[`test test4.js 1`] = `
"module.exports = \'hello\';
exports[`test4.js 1`] = `
"module.exports = 'hello';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
module.exports = \"hello\";
module.exports = \\"hello\\";
"
`;
exports[`test test5.js 1`] = `
"var hello = require(\'./test4\');
var dummy = require(\'./test\');
exports[`test5.js 1`] = `
"var hello = require('./test4');
var dummy = require('./test');
module.exports = {
...dummy,
[hello]: \'world\',
[hello]: 'world',
...dummy,
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var hello = require(\"./test4\");
var dummy = require(\"./test\");
var hello = require(\\"./test4\\");
var dummy = require(\\"./test\\");
module.exports = {
...dummy,
[hello]: \"world\",
[hello]: \\"world\\",
...dummy
};
"
`;
exports[`test test6.js 1`] = `
"var o = require(\'./test5\');
(o.hello: \'nothing\'); // oops
exports[`test6.js 1`] = `
"var o = require('./test5');
(o.hello: 'nothing'); // oops
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var o = require(\"./test5\");
(o.hello: \"nothing\"); // oops
var o = require(\\"./test5\\");
(o.hello: \\"nothing\\"); // oops
"
`;
exports[`test test7.js 1`] = `
exports[`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
@ -135,7 +137,7 @@ var obj = {
return this.x;
}
};
var x: string = obj[\"m\"](); // error, number ~> string
var x: string = obj[\\"m\\"](); // error, number ~> string
var arr = [
function() {

View File

@ -1,4 +1,6 @@
exports[`test conditional.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`conditional.js 1`] = `
"/* @flow */
function a(): number {

View File

@ -1,6 +1,8 @@
exports[`test no_at_flow.js 1`] = `
"var x: number = \"not a number\"; // Error: string ~> number
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`no_at_flow.js 1`] = `
"var x: number = \\"not a number\\"; // Error: string ~> number
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var x: number = \"not a number\"; // Error: string ~> number
var x: number = \\"not a number\\"; // Error: string ~> number
"
`;

View File

@ -1,6 +1,8 @@
exports[`test no_at_flow.js 1`] = `
"var x: number = \"not a number\"; // No error
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`no_at_flow.js 1`] = `
"var x: number = \\"not a number\\"; // No error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var x: number = \"not a number\"; // No error
var x: number = \\"not a number\\"; // No error
"
`;

View File

@ -1,4 +1,6 @@
exports[`test no_at_flow.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`no_at_flow.js 1`] = `
"var x;
x.length;

View File

@ -1,26 +1,28 @@
exports[`test test.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"/*
* @flow
*/
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
*/
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!\\");
"
`;

View File

@ -1,12 +1,14 @@
exports[`test foo.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`foo.js 1`] = `
"/* @flow */
// No error, this file is ignored
var x: number = \"string\";
var x: number = \\"string\\";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
// No error, this file is ignored
var x: number = \"string\";
var x: number = \\"string\\";
"
`;

View File

@ -1,10 +1,12 @@
exports[`test foo.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`foo.js 1`] = `
"/* @flow */
var x: number = \"string\"; // Error string ~> number
var x: number = \\"string\\"; // Error string ~> number
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
var x: number = \"string\"; // Error string ~> number
var x: number = \\"string\\"; // Error string ~> number
"
`;

View File

@ -1,14 +1,16 @@
exports[`test main.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`main.js 1`] = `
"// @flow
import {test} from \'testmodule\';
import {test} from 'testmodule';
var a: number = test;
var b: string = test; // Error: number ~> string
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow
import { test } from \"testmodule\";
import { test } from \\"testmodule\\";
var a: number = test;
var b: string = test; // Error: number ~> string

View File

@ -1,4 +1,6 @@
exports[`test testmodule.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`testmodule.js 1`] = `
"// @flow
export let test = 42;

View File

@ -1,12 +1,14 @@
exports[`test test.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"// @flow
import {className} from \"./SomeCSSFile.css\";
import {doesntExist} from \"./SomeCSSFile.css\"; // Error: \`doestExist\` isn\'t an export
import {className} from \\"./SomeCSSFile.css\\";
import {doesntExist} from \\"./SomeCSSFile.css\\"; // Error: \`doestExist\` isn't an export
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow
import { className } from \"./SomeCSSFile.css\";
import { doesntExist } from \"./SomeCSSFile.css\"; // Error: \`doestExist\` isn\'t an export
import { className } from \\"./SomeCSSFile.css\\";
import { doesntExist } from \\"./SomeCSSFile.css\\"; // Error: \`doestExist\` isn't an export
"
`;

View File

@ -1,35 +1,37 @@
exports[`test A.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`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 */
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
"
`;
exports[`test Exists.js 1`] = `
exports[`Exists.js 1`] = `
"/**
* @providesModule Exists
* @flow

View File

@ -1,59 +1,61 @@
exports[`test A.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @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
"
`;
exports[`test Exists.js 1`] = `
exports[`Exists.js 1`] = `
"/* @flow */
module.exports = {

View File

@ -1,16 +1,18 @@
exports[`test toplevel.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`toplevel.js 1`] = `
"// @flow
import {name} from \"testproj\";
import {name} from \\"testproj\\";
(name: \"node_modules/testproj\");
(name: \"custom_resolve_dir/testproj\"); // Error: Resolve from node_modules first!
(name: \\"node_modules/testproj\\");
(name: \\"custom_resolve_dir/testproj\\"); // Error: Resolve from node_modules first!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow
import { name } from \"testproj\";
import { name } from \\"testproj\\";
(name: \"node_modules/testproj\");
(name: \"custom_resolve_dir/testproj\"); // Error: Resolve from node_modules first!
(name: \\"node_modules/testproj\\");
(name: \\"custom_resolve_dir/testproj\\"); // Error: Resolve from node_modules first!
"
`;

View File

@ -1,10 +1,12 @@
exports[`test index.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`index.js 1`] = `
"// @flow
export var name: \"otherdir/testproj\" = \"otherdir/testproj\";
export var name: \\"otherdir/testproj\\" = \\"otherdir/testproj\\";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow
export var name: \"otherdir/testproj\" = \"otherdir/testproj\";
export var name: \\"otherdir/testproj\\" = \\"otherdir/testproj\\";
"
`;

View File

@ -1,10 +1,12 @@
exports[`test index.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`index.js 1`] = `
"// @flow
export var name: \"otherdir/testproj2\" = \"otherdir/testproj2\";
export var name: \\"otherdir/testproj2\\" = \\"otherdir/testproj2\\";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow
export var name: \"otherdir/testproj2\" = \"otherdir/testproj2\";
export var name: \\"otherdir/testproj2\\" = \\"otherdir/testproj2\\";
"
`;

View File

@ -1,16 +1,18 @@
exports[`test sublevel.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`sublevel.js 1`] = `
"// @flow
import {name} from \"testproj2\";
import {name} from \\"testproj2\\";
(name: \"node_modules/testproj2\"); // Error: Resolve from sibling \'custom_resolve_dir\' first!
(name: \"subdir/custom_resolve_dir/testproj2\");
(name: \\"node_modules/testproj2\\"); // Error: Resolve from sibling 'custom_resolve_dir' first!
(name: \\"subdir/custom_resolve_dir/testproj2\\");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow
import { name } from \"testproj2\";
import { name } from \\"testproj2\\";
(name: \"node_modules/testproj2\"); // Error: Resolve from sibling \'custom_resolve_dir\' first!
(name: \"subdir/custom_resolve_dir/testproj2\");
(name: \\"node_modules/testproj2\\"); // Error: Resolve from sibling 'custom_resolve_dir' first!
(name: \\"subdir/custom_resolve_dir/testproj2\\");
"
`;

View File

@ -1,10 +1,12 @@
exports[`test index.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`index.js 1`] = `
"// @flow
export var name: \"subdir/custom_resolve_dir/testproj2\" = \"subdir/custom_resolve_dir/testproj2\";
export var name: \\"subdir/custom_resolve_dir/testproj2\\" = \\"subdir/custom_resolve_dir/testproj2\\";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow
export var name: \"subdir/custom_resolve_dir/testproj2\" = \"subdir/custom_resolve_dir/testproj2\";
export var name: \\"subdir/custom_resolve_dir/testproj2\\" = \\"subdir/custom_resolve_dir/testproj2\\";
"
`;

View File

@ -1,4 +1,6 @@
exports[`test chain.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`chain.js 1`] = `
"/* @flow */
class A {
@ -12,7 +14,7 @@ class A {
return 1;
}
static _sMethod(): string {
return \"some string\";
return \\"some string\\";
}
}
A._sProperty = 48;
@ -23,16 +25,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 */
@ -47,7 +49,7 @@ class A {
return 1;
}
static _sMethod(): string {
return \"some string\";
return \\"some string\\";
}
}
A._sProperty = 48;
@ -58,20 +60,20 @@ 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\\";
"
`;
exports[`test commonjs_export.js 1`] = `
exports[`commonjs_export.js 1`] = `
"/* @flow */
class C {
@ -90,13 +92,13 @@ module.exports = new C();
"
`;
exports[`test commonjs_import.js 1`] = `
exports[`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\\";
"
`;

View File

@ -1,4 +1,6 @@
exports[`test chain.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`chain.js 1`] = `
"/* @flow */
class A {
@ -12,7 +14,7 @@ class A {
return 1;
}
static _sMethod(): string {
return \"some string\";
return \\"some string\\";
}
}
A._sProperty = 48;
@ -23,16 +25,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 */
@ -47,7 +49,7 @@ class A {
return 1;
}
static _sMethod(): string {
return \"some string\";
return \\"some string\\";
}
}
A._sProperty = 48;
@ -58,15 +60,15 @@ 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\\";
"
`;

View File

@ -1,4 +1,6 @@
exports[`test test.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"/**
* test handling of const params
* - reassignment prohibited
@ -15,16 +17,16 @@ exports[`test test.js 1`] = `
*/
function cannot_reassign(x: string) {
x = \"hey\"; // error, const param cannot be reassigned
x = \\"hey\\"; // error, const param cannot be reassigned
}
// Note: const params use the same machinery as explicit
// const bindings, which are tested more extensively elsewhere.
// Here we\'re just making sure the machinery is hooked up.
// Here we're just making sure the machinery is hooked up.
//
function durable_refi(x: ?number) {
if (x) {
// ok: if x is truthy here, it\'s truthy everywhere
// ok: if x is truthy here, it's truthy everywhere
return () => { var y:number = x; };
}
}
@ -45,16 +47,16 @@ function durable_refi(x: ?number) {
*/
function cannot_reassign(x: string) {
x = \"hey\"; // error, const param cannot be reassigned
x = \\"hey\\"; // error, const param cannot be reassigned
}
// Note: const params use the same machinery as explicit
// const bindings, which are tested more extensively elsewhere.
// Here we\'re just making sure the machinery is hooked up.
// Here we're just making sure the machinery is hooked up.
//
function durable_refi(x: ?number) {
if (x) {
// ok: if x is truthy here, it\'s truthy everywhere
// ok: if x is truthy here, it's truthy everywhere
return () => {
var y: number = x;
};

View File

@ -1,4 +1,6 @@
exports[`test constructor.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`constructor.js 1`] = `
"class C {
constructor() { }
}

View File

@ -1,4 +1,6 @@
exports[`test constructors.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`constructors.js 1`] = `
"// Foo is a class-like function
function Foo() {
this.x = 0; // constructs objects with property x
@ -6,8 +8,8 @@ function Foo() {
Foo.y = 0; // has static property y
Foo.prototype = { m() { return 0; } };
// exporting Foo directly doesn\'t work
// Foo\'s instance and static props are not picked up
// exporting Foo directly doesn't work
// Foo's instance and static props are not picked up
exports.Foo = Foo;
// so you want to type Foo, by declaring it as a class
@ -32,8 +34,8 @@ Foo.prototype = {
}
};
// exporting Foo directly doesn\'t work
// Foo\'s instance and static props are not picked up
// exporting Foo directly doesn't work
// Foo's instance and static props are not picked up
exports.Foo = Foo;
// so you want to type Foo, by declaring it as a class
@ -49,23 +51,23 @@ exports.Foo2 = (Foo: Class<IFoo>);
"
`;
exports[`test test.js 1`] = `
"var Foo = require(\'./constructors\').Foo;
exports[`test.js 1`] = `
"var Foo = require('./constructors').Foo;
var x: string = new Foo().x; // error, found number instead of string
var y: string = Foo.y; // error, found number instead of string
var z: string = new Foo().m();
var Foo2 = require(\'./constructors\').Foo2;
var Foo2 = require('./constructors').Foo2;
var x2: string = new Foo2().x; // error, found boolean instead of string
var y2: string = Foo2.y; // error, found boolean instead of string
var z2: string = new Foo2().m();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var Foo = require(\"./constructors\").Foo;
var Foo = require(\\"./constructors\\").Foo;
var x: string = new Foo().x; // error, found number instead of string
var y: string = Foo.y; // error, found number instead of string
var z: string = new Foo().m();
var Foo2 = require(\"./constructors\").Foo2;
var Foo2 = require(\\"./constructors\\").Foo2;
var x2: string = new Foo2().x; // error, found boolean instead of string
var y2: string = Foo2.y; // error, found boolean instead of string
var z2: string = new Foo2().m();

View File

@ -1,14 +1,16 @@
exports[`test dummy.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`dummy.js 1`] = `
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"
`;
exports[`test test.js 1`] = `
"require(\'./dummy\');
exports[`test.js 1`] = `
"require('./dummy');
var xxx = 0;
xxx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
require(\"./dummy\");
require(\\"./dummy\\");
var xxx = 0;
xxx;
"

View File

@ -1,14 +1,16 @@
exports[`test dummy.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`dummy.js 1`] = `
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"
`;
exports[`test test.js 1`] = `
"require(\'./dummy\');
exports[`test.js 1`] = `
"require('./dummy');
var xxx = 0;
xxx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
require(\"./dummy\");
require(\\"./dummy\\");
var xxx = 0;
xxx;
"

View File

@ -1,4 +1,6 @@
exports[`test boolean.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`boolean.js 1`] = `
"// @flow
// Boolean (the class) tests. booleans (the literals) are not part of core.js
@ -13,7 +15,7 @@ let tests = [
new Boolean(false);
new Boolean(NaN);
new Boolean(undefined);
new Boolean(\"\");
new Boolean(\\"\\");
},
// toString
@ -38,7 +40,7 @@ let tests = [
Boolean(false);
Boolean(NaN);
Boolean(undefined);
Boolean(\"\");
Boolean(\\"\\");
},
];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -56,7 +58,7 @@ let tests = [
new Boolean(false);
new Boolean(NaN);
new Boolean(undefined);
new Boolean(\"\");
new Boolean(\\"\\");
},
// toString
@ -81,18 +83,18 @@ let tests = [
Boolean(false);
Boolean(NaN);
Boolean(undefined);
Boolean(\"\");
Boolean(\\"\\");
}
];
"
`;
exports[`test map.js 1`] = `
exports[`map.js 1`] = `
"// @flow
function* generator(): Iterable<[string, number]> {
while (true) {
yield [\'foo\', 123];
yield ['foo', 123];
}
}
@ -101,22 +103,22 @@ let tests = [
function() {
let w = new Map();
let x = new Map(null);
let y = new Map([[\'foo\', 123]]);
let y = new Map([['foo', 123]]);
let z = new Map(generator());
let a: Map<string, number> = new Map();
let b: Map<string, number> = new Map([[\'foo\', 123]]);
let b: Map<string, number> = new Map([['foo', 123]]);
let c: Map<string, number> = new Map(generator());
},
// bad constructors
function() {
let x = new Map([\'foo\', 123]); // error
let y: Map<number, string> = new Map([[\'foo\', 123]]); // error
let x = new Map(['foo', 123]); // error
let y: Map<number, string> = new Map([['foo', 123]]); // error
},
// get()
function(x: Map<string, number>) {
(x.get(\'foo\'): boolean); // error, string | void
(x.get('foo'): boolean); // error, string | void
x.get(123); // error, wrong key type
},
];
@ -125,7 +127,7 @@ let tests = [
function* generator(): Iterable<[string, number]> {
while (true) {
yield [\"foo\", 123];
yield [\\"foo\\", 123];
}
}
@ -134,56 +136,56 @@ let tests = [
function() {
let w = new Map();
let x = new Map(null);
let y = new Map([[\"foo\", 123]]);
let y = new Map([[\\"foo\\", 123]]);
let z = new Map(generator());
let a: Map<string, number> = new Map();
let b: Map<string, number> = new Map([[\"foo\", 123]]);
let b: Map<string, number> = new Map([[\\"foo\\", 123]]);
let c: Map<string, number> = new Map(generator());
},
// bad constructors
function() {
let x = new Map([\"foo\", 123]); // error
let y: Map<number, string> = new Map([[\"foo\", 123]]); // error
let x = new Map([\\"foo\\", 123]); // error
let y: Map<number, string> = new Map([[\\"foo\\", 123]]); // error
},
// get()
function(x: Map<string, number>) {
(x.get(\"foo\"): boolean); // error, string | void
(x.get(\\"foo\\"): boolean); // error, string | void
x.get(123); // error, wrong key type
}
];
"
`;
exports[`test regexp.js 1`] = `
exports[`regexp.js 1`] = `
"// @flow
let tests = [
// constructor
function() {
new RegExp(\'foo\');
new RegExp('foo');
new RegExp(/foo/);
new RegExp(\'foo\', \'i\');
new RegExp(\'foo\', \'ig\');
new RegExp(/foo/, \'i\'); // invalid in ES5, valid in ES6
new RegExp(/foo/g, \'i\'); // invalid in ES5, valid in ES6
new RegExp('foo', 'i');
new RegExp('foo', 'ig');
new RegExp(/foo/, 'i'); // invalid in ES5, valid in ES6
new RegExp(/foo/g, 'i'); // invalid in ES5, valid in ES6
},
// called as a function (equivalent to the constructor per ES6 21.2.3)
function() {
RegExp(\'foo\');
RegExp('foo');
RegExp(/foo/);
RegExp(\'foo\', \'i\');
RegExp(\'foo\', \'ig\');
RegExp(/foo/, \'i\'); // invalid in ES5, valid in ES6
RegExp(/foo/g, \'i\'); // invalid in ES5, valid in ES6
RegExp('foo', 'i');
RegExp('foo', 'ig');
RegExp(/foo/, 'i'); // invalid in ES5, valid in ES6
RegExp(/foo/g, 'i'); // invalid in ES5, valid in ES6
},
// invalid flags
function() {
RegExp(\'foo\', \'z\'); // error
new RegExp(\'foo\', \'z\'); // error
RegExp('foo', 'z'); // error
new RegExp('foo', 'z'); // error
}
];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -192,39 +194,39 @@ let tests = [
let tests = [
// constructor
function() {
new RegExp(\"foo\");
new RegExp(\\"foo\\");
new RegExp(/foo/);
new RegExp(\"foo\", \"i\");
new RegExp(\"foo\", \"ig\");
new RegExp(/foo/, \"i\"); // invalid in ES5, valid in ES6
new RegExp(/foo/g, \"i\"); // invalid in ES5, valid in ES6
new RegExp(\\"foo\\", \\"i\\");
new RegExp(\\"foo\\", \\"ig\\");
new RegExp(/foo/, \\"i\\"); // invalid in ES5, valid in ES6
new RegExp(/foo/g, \\"i\\"); // invalid in ES5, valid in ES6
},
// called as a function (equivalent to the constructor per ES6 21.2.3)
function() {
RegExp(\"foo\");
RegExp(\\"foo\\");
RegExp(/foo/);
RegExp(\"foo\", \"i\");
RegExp(\"foo\", \"ig\");
RegExp(/foo/, \"i\"); // invalid in ES5, valid in ES6
RegExp(/foo/g, \"i\"); // invalid in ES5, valid in ES6
RegExp(\\"foo\\", \\"i\\");
RegExp(\\"foo\\", \\"ig\\");
RegExp(/foo/, \\"i\\"); // invalid in ES5, valid in ES6
RegExp(/foo/g, \\"i\\"); // invalid in ES5, valid in ES6
},
// invalid flags
function() {
RegExp(\"foo\", \"z\"); // error
new RegExp(\"foo\", \"z\"); // error
RegExp(\\"foo\\", \\"z\\"); // error
new RegExp(\\"foo\\", \\"z\\"); // error
}
];
"
`;
exports[`test weakset.js 1`] = `
exports[`weakset.js 1`] = `
"// @flow
let ws = new WeakSet();
let obj: Object = {};
let dict: {foo: string} = {foo: \'bar\'};
let dict: {foo: string} = {foo: 'bar'};
ws.add(window);
ws.add(obj);
@ -242,7 +244,7 @@ let ws3 = new WeakSet([1, 2, 3]); // error, must be objects
function* generator(): Iterable<{foo: string}> {
while (true) {
yield {foo: \'bar\'};
yield {foo: 'bar'};
}
}
@ -261,7 +263,7 @@ let ws5 = new WeakSet(numbers()); // error, must be objects
let ws = new WeakSet();
let obj: Object = {};
let dict: { foo: string } = { foo: \"bar\" };
let dict: { foo: string } = { foo: \\"bar\\" };
ws.add(window);
ws.add(obj);
@ -279,7 +281,7 @@ let ws3 = new WeakSet([1, 2, 3]); // error, must be objects
function* generator(): Iterable<{ foo: string }> {
while (true) {
yield { foo: \"bar\" };
yield { foo: \\"bar\\" };
}
}

View File

@ -1,8 +1,10 @@
exports[`test test.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`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 +24,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>;
@ -52,7 +54,7 @@ n.x = [0];
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>;
@ -74,12 +76,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>;

View File

@ -1,5 +1,7 @@
exports[`test crash.js 1`] = `
"// This file triggers a violation of the \"disjoint-or-nested ranges invariant\"
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`crash.js 1`] = `
"// 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.
@ -15,7 +17,7 @@ declare module foo {
}
// 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.
@ -24,7 +26,7 @@ declare module bar {
"
`;
exports[`test declare_module.js 1`] = `
exports[`declare_module.js 1`] = `
"// check coverage of declare module
declare module foo {
@ -37,7 +39,7 @@ declare module foo {
"
`;
exports[`test no_pragma.js 1`] = `
exports[`no_pragma.js 1`] = `
"let x = 0;
(x: string);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -46,8 +48,8 @@ let x = 0;
"
`;
exports[`test non-termination.js 1`] = `
"// This file triggers a violation of the \"disjoint-or-nested ranges invariant\"
exports[`non-termination.js 1`] = `
"// 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.
@ -64,7 +66,7 @@ declare class qux {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
declare module foo {
}
// 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.

View File

@ -1,11 +1,13 @@
exports[`test A.js 1`] = `
"var B = require(\'./B\');
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`A.js 1`] = `
"var B = require('./B');
class A extends B { }
module.exports = A;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var B = require(\"./B\");
var B = require(\\"./B\\");
class A extends B {}
@ -13,14 +15,14 @@ module.exports = A;
"
`;
exports[`test B.js 1`] = `
"var A = require(\'./A\');
exports[`B.js 1`] = `
"var A = require('./A');
//class B extends A { }
module.exports = B;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var A = require(\"./A\");
var A = require(\\"./A\\");
//class B extends A { }

View File

@ -1,4 +1,6 @@
exports[`test date.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`date.js 1`] = `
"var d = new Date(0);
var x:string = d.getTime();
@ -7,7 +9,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 +19,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');
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var d = new Date(0);
var x: string = d.getTime();
@ -36,7 +38,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);
@ -46,15 +48,15 @@ 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\\");
"
`;

View File

@ -1,82 +1,84 @@
exports[`test ExplicitProvidesModuleDifferentName.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`ExplicitProvidesModuleDifferentName.js 1`] = `
"/*
* @providesModule ExplicitProvidesModuleDifferentName
* @flow
*/
module.exports.fun = (): string => \"hello there\";
module.exports.fun = (): string => \\"hello there\\";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*
* @providesModule ExplicitProvidesModuleDifferentName
* @flow
*/
module.exports.fun = (): string => \"hello there\";
module.exports.fun = (): string => \\"hello there\\";
"
`;
exports[`test ExplicitProvidesModuleSameName.js 1`] = `
exports[`ExplicitProvidesModuleSameName.js 1`] = `
"/*
* @providesModule ExplicitProvidesModuleSameName
* @flow
*/
module.exports.fun = (): string => \"hello there\";
module.exports.fun = (): string => \\"hello there\\";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*
* @providesModule ExplicitProvidesModuleSameName
* @flow
*/
module.exports.fun = (): string => \"hello there\";
module.exports.fun = (): string => \\"hello there\\";
"
`;
exports[`test ImplicitProvidesModule.js 1`] = `
exports[`ImplicitProvidesModule.js 1`] = `
"/*
* @providesModule ImplicitProvidesModule
* @flow
*/
module.exports.fun = (): string => \"hello there\";
module.exports.fun = (): string => \\"hello there\\";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*
* @providesModule ImplicitProvidesModule
* @flow
*/
module.exports.fun = (): string => \"hello there\";
module.exports.fun = (): string => \\"hello there\\";
"
`;
exports[`test md5.js 1`] = `
exports[`md5.js 1`] = `
"/* @providesModule md5 */
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @providesModule md5 */
"
`;
exports[`test test.js 1`] = `
exports[`test.js 1`] = `
"/* @flow */
var Implicit = require(\'ImplicitProvidesModule\');
var Implicit = require('ImplicitProvidesModule');
(Implicit.fun(): string);
var ExplicitSameName = require(\'ExplicitProvidesModuleSameName\');
var ExplicitSameName = require('ExplicitProvidesModuleSameName');
(ExplicitSameName.fun(): string);
var ExplicitDifferentName = require(\'ExplicitProvidesModuleDifferentName\');
var ExplicitDifferentName = require('ExplicitProvidesModuleDifferentName');
(ExplicitDifferentName.fun(): string);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
var Implicit = require(\"ImplicitProvidesModule\");
var Implicit = require(\\"ImplicitProvidesModule\\");
(Implicit.fun(): string);
var ExplicitSameName = require(\"ExplicitProvidesModuleSameName\");
var ExplicitSameName = require(\\"ExplicitProvidesModuleSameName\\");
(ExplicitSameName.fun(): string);
var ExplicitDifferentName = require(\"ExplicitProvidesModuleDifferentName\");
var ExplicitDifferentName = require(\\"ExplicitProvidesModuleDifferentName\\");
(ExplicitDifferentName.fun(): string);
"
`;

View File

@ -1,6 +1,8 @@
exports[`test min.js 1`] = `
"module.exports.fun = (): string => \"hello there\";
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`min.js 1`] = `
"module.exports.fun = (): string => \\"hello there\\";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
module.exports.fun = (): string => \"hello there\";
module.exports.fun = (): string => \\"hello there\\";
"
`;

View File

@ -1,13 +1,15 @@
exports[`test nested_test.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`nested_test.js 1`] = `
"/* @flow */
var docblock = require(\'qux/docblock\');
var min = require(\'d3/min.js\');
var corge = require(\'qux/corge\');
var docblock = require('qux/docblock');
var min = require('d3/min.js');
var corge = require('qux/corge');
// make sure we don\'t pick up non-header @providesModule
// make sure we don't pick up non-header @providesModule
// annotations - see node_modules/qux/docblock.js
var unreachable = require(\'annotation\');
var unreachable = require('annotation');
(docblock.fun(): string);
(min.fun(): string);
@ -15,13 +17,13 @@ var unreachable = require(\'annotation\');
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
var docblock = require(\"qux/docblock\");
var min = require(\"d3/min.js\");
var corge = require(\"qux/corge\");
var docblock = require(\\"qux/docblock\\");
var min = require(\\"d3/min.js\\");
var corge = require(\\"qux/corge\\");
// make sure we don\'t pick up non-header @providesModule
// make sure we don't pick up non-header @providesModule
// annotations - see node_modules/qux/docblock.js
var unreachable = require(\"annotation\");
var unreachable = require(\\"annotation\\");
(docblock.fun(): string);
(min.fun(): string);

View File

@ -1,4 +1,6 @@
exports[`test index.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`index.js 1`] = `
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"
`;

View File

@ -1,6 +1,8 @@
exports[`test client.js 1`] = `
"var ws = require(\'../\');
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`client.js 1`] = `
"var ws = require('../');
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var ws = require(\"../\");
var ws = require(\\"../\\");
"
`;

View File

@ -1,4 +1,6 @@
exports[`test A.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`A.js 1`] = `
"/* @providesModule A */
class Implementation {}
export function foo(): Implementation { return new Implementation; }
@ -11,7 +13,7 @@ export function foo(): Implementation {
"
`;
exports[`test ExplicitProvidesModuleDifferentName.js 1`] = `
exports[`ExplicitProvidesModuleDifferentName.js 1`] = `
"/*
* @providesModule ExplicitProvidesModuleDifferentName
* @flow
@ -30,7 +32,7 @@ module.exports.fun = (): Implementation => new Implementation();
"
`;
exports[`test ExplicitProvidesModuleSameName.js 1`] = `
exports[`ExplicitProvidesModuleSameName.js 1`] = `
"/*
* @providesModule ExplicitProvidesModuleSameName
* @flow
@ -49,7 +51,7 @@ module.exports.fun = (): Implementation => new Implementation();
"
`;
exports[`test ImplicitProvidesModule.js 1`] = `
exports[`ImplicitProvidesModule.js 1`] = `
"/*
* @providesModule ImplicitProvidesModule
* @flow
@ -68,34 +70,34 @@ module.exports.fun = (): Implementation => new Implementation();
"
`;
exports[`test md5.js 1`] = `
exports[`md5.js 1`] = `
"/* @providesModule md5 */
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @providesModule md5 */
"
`;
exports[`test test.js 1`] = `
exports[`test.js 1`] = `
"/* @flow */
var Implicit = require(\'ImplicitProvidesModule\');
var Implicit = require('ImplicitProvidesModule');
(Implicit.fun(): boolean); // Error: Either Implementation ~> boolean or Declaration ~> boolean
var ExplicitSameName = require(\'ExplicitProvidesModuleSameName\');
var ExplicitSameName = require('ExplicitProvidesModuleSameName');
(ExplicitSameName.fun(): boolean); // Error: Either Implementation ~> boolean or Declaration ~> boolean
var ExplicitDifferentName = require(\'ExplicitProvidesModuleDifferentName\');
var ExplicitDifferentName = require('ExplicitProvidesModuleDifferentName');
(ExplicitDifferentName.fun(): boolean); // Error: Either Implementation ~> boolean or Declaration ~> boolean
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
var Implicit = require(\"ImplicitProvidesModule\");
var Implicit = require(\\"ImplicitProvidesModule\\");
(Implicit.fun(): boolean); // Error: Either Implementation ~> boolean or Declaration ~> boolean
var ExplicitSameName = require(\"ExplicitProvidesModuleSameName\");
var ExplicitSameName = require(\\"ExplicitProvidesModuleSameName\\");
(ExplicitSameName.fun(): boolean); // Error: Either Implementation ~> boolean or Declaration ~> boolean
var ExplicitDifferentName = require(\"ExplicitProvidesModuleDifferentName\");
var ExplicitDifferentName = require(\\"ExplicitProvidesModuleDifferentName\\");
(ExplicitDifferentName.fun(): boolean); // Error: Either Implementation ~> boolean or Declaration ~> boolean
"
`;

View File

@ -1,4 +1,6 @@
exports[`test min.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`min.js 1`] = `
"class Implementation {}
module.exports.fun = (): Implementation => new Implementation;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -1,9 +1,11 @@
exports[`test nested_test.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`nested_test.js 1`] = `
"/* @flow */
var docblock = require(\'qux/docblock\');
var min = require(\'d3/min.js\');
var corge = require(\'qux/corge\');
var docblock = require('qux/docblock');
var min = require('d3/min.js');
var corge = require('qux/corge');
(docblock.fun(): boolean); // Error: Either Implementation ~> boolean or Declaration ~> boolean
(min.fun(): boolean); // Error: Either Implementation ~> boolean or Declaration ~> boolean
@ -11,9 +13,9 @@ var corge = require(\'qux/corge\');
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
var docblock = require(\"qux/docblock\");
var min = require(\"d3/min.js\");
var corge = require(\"qux/corge\");
var docblock = require(\\"qux/docblock\\");
var min = require(\\"d3/min.js\\");
var corge = require(\\"qux/corge\\");
(docblock.fun(): boolean); // Error: Either Implementation ~> boolean or Declaration ~> boolean
(min.fun(): boolean); // Error: Either Implementation ~> boolean or Declaration ~> boolean

View File

@ -1,4 +1,6 @@
exports[`test index.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`index.js 1`] = `
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"
`;

View File

@ -1,6 +1,8 @@
exports[`test client.js 1`] = `
"var ws = require(\'../\');
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`client.js 1`] = `
"var ws = require('../');
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var ws = require(\"../\");
var ws = require(\\"../\\");
"
`;

View File

@ -1,4 +1,6 @@
exports[`test A.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`A.js 1`] = `
"class Implementation {}
export function foo(): Implementation { return new Implementation; }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -9,99 +11,99 @@ export function foo(): Implementation {
"
`;
exports[`test test_absolute.js 1`] = `
exports[`test_absolute.js 1`] = `
"/* @flow */
// This will require ./node_modules/B.js.flow
var B1 = require(\'B\');
var B1 = require('B');
(B1.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
// This will require ./node_modules/B.js.flow
var B2 = require(\'B.js\');
var B2 = require('B.js');
(B2.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
var C = require(\'package_with_full_main\');
var C = require('package_with_full_main');
(C.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
var D = require(\'package_with_partial_main\');
var D = require('package_with_partial_main');
(D.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
var E = require(\'package_with_no_package_json\');
var E = require('package_with_no_package_json');
(E.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
var F = require(\'package_with_dir_main\');
var F = require('package_with_dir_main');
(F.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
// This will require ./node_modules/B.js.flow
var B1 = require(\'B\');
var B1 = require('B');
(B1.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
// This will require ./node_modules/B.js.flow
var B2 = require(\'B.js\');
var B2 = require('B.js');
(B2.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
var C = require(\'package_with_full_main\');
var C = require('package_with_full_main');
(C.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
var D = require(\'package_with_partial_main\');
var D = require('package_with_partial_main');
(D.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
var E = require(\'package_with_no_package_json\');
var E = require('package_with_no_package_json');
(E.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
var F = require(\'package_with_dir_main\');
var F = require('package_with_dir_main');
(F.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
// This will require ./node_modules/B.js.flow
var B1 = require(\"B\");
var B1 = require(\\"B\\");
(B1.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
// This will require ./node_modules/B.js.flow
var B2 = require(\"B.js\");
var B2 = require(\\"B.js\\");
(B2.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
var C = require(\"package_with_full_main\");
var C = require(\\"package_with_full_main\\");
(C.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
var D = require(\"package_with_partial_main\");
var D = require(\\"package_with_partial_main\\");
(D.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
var E = require(\"package_with_no_package_json\");
var E = require(\\"package_with_no_package_json\\");
(E.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
var F = require(\"package_with_dir_main\");
var F = require(\\"package_with_dir_main\\");
(F.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
// This will require ./node_modules/B.js.flow
var B1 = require(\"B\");
var B1 = require(\\"B\\");
(B1.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
// This will require ./node_modules/B.js.flow
var B2 = require(\"B.js\");
var B2 = require(\\"B.js\\");
(B2.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
var C = require(\"package_with_full_main\");
var C = require(\\"package_with_full_main\\");
(C.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
var D = require(\"package_with_partial_main\");
var D = require(\\"package_with_partial_main\\");
(D.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
var E = require(\"package_with_no_package_json\");
var E = require(\\"package_with_no_package_json\\");
(E.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
var F = require(\"package_with_dir_main\");
var F = require(\\"package_with_dir_main\\");
(F.fun(): boolean); // Error either Implementation ~> boolean or Declaration ~> boolean
"
`;
exports[`test test_relative.js 1`] = `
"import { foo } from \'./A\';
exports[`test_relative.js 1`] = `
"import { foo } from './A';
(foo(): boolean); // Error: either Implementation ~> boolean or Definition ~> boolean
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import { foo } from \"./A\";
import { foo } from \\"./A\\";
(foo(): boolean); // Error: either Implementation ~> boolean or Definition ~> boolean
"

View File

@ -1,15 +1,17 @@
exports[`test A.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`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!\\";
"
`;
exports[`test CJS.js 1`] = `
exports[`CJS.js 1`] = `
"// @flow
module.exports = 42;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -18,79 +20,79 @@ module.exports = 42;
"
`;
exports[`test test_absolute.js 1`] = `
exports[`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 */
// 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
"
`;
exports[`test test_relative.js 1`] = `
exports[`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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @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
"

View File

@ -1,24 +1,26 @@
exports[`test declare_class.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`declare_class.js 1`] = `
"declare class C {
static x: number;
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
declare class C {
static x: number,
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
"
`;

View File

@ -1,4 +1,6 @@
exports[`test test.js 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"declare class _C {
foo(): number;
}

Some files were not shown because too many files have changed in this diff Show More