Prittier printing of snapshots (#1190)

This uses a custom snapshot serializer to reduce escaping in snapshot files and
make them easier to read.

Snapshot serializers are documented here:
https://facebook.github.io/jest/docs/configuration.html#snapshotserializers-array-string
master
Jan Kassens 2017-04-12 13:41:51 -07:00 committed by Christopher Chedeau
parent 8e1583fd16
commit b82220b20f
501 changed files with 9018 additions and 8994 deletions

View File

@ -46,6 +46,9 @@
"setupFiles": [
"<rootDir>/tests_config/run_spec.js"
],
"snapshotSerializers": [
"<rootDir>/tests_config/raw-serializer.js"
],
"testRegex": "jsfmt\\.spec\\.js$",
"testPathIgnorePatterns": [
"tests/new_react",

View File

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

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`last.js 1`] = `
"[,];
[,];
[,,];
[,,1,];
[,,1,1];
@ -10,11 +10,11 @@ exports[`last.js 1`] = `
[, ,];
[, , 1];
[, , 1, 1];
"
`;
exports[`preserve_empty_lines.js 1`] = `
"a = [
a = [
1,
2,
@ -28,5 +28,5 @@ exports[`preserve_empty_lines.js 1`] = `
]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a = [1, 2, 3, 4];
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`arrow_call.js 1`] = `
"const testResults = results.testResults.map(testResult =>
const testResults = results.testResults.map(testResult =>
formatResult(testResult, formatter, reporter)
);
@ -11,19 +11,19 @@ it('mocks regexp instances', () => {
).not.toThrow();
});
expect(() => asyncRequest({ url: \\"/test-endpoint\\" }))
expect(() => asyncRequest({ url: "/test-endpoint" }))
.toThrowError(/Required parameter/);
expect(() => asyncRequest({ url: \\"/test-endpoint-but-with-a-long-url\\" }))
expect(() => asyncRequest({ url: "/test-endpoint-but-with-a-long-url" }))
.toThrowError(/Required parameter/);
expect(() => asyncRequest({ url: \\"/test-endpoint-but-with-a-suuuuuuuuper-long-url\\" }))
expect(() => asyncRequest({ url: "/test-endpoint-but-with-a-suuuuuuuuper-long-url" }))
.toThrowError(/Required parameter/);
expect(() => asyncRequest({ type: \\"foo\\", url: \\"/test-endpoint\\" }))
expect(() => asyncRequest({ type: "foo", url: "/test-endpoint" }))
.not.toThrowError();
expect(() => asyncRequest({ type: \\"foo\\", url: \\"/test-endpoint-but-with-a-long-url\\" }))
expect(() => asyncRequest({ type: "foo", url: "/test-endpoint-but-with-a-long-url" }))
.not.toThrowError();
const a = Observable
@ -43,33 +43,33 @@ const testResults = results.testResults.map(testResult =>
formatResult(testResult, formatter, reporter)
);
it(\\"mocks regexp instances\\", () => {
it("mocks regexp instances", () => {
expect(() =>
moduleMocker.generateFromMetadata(moduleMocker.getMetadata(/a/))
).not.toThrow();
});
expect(() => asyncRequest({ url: \\"/test-endpoint\\" })).toThrowError(
expect(() => asyncRequest({ url: "/test-endpoint" })).toThrowError(
/Required parameter/
);
expect(() =>
asyncRequest({ url: \\"/test-endpoint-but-with-a-long-url\\" })
asyncRequest({ url: "/test-endpoint-but-with-a-long-url" })
).toThrowError(/Required parameter/);
expect(() =>
asyncRequest({ url: \\"/test-endpoint-but-with-a-suuuuuuuuper-long-url\\" })
asyncRequest({ url: "/test-endpoint-but-with-a-suuuuuuuuper-long-url" })
).toThrowError(/Required parameter/);
expect(() =>
asyncRequest({ type: \\"foo\\", url: \\"/test-endpoint\\" })
asyncRequest({ type: "foo", url: "/test-endpoint" })
).not.toThrowError();
expect(() =>
asyncRequest({ type: \\"foo\\", url: \\"/test-endpoint-but-with-a-long-url\\" })
asyncRequest({ type: "foo", url: "/test-endpoint-but-with-a-long-url" })
).not.toThrowError();
const a = Observable.fromPromise(axiosInstance.post(\\"/carts/mine\\")).map(
const a = Observable.fromPromise(axiosInstance.post("/carts/mine")).map(
response => response.data
);
@ -82,11 +82,11 @@ func(
veryLooooooooooooooooooooooooongName =>
veryLoooooooooooooooongName.something()
);
"
`;
exports[`arrow_call.js 2`] = `
"const testResults = results.testResults.map(testResult =>
const testResults = results.testResults.map(testResult =>
formatResult(testResult, formatter, reporter)
);
@ -96,19 +96,19 @@ it('mocks regexp instances', () => {
).not.toThrow();
});
expect(() => asyncRequest({ url: \\"/test-endpoint\\" }))
expect(() => asyncRequest({ url: "/test-endpoint" }))
.toThrowError(/Required parameter/);
expect(() => asyncRequest({ url: \\"/test-endpoint-but-with-a-long-url\\" }))
expect(() => asyncRequest({ url: "/test-endpoint-but-with-a-long-url" }))
.toThrowError(/Required parameter/);
expect(() => asyncRequest({ url: \\"/test-endpoint-but-with-a-suuuuuuuuper-long-url\\" }))
expect(() => asyncRequest({ url: "/test-endpoint-but-with-a-suuuuuuuuper-long-url" }))
.toThrowError(/Required parameter/);
expect(() => asyncRequest({ type: \\"foo\\", url: \\"/test-endpoint\\" }))
expect(() => asyncRequest({ type: "foo", url: "/test-endpoint" }))
.not.toThrowError();
expect(() => asyncRequest({ type: \\"foo\\", url: \\"/test-endpoint-but-with-a-long-url\\" }))
expect(() => asyncRequest({ type: "foo", url: "/test-endpoint-but-with-a-long-url" }))
.not.toThrowError();
const a = Observable
@ -128,33 +128,33 @@ const testResults = results.testResults.map(testResult =>
formatResult(testResult, formatter, reporter),
);
it(\\"mocks regexp instances\\", () => {
it("mocks regexp instances", () => {
expect(() =>
moduleMocker.generateFromMetadata(moduleMocker.getMetadata(/a/)),
).not.toThrow();
});
expect(() => asyncRequest({ url: \\"/test-endpoint\\" })).toThrowError(
expect(() => asyncRequest({ url: "/test-endpoint" })).toThrowError(
/Required parameter/,
);
expect(() =>
asyncRequest({ url: \\"/test-endpoint-but-with-a-long-url\\" }),
asyncRequest({ url: "/test-endpoint-but-with-a-long-url" }),
).toThrowError(/Required parameter/);
expect(() =>
asyncRequest({ url: \\"/test-endpoint-but-with-a-suuuuuuuuper-long-url\\" }),
asyncRequest({ url: "/test-endpoint-but-with-a-suuuuuuuuper-long-url" }),
).toThrowError(/Required parameter/);
expect(() =>
asyncRequest({ type: \\"foo\\", url: \\"/test-endpoint\\" }),
asyncRequest({ type: "foo", url: "/test-endpoint" }),
).not.toThrowError();
expect(() =>
asyncRequest({ type: \\"foo\\", url: \\"/test-endpoint-but-with-a-long-url\\" }),
asyncRequest({ type: "foo", url: "/test-endpoint-but-with-a-long-url" }),
).not.toThrowError();
const a = Observable.fromPromise(axiosInstance.post(\\"/carts/mine\\")).map(
const a = Observable.fromPromise(axiosInstance.post("/carts/mine")).map(
response => response.data,
);
@ -167,5 +167,5 @@ func(
veryLooooooooooooooooooooooooongName =>
veryLoooooooooooooooongName.something(),
);
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`arrow_function_expression.js 1`] = `
"(a => {}).length
(a => {}).length
typeof (() => {});
export default (() => {})();
(() => {})()\`\`;
@ -54,7 +54,7 @@ a = () => ({} = 0);
a = () => ({}, a);
a => a instanceof {};
a => ({}().b && 0);
a => ({}::b()\`\`[\\"\\"].c++ && 0 ? 0 : 0);
a => ({}::b()\`\`[""].c++ && 0 ? 0 : 0);
a => ({}().c = 0);
x => ({}()());
x => ({}()\`\`);
@ -63,18 +63,18 @@ x => ({}().b);
a::(b => c);
a = b => c;
a = (b?) => c;
"
`;
exports[`block_like.js 1`] = `
"a = () => ({} = this);
a = () => ({} = this);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a = () => ({} = this);
"
`;
exports[`call.js 1`] = `
"Seq(typeDef.interface.groups).forEach(group =>
Seq(typeDef.interface.groups).forEach(group =>
Seq(group.members).forEach((member, memberName) =>
markdownDoc(
member.doc,
@ -224,18 +224,18 @@ function render() {
}
jest.mock(
\\"../SearchSource\\",
"../SearchSource",
() => class {
findMatchingTests(pattern) {
return { paths: [] };
}
}
);
"
`;
exports[`currying.js 1`] = `
"const fn = b => c => d => {
const fn = b => c => d => {
return 3;
};
@ -258,37 +258,37 @@ const mw = store => next => action => {
const middleware = options => (req, res, next) => {
// ...
};
"
`;
exports[`long-call-no-args.js 1`] = `
"veryLongCall(VERY_VERY_VERY_VERY_VERY_VERY_VERY_VERY_VERY_VERY_LONG_CONSTANT, () => {})
veryLongCall(VERY_VERY_VERY_VERY_VERY_VERY_VERY_VERY_VERY_VERY_LONG_CONSTANT, () => {})
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
veryLongCall(
VERY_VERY_VERY_VERY_VERY_VERY_VERY_VERY_VERY_VERY_LONG_CONSTANT,
() => {}
);
"
`;
exports[`long-contents.js 1`] = `
"const foo = () => {
const foo = () => {
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"
});
};
"
`;
exports[`short_body.js 1`] = `
"const initializeSnapshotState = (
const initializeSnapshotState = (
testFile: Path,
update: boolean,
testPath: string,
@ -301,5 +301,5 @@ const initializeSnapshotState = (
testPath: string,
expand: boolean
) => new SnapshotState(testFile, update, testPath, expand);
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`binaryish.js 1`] = `
"const computedDescriptionLines = (showConfirm &&
const computedDescriptionLines = (showConfirm &&
descriptionLinesConfirming) ||
(focused && !loading && descriptionLinesFocused) ||
descriptionLines;
@ -18,5 +18,5 @@ const computedDescriptionLines =
computedDescriptionLines =
(focused && !loading && descriptionLinesFocused) || descriptionLines;
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`assignment_comments.js 1`] = `
"fnString =
fnString =
// Comment
'some' + 'long' + 'string';
@ -58,52 +58,52 @@ let f = (
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fnString =
// Comment
\\"some\\" + \\"long\\" + \\"string\\";
"some" + "long" + "string";
var fnString =
// Comment
\\"some\\" + \\"long\\" + \\"string\\";
"some" + "long" + "string";
var fnString =
// Comment
\\"some\\" + \\"long\\" + \\"string\\";
"some" + "long" + "string";
var fnString =
// Comment
\\"some\\" + \\"long\\" + \\"string\\";
"some" + "long" + "string";
var fnString =
/* comment */
\\"some\\" + \\"long\\" + \\"string\\";
"some" + "long" + "string";
var fnString =
/**
* multi-line
*/
\\"some\\" + \\"long\\" + \\"string\\";
"some" + "long" + "string";
var fnString =
/* inline */ \\"some\\" +
\\"long\\" +
\\"string\\" +
\\"some\\" +
\\"long\\" +
\\"string\\" +
\\"some\\" +
\\"long\\" +
\\"string\\" +
\\"some\\" +
\\"long\\" +
\\"string\\";
/* inline */ "some" +
"long" +
"string" +
"some" +
"long" +
"string" +
"some" +
"long" +
"string" +
"some" +
"long" +
"string";
var fnString = // Comment
// Comment
\\"some\\" + \\"long\\" + \\"string\\";
"some" + "long" + "string";
var fnString = // Comment
\\"some\\" + \\"long\\" + \\"string\\";
"some" + "long" + "string";
let f = (
//comment
@ -117,5 +117,5 @@ let f = (
let f = (
a = b //comment
) => {};
"
`;

View File

@ -1,8 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`assignment_expression.js 1`] = `
"this.size = this._origin = this._capacity = 0;
this.size = this._origin = this._capacity = 0;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
this.size = this._origin = this._capacity = 0;
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`await_parse.js 1`] = `
"async function f() { (await f()).length }
async function f() { (await f()).length }
async function g() {
invariant(
(await driver.navigator.getUrl()).substr(-7)
@ -26,26 +26,26 @@ function* f() {
async function f() {
a = !await f();
}
"
`;
exports[`conditional-expression.js 1`] = `
"async function f() {
async function f() {
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,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`arrow.js 1`] = `
"function f() {
function f() {
const appEntitys = getAppEntitys(loadObject).filter(
entity => entity && entity.isInstallAvailable() && !entity.isQueue() && entity.isDisabled()
)
@ -16,11 +16,11 @@ function f() {
entity.isDisabled()
);
}
"
`;
exports[`comment.js 1`] = `
"a = (
a = (
// Commment 1
(Math.random() * (yRange * (1 - minVerticalFraction)))
+ (minVerticalFraction * yRange)
@ -31,11 +31,11 @@ a =
Math.random() * (yRange * (1 - minVerticalFraction)) +
minVerticalFraction * yRange -
offset;
"
`;
exports[`exp.js 1`] = `
"a ** b ** c;
a ** b ** c;
(a ** b) ** c;
a.b ** c;
(-a) ** b;
@ -52,11 +52,11 @@ a ** -b;
-(a ** b);
(a * b) ** c;
a ** (b * c);
"
`;
exports[`inline-object-array.js 1`] = `
"prevState = prevState || {
prevState = prevState || {
catalogs: [],
loadState: LOADED,
opened: false,
@ -75,21 +75,21 @@ 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[`short-right.js 1`] = `
"this._cumulativeHeights &&
this._cumulativeHeights &&
Math.abs(
this._cachedItemHeight(this._firstVisibleIndex + i) -
this._provider.fastHeight(i + this._firstVisibleIndex),
@ -120,16 +120,16 @@ foooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(
) + a;
const isPartOfPackageJSON =
dependenciesArray.indexOf(dependencyWithOutRelativePath.split(\\"/\\")[0]) !== -1;
dependenciesArray.indexOf(dependencyWithOutRelativePath.split("/")[0]) !== -1;
defaultContent.filter(defaultLocale => {
// ...
})[0] || null;
"
`;
exports[`test.js 1`] = `
"// It should always break the highest precedence operators first, and
// It should always break the highest precedence operators first, and
// break them all at the same time.
const x = longVariable + longVariable + longVariable;
@ -191,5 +191,5 @@ foo(
? number + 5
: false
);
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`parens.js 1`] = `
"const result = (a + b) >>> 1;
const result = (a + b) >>> 1;
var sizeIndex = ((index - 1) >>> level) & MASK;
var from = offset > left ? 0 : (left - offset) >> level;
var to = ((right - offset) >> level) + 1;
@ -21,5 +21,5 @@ var res = size < SIZE ? 0 : (size - 1) >>> SHIFT << SHIFT;
sign = 1 - 2 * (b[3] >> 7);
exponent = (((b[3] << 1) & 0xff) | (b[2] >> 7)) - 127;
mantissa = ((b[2] & 0x7f) << 16) | (b[1] << 8) | b[0];
"
`;

View File

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

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`break.js 1`] = `
"h(f(g(() => {
h(f(g(() => {
a
})))
@ -77,11 +77,11 @@ const mapChargeItems = fp.flow(
expect(
new LongLongLongLongLongRange([0, 0], [0, 0])
).toEqualAtomLongLongLongLongRange(new LongLongLongRange([0, 0], [0, 0]));
"
`;
exports[`parent.js 1`] = `
"runtimeAgent.getProperties(
runtimeAgent.getProperties(
objectId,
false, // ownProperties
false, // accessorPropertiesOnly
@ -100,5 +100,5 @@ runtimeAgent.getProperties(
return 1;
}
);
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`comments.js 1`] = `
"class A // comment 1
class A // comment 1
// comment 2
extends B {}
@ -68,5 +68,5 @@ class x {
// do nothing
}
}
"
`;

View File

@ -1,57 +1,57 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`extends.js 1`] = `
"// \\"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) {}
@ -59,62 +59,62 @@ 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) {}
}
x = class extends (++b) {};
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`binary.js 1`] = `
"(class {}) + 1;
(class {}) + 1;
(class a {}) + 1;
(class extends b {}) + 1;
(class a extends b {}) + 1;
@ -10,11 +10,11 @@ exports[`binary.js 1`] = `
(class a {} + 1);
(class extends b {} + 1);
(class a extends b {} + 1);
"
`;
exports[`break.js 1`] = `
"class MyContractSelectionWidget extends React.Component<void, MyContractSelectionWidgetPropsType, void> implements SomethingLarge {
class MyContractSelectionWidget extends React.Component<void, MyContractSelectionWidgetPropsType, void> implements SomethingLarge {
method() {}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -23,18 +23,18 @@ class MyContractSelectionWidget
implements SomethingLarge {
method() {}
}
"
`;
exports[`call.js 1`] = `
"(class {})(class {});
(class {})(class {});
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(class {}(class {}));
"
`;
exports[`empty.js 1`] = `
"class A {
class A {
// comment
}
@ -61,21 +61,21 @@ class A {}
class A {
m() {}
}
"
`;
exports[`member.js 1`] = `
"(class {})[1];
(class {})[1];
(class {}).a;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(class {}[1]);
(class {}.a);
"
`;
exports[`ternary.js 1`] = `
"if (1) (class {}) ? 1 : 2;
if (1) (class {}) ? 1 : 2;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (1) (class {} ? 1 : 2);
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`assignment-pattern.js 1`] = `
"const { a /* comment */ = 1 } = b;
const { a /* comment */ = 1 } = b;
const { c = 1 /* comment */ } = d;
@ -15,11 +15,11 @@ const { c = 1 /* comment */ } = d;
let {
a = b //comment
} = c;
"
`;
exports[`before-comma.js 1`] = `
"const foo = {
const foo = {
a: 'a' /* comment for this line */,
/* Section B */
@ -27,16 +27,16 @@ exports[`before-comma.js 1`] = `
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const foo = {
a: \\"a\\" /* comment for this line */,
a: "a" /* comment for this line */,
/* Section B */
b: \\"b\\"
b: "b"
};
"
`;
exports[`blank.js 1`] = `
"// This file only
// This file only
// has comments. This comment
// should still exist
//
@ -79,11 +79,11 @@ exports[`blank.js 1`] = `
// comment
// comment
"
`;
exports[`call_comment.js 1`] = `
"render( // Warm any cache
render( // Warm any cache
<ChildUpdates renderAnchor={true} anchorClassOn={true} />,
container
);
@ -104,11 +104,11 @@ React.render(
<ChildUpdates renderAnchor={true} anchorClassOn={true} />,
container
);
"
`;
exports[`dangling.js 1`] = `
"var x = {/* dangling */};
var x = {/* dangling */};
var x = {
// dangling
};
@ -135,11 +135,11 @@ declare class Foo extends Qux<string> {
/* dangling */
}
export /* dangling */{};
"
`;
exports[`dangling_array.js 1`] = `
"expect(() => {}).toTriggerReadyStateChanges([
expect(() => {}).toTriggerReadyStateChanges([
// Nothing.
]);
@ -152,11 +152,11 @@ expect(() => {}).toTriggerReadyStateChanges(
);
[1 /*first comment */, 2 /* second comment */, 3];
"
`;
exports[`dangling_for.js 1`] = `
"for // comment
for // comment
(;;);
for /* comment */(;;);
@ -166,37 +166,37 @@ for (;;);
/* comment */
for (;;);
"
`;
exports[`export.js 1`] = `
"export //comment
export //comment
{}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//comment
export {};
"
`;
exports[`first-line.js 1`] = `
"a // comment
a // comment
b
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a; // comment
b;
"
`;
exports[`flow_union.js 1`] = `
"type UploadState<E, EM, D>
type UploadState<E, EM, D>
// The upload hasnt begun yet
= {type: \\"Not_begun\\"}
= {type: "Not_begun"}
// The upload timed out
| {type: \\"Timed_out\\"}
| {type: "Timed_out"}
// Failed somewhere on the line
| {type: \\"Failed\\", error: E, errorMsg: EM}
| {type: "Failed", error: E, errorMsg: EM}
// Uploading to aws3 and CreatePostMutation succeeded
| {type: \\"Success\\", data: D};
| {type: "Success", data: D};
type UploadState<E, EM, D>
// The upload hasnt begun yet
@ -210,13 +210,13 @@ type UploadState<E, EM, D>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
type UploadState<E, EM, D> =
// The upload hasnt begun yet
| { type: \\"Not_begun\\" }
| { type: "Not_begun" }
// The upload timed out
| { type: \\"Timed_out\\" }
| { type: "Timed_out" }
// Failed somewhere on the line
| { type: \\"Failed\\", error: E, errorMsg: EM }
| { type: "Failed", error: E, errorMsg: EM }
// Uploading to aws3 and CreatePostMutation succeeded
| { type: \\"Success\\", data: D };
| { type: "Success", data: D };
type UploadState<E, EM, D> =
// The upload hasnt begun yet
@ -227,22 +227,22 @@ type UploadState<E, EM, D> =
| C
// Uploading to aws3 and CreatePostMutation succeeded
| D;
"
`;
exports[`function-declaration.js 1`] = `
"function a(/* comment */) {} // comment
function a(/* comment */) {} // comment
function b() {} // comment
function c(/* comment */ argA, argB, argC) {} // comment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function a(/* comment */) {} // comment
function b() {} // comment
function c(/* comment */ argA, argB, argC) {} // comment
"
`;
exports[`if.js 1`] = `
"if (1)
if (1)
// comment
{
false
@ -292,11 +292,11 @@ if (1) {
} else {
// comment
}
"
`;
exports[`issues.js 1`] = `
"// Does not need to break as it fits in 80 columns
// Does not need to break as it fits in 80 columns
this.call(a, /* comment */ b);
function f(
@ -354,11 +354,11 @@ 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
'[\\'"]' + // closing quotation mark
',?$', // optional trailing comma
);
@ -425,30 +425,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
@ -469,16 +469,16 @@ 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
import path from "path"; // eslint-disable-line nuclide-internal/prefer-nuclide-uri
// Comments disappear in-between MemberExpressions
Observable.of(process)
@ -510,18 +510,18 @@ 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(
{}
// Hi
);
"
`;
exports[`jsx.js 1`] = `
"<div>
<div>
{
/* comment */
}
@ -655,11 +655,11 @@ exports[`jsx.js 1`] = `
<div>
{/*<div> Some very v ery very very long line to break line width limit </div>*/}
</div>;
"
`;
exports[`last-arg.js 1`] = `
"type f = (
type f = (
currentRequest: {a: number},
// TODO this is a very very very very long comment that makes it go > 80 columns
) => number;
@ -726,11 +726,11 @@ function f(
): number {
return a + 1;
}
"
`;
exports[`preserve-new-line-last.js 1`] = `
"function f() {
function f() {
a
/* eslint-disable */
}
@ -773,11 +773,11 @@ function name() {
// comment3 why func3 commented
// func3()
}
"
`;
exports[`return-statement.js 1`] = `
"function jsx() {
function jsx() {
return (
// Comment
<div />
@ -1026,17 +1026,17 @@ function taggedTemplate() {
function inlineComment() {
return /* hi */ 42 || 42;
}
"
`;
exports[`switch.js 1`] = `
"switch (node && node.type) {
case \\"Property\\":
case \\"MethodDefinition\\":
switch (node && node.type) {
case "Property":
case "MethodDefinition":
prop = node.key;
break;
case \\"MemberExpression\\":
case "MemberExpression":
prop = node.property;
break;
@ -1044,38 +1044,38 @@ exports[`switch.js 1`] = `
}
switch (foo) {
case \\"bar\\":
case "bar":
doThing()
// no default
}
switch (foo) {
case \\"bar\\": //comment
case "bar": //comment
doThing(); //comment
case \\"baz\\":
case "baz":
doOtherThing(); //comment
}
switch (foo) {
case \\"bar\\": {
case "bar": {
doThing();
} //comment
case \\"baz\\": {
case "baz": {
doThing();
} //comment
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
switch (node && node.type) {
case \\"Property\\":
case \\"MethodDefinition\\":
case "Property":
case "MethodDefinition":
prop = node.key;
break;
case \\"MemberExpression\\":
case "MemberExpression":
prop = node.property;
break;
@ -1083,34 +1083,34 @@ switch (node && node.type) {
}
switch (foo) {
case \\"bar\\":
case "bar":
doThing();
// no default
}
switch (foo) {
case \\"bar\\": //comment
case "bar": //comment
doThing(); //comment
case \\"baz\\":
case "baz":
doOtherThing(); //comment
}
switch (foo) {
case \\"bar\\": {
case "bar": {
doThing();
} //comment
case \\"baz\\": {
case "baz": {
doThing();
} //comment
}
"
`;
exports[`template-literal.js 1`] = `
"\`
\`
\${a // comment
}
@ -1135,11 +1135,11 @@ a}
/*comment*/
d};
\`;
"
`;
exports[`try.js 1`] = `
"// comment 1
// comment 1
try {
// comment 2
}
@ -1163,11 +1163,11 @@ try {
// comment 5
// comment 7
}
"
`;
exports[`variable_declarator.js 1`] = `
"let obj = // Comment
let obj = // Comment
{
key: 'val'
}
@ -1208,41 +1208,41 @@ let obj = [
let obj =
// Comment
{
key: \\"val\\"
key: "val"
};
let obj =
// Comment
{
key: \\"val\\"
key: "val"
};
let obj = {
// Comment
key: \\"val\\"
key: "val"
};
let obj = {
// Comment
key: \\"val\\"
key: "val"
};
let obj =
// Comment
[\\"val\\"];
["val"];
let obj =
// Comment
[\\"val\\"];
["val"];
let obj = [
// Comment
\\"val\\"
"val"
];
let obj = [
// Comment
\\"val\\"
"val"
];
"
`;

View File

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

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`comments.js 1`] = `
"var inspect = 4 === util.inspect.length
var inspect = 4 === util.inspect.length
? // node <= 0.8.x
(function(v, colors) {
return util.inspect(v, void 0, void 0, colors);
@ -28,16 +28,16 @@ const extractTextPluginOptions = shouldUseRelativeAssetPaths
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
@ -61,42 +61,42 @@ 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
`;
exports[`new-expression.js 1`] = `
"const testConsole = new TestConsole(
const testConsole = new TestConsole(
config.useStderr ? process.stderr : process.stdout
);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const testConsole = new TestConsole(
config.useStderr ? process.stderr : process.stdout
);
"
`;
exports[`no-confusing-arrow.js 1`] = `
"// no-confusing-arrow
// no-confusing-arrow
var x = a => 1 ? 2 : 3;
var x = a <= 1 ? 2 : 3;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// no-confusing-arrow
var x = a => (1 ? 2 : 3);
var x = a <= 1 ? 2 : 3;
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`mobx.js 1`] = `
"import {observable} from \\"mobx\\";
import {observable} from "mobx";
@observer class OrderLine {
@observable price:number = 0;
@ -20,7 +20,7 @@ exports[`mobx.js 1`] = `
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import { observable } from \\"mobx\\";
import { observable } from "mobx";
@observer class OrderLine {
@observable price: number = 0;
@ -38,11 +38,11 @@ import { observable } from \\"mobx\\";
this.price = price;
}
}
"
`;
exports[`multiple.js 1`] = `
"const dog = {
const dog = {
@readonly
@nonenumerable
@doubledValue
@ -55,11 +55,11 @@ const dog = {
@doubledValue
legs: 4
};
"
`;
exports[`redux.js 1`] = `
"@connect(mapStateToProps, mapDispatchToProps)
@connect(mapStateToProps, mapDispatchToProps)
export class MyApp extends React.Component {}
@connect(state => ({ todos: state.todos }))
@ -70,5 +70,5 @@ export class MyApp extends React.Component {}
@connect(state => ({ todos: state.todos }))
export class Home extends React.Component {}
"
`;

View File

@ -1,65 +1,65 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`last-line-0.js 1`] = `
"'use strict';~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\\"use strict\\";
"
'use strict';~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"use strict";
`;
exports[`last-line-1.js 1`] = `
"'use strict';
'use strict';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\\"use strict\\";
"
"use strict";
`;
exports[`last-line-2.js 1`] = `
"'use strict';
'use strict';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\\"use strict\\";
"
"use strict";
`;
exports[`newline.js 1`] = `
"/* @flow */
/* @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[`no-newline.js 1`] = `
"\\"use strict\\";
"use strict";
a
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\\"use strict\\";
"use strict";
a;
"
`;
exports[`test.js 1`] = `
"\\"use strict\\";
"use strict";
function fn() {
\\"use strict\\";
"use strict";
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\\"use strict\\";
"use strict";
function fn() {
\\"use strict\\";
"use strict";
}
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`do.js 1`] = `
"const envSpecific = {
const envSpecific = {
domain:
do {
if(env === 'production') 'https://abc.mno.com/';
@ -11,9 +11,9 @@ exports[`do.js 1`] = `
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const envSpecific = {
domain: do {
if (env === \\"production\\") (\\"https://abc.mno.com/\\");
else if (env === \\"development\\") (\\"http://localhost:4000\\");
if (env === "production") ("https://abc.mno.com/");
else if (env === "development") ("http://localhost:4000");
}
};
"
`;

View File

@ -1,10 +1,10 @@
// 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);
"
import("module.js");
import("module.js").then(a => a);
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`empty_paren_comment.js 1`] = `
"let f = (/* ... */) => {}
let f = (/* ... */) => {}
(function (/* ... */) {})(/* ... */)
function f(/* ... */) {}
@ -52,5 +52,5 @@ f(/* ... */);
f(a /* ... */);
f(a, /* ... */ b);
f(/* ... */ a, b);
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`body.js 1`] = `
"with (a);
with (a);
if (1); else if (2); else;
for (;;);
while (1);
@ -19,5 +19,5 @@ for (var i in o);
for (var i of o);
do;
while (1);
"
`;

View File

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

View File

@ -1,8 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"type Props = {||};
type Props = {||};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
type Props = {||};
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`bracket.js 1`] = `
"export {
export {
runTaskForChanged,
description,
someOtherLabel,
@ -24,11 +24,11 @@ export {
soWeCanGetItTo80Columns
};
export { fitsIn, oneLine };
"
`;
exports[`bracket.js 2`] = `
"export {
export {
runTaskForChanged,
description,
someOtherLabel,
@ -51,23 +51,23 @@ export {
soWeCanGetItTo80Columns
};
export {fitsIn, oneLine};
"
`;
exports[`empty.js 1`] = `
"export {};
export {} from \\".\\";
export {};
export {} from ".";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export {};
export {} from \\".\\";
"
export {} from ".";
`;
exports[`empty.js 2`] = `
"export {};
export {} from \\".\\";
export {};
export {} from ".";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export {};
export {} from \\".\\";
"
export {} from ".";
`;

View File

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

View File

@ -1,10 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`export.js 1`] = `
"export * as ns from 'mod';
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,13 +1,13 @@
// 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, value2 as value2_renamed, value3, value4 as value4_renamed, value5 } from "exports";
export a,{b} from \\"./baz\\";
export a,{b} from "./baz";
export * as ns from \\"mod\\";
export * as ns from "mod";
export * as foo,{bar} from \\"./baz\\";
export * as foo,{bar} from "./baz";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export {
value1,
@ -15,12 +15,12 @@ export {
value3,
value4 as value4_renamed,
value5
} from \\"exports\\";
} from "exports";
export a, { b } from \\"./baz\\";
export a, { b } from "./baz";
export * as ns from \\"mod\\";
export * as ns from "mod";
export * as foo, { bar } from "./baz";
export * as foo, { bar } from \\"./baz\\";
"
`;

View File

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

View File

@ -1,13 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"setTimeout(function() {
setTimeout(function() {
thing();
}, 500);
[\\"a\\",\\"b\\",\\"c\\"].reduce(function(item, thing) {
return thing + \\" \\" + item;
}, \\"letters:\\")
["a","b","c"].reduce(function(item, thing) {
return thing + " " + item;
}, "letters:")
func(() => {
thing();
@ -66,7 +66,7 @@ func(() => {
compose((a) => {
return a.thing;
}, b => {
return b + \\"\\";
return b + "";
});
compose((a) => {
@ -93,9 +93,9 @@ setTimeout(function() {
thing();
}, 500);
[\\"a\\", \\"b\\", \\"c\\"].reduce(function(item, thing) {
return thing + \\" \\" + item;
}, \\"letters:\\");
["a", "b", "c"].reduce(function(item, thing) {
return thing + " " + item;
}, "letters:");
func(() => {
thing();
@ -166,7 +166,7 @@ compose(
return a.thing;
},
b => {
return b + \\"\\";
return b + "";
}
);
@ -196,5 +196,5 @@ setTimeout(
},
500
);
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`break-continue.js 1`] = `
"function foo() {
function foo() {
while(true) { break; }
}
@ -20,11 +20,11 @@ function bar() {
continue L;
} while (false);
}
"
`;
exports[`return.js 1`] = `
"function bar(x:number) { }
function bar(x:number) { }
function foo() {
var x = null;
if (x == null) return;
@ -37,16 +37,16 @@ function foo() {
if (x == null) return;
bar(x);
}
"
`;
exports[`toplevel_throw.js 1`] = `
"// @flow
// @flow
throw new Error('foo'); // no error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow
throw new Error(\\"foo\\"); // no error
"
throw new Error("foo"); // no error
`;

View File

@ -1,19 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`annot.js 1`] = `
"function foo(str:string, i:number):string {
function foo(str:string, i:number):string {
return str;
}
var bar: (str:number, i:number)=> string = foo;
var qux = function(str:string, i:number):number { return foo(str,i); }
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;
@ -23,7 +23,7 @@ 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; };
@ -31,7 +31,7 @@ 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
@ -72,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;
@ -90,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
@ -131,11 +131,11 @@ function foobar(n: ?number): number | null | void {
function barfoo(n: number | null | void): ?number {
return n;
}
"
`;
exports[`forward_ref.js 1`] = `
"let myClassInstance: MyClass = null; // forward ref ok, null ~> class error
let myClassInstance: MyClass = null; // forward ref ok, null ~> class error
function bar(): MyClass {
return null; // forward ref ok, null ~> class error
@ -166,22 +166,22 @@ function foo() {
class MyClass {} // looked up above
}
"
`;
exports[`issue-530.js 1`] = `
"function foo(...args: any) { }
function foo(...args: any) { }
module.exports = foo;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function foo(...args: any) {}
module.exports = foo;
"
`;
exports[`leak.js 1`] = `
"/** @flow */
/** @flow */
/* This test documents an example we ran into of a type annotation leaking.
*
@ -226,20 +226,20 @@ function foo(x: { [key: string]: mixed }) {
function bar(y: MyObj): string {
return y.foo;
}
"
`;
exports[`other.js 1`] = `
"class C { }
class C { }
module.exports = (C: any);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class C {}
module.exports = (C: any);
"
`;
exports[`scope.js 1`] = `
"type Merge<T> = (a: T, b: T) => T;
type Merge<T> = (a: T, b: T) => T;
// hypothetical immutable map
declare class Map<K,V> {
@ -292,14 +292,14 @@ class Foo<A> {
};
}
}
"
`;
exports[`test.js 1`] = `
"var C = require('./other');
var C = require('./other');
((0: C): string);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var C = require(\\"./other\\");
var C = require("./other");
((0: C): string);
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`A.js 1`] = `
"type T = any;
type T = any;
export default class {
p: T;
@ -20,20 +20,20 @@ export default class {
this.p = 0;
}
}
"
`;
exports[`B.js 1`] = `
"import A from \\"./A\\"
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,12 +1,12 @@
// 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;
@ -21,7 +21,7 @@ export default class {
* @flow
*/
import type T from \\"T\\";
import type T from "T";
export default class {
p: T;
@ -30,15 +30,15 @@ export default class {
this.p = 0;
}
}
"
`;
exports[`B.js 1`] = `
"/**
/**
* @flow
*/
import A from \\"A\\"
import A from "A"
class B extends A {
p: string; // OK, string ~> any
@ -48,21 +48,21 @@ class B extends A {
* @flow
*/
import A from \\"A\\";
import A from "A";
class B extends A {
p: string; // OK, string ~> any
}
"
`;
exports[`T.js 1`] = `
"/**
/**
* @providesModule T
*/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/**
* @providesModule T
*/
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`any.js 1`] = `
"// @flow
// @flow
function foo(x:any):any { return x; }
function bar(x:any):mixed { return x; }
@ -26,22 +26,22 @@ function qux(x: mixed): any {
var x: string = foo(0);
var y: string = bar(0);
var z: string = qux(0);
"
`;
exports[`anyexportflowfile.js 1`] = `
"// @flow
// @flow
module.exports = ((x: any) => x: any);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow
module.exports = ((x: any) => x: any);
"
`;
exports[`flowfixme.js 1`] = `
"/*
/*
FlowFixMe is a synonym for any, used by the Flow team to
signal a needed mod to JS devs.
@ -88,11 +88,11 @@ var x: string = foo(0);
var y: string = bar(0);
var z: string = qux(0);
var w: string = baz(0);
"
`;
exports[`flowissue.js 1`] = `
"/*
/*
$FlowIssue is a synonym for any, used by JS devs to signal
a potential typechecker bug to the Flow team.
@ -139,22 +139,22 @@ var x: string = foo(0);
var y: string = bar(0);
var z: string = qux(0);
var w: string = baz(0);
"
`;
exports[`nonflowfile.js 1`] = `
"// @noflow
// @noflow
module.exports = (x) => x;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @noflow
module.exports = x => x;
"
`;
exports[`propagate.js 1`] = `
"// @flow
// @flow
declare class C {
bar(n1: number, n2: number): number;
@ -192,24 +192,24 @@ 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);
}
}
"
`;
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
* annotation - without it, the body of the if will be unreachable
@ -236,5 +236,5 @@ function foo(o: ?AsyncRequest) {
var n: number = o;
}
}
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Arith.js 1`] = `
"
/* @providesModule Arith */
function num(x:number) { }
@ -10,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
@ -56,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
},
@ -80,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) {
@ -101,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
@ -147,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
},
@ -171,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) {
@ -183,16 +183,16 @@ let tests = [
(z + x: empty); // error, string ~> empty
}
];
"
`;
exports[`exponent.js 1`] = `
"/* @flow */
/* @flow */
let x: number = 2 ** 3;
x **= 4;
let y: string = \\"123\\";
let y: string = "123";
y **= 2; // error
1 + 2 ** 3 + 4;
@ -204,17 +204,17 @@ 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;
2 ** 2;
(-2) ** 2;
"
`;
exports[`generic.js 1`] = `
"/* @flow */
/* @flow */
function f<A>(a: A): A { return a + a; } // error
function f<A,B>(a: A, b: B): A {return a + b; } // error
@ -239,11 +239,11 @@ function f<A, B>(a: A, b: B): B {
function f<A, B>(a: A, b: B): B {
return b + a;
} // error
"
`;
exports[`mult.js 1`] = `
"/* @flow */
/* @flow */
function num(x:number) { }
@ -253,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 */
@ -266,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[`relational.js 1`] = `
"/* @flow */
/* @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
@ -306,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
@ -333,5 +333,5 @@ let tests = [
x > z;
}
];
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"/* @flow */
/* @flow */
function filterOutVoids<T> (arr: Array<?T>): Array<T> {
return arr.filter(Boolean)
@ -20,11 +20,11 @@ function filterOutVoids<T>(arr: Array<?T>): Array<T> {
function filterOutSmall(arr: Array<?number>): Array<?number> {
return arr.filter(num => num && num > 10);
}
"
`;
exports[`test2.js 1`] = `
"/* @flow */
/* @flow */
function filterItems(items: Array<string|number>): Array<string|number> {
return items.map(item => {
@ -45,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;
@ -54,8 +54,8 @@ 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,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"var A = [1,2,3];
var A = [1,2,3];
var B = [...A];
var C = [1,2,3];
B.sort((a, b) => a - b);
@ -16,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,18 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`array_lib.js 1`] = `
"/* @flow */
/* @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];
@ -46,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);
@ -65,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];
@ -73,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:
@ -109,17 +109,17 @@ 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,14 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Arrays.js 1`] = `
"
/* @providesModule Arrays */
function foo(x:string) { }
var a = [];
a[0] = 1;
a[1] = \\"...\\";
a[1] = "...";
foo(a[1]);
var y;
@ -34,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 */
@ -47,7 +47,7 @@ function foo(x: string) {}
var a = [];
a[0] = 1;
a[1] = \\"...\\";
a[1] = "...";
foo(a[1]);
var y;
@ -73,17 +73,17 @@ 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[`numeric_elem.js 1`] = `
"var arr = [];
var arr = [];
var day = new Date;
// Date instances are numeric (see Flow_js.numeric) and thus can index into
@ -98,5 +98,5 @@ var day = new Date();
// arrays.
arr[day] = 0;
(arr[day]: string); // error: number ~> string
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`advanced_arrows.js 1`] = `
"/**
/**
* @flow
*/
@ -11,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
@ -23,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[`arrows.js 1`] = `
"function selectBestEffortImageForWidth(
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];
}
@ -45,11 +45,11 @@ 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,10 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`async.js 1`] = `
"// @flow
// @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> {
@ -29,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
}
@ -56,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> {
@ -82,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
}
@ -114,11 +114,11 @@ class C {
var obj = { f: async () => await 1 };
var objf: () => Promise<number> = obj.f;
"
`;
exports[`async_base_class.js 1`] = `
"// This is kind of weird, but it should parse. This works in babel without the
// 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
// that is probably not important to support.
@ -147,11 +147,11 @@ async function foo() {
class Bar extends (await P) {}
return Bar;
}
"
`;
exports[`async_parse.js 1`] = `
"async function f() {}
async function f() {}
async function ft<T>(a: T) {}
class C {
@ -200,22 +200,22 @@ console.log(x.async);
var async = 3;
var y = { async };
"
`;
exports[`async_promise.js 1`] = `
"async function f(): Promise<number> {
async function f(): Promise<number> {
return Promise.resolve(1);
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
async function f(): Promise<number> {
return Promise.resolve(1);
}
"
`;
exports[`async_return_void.js 1`] = `
"// @flow
// @flow
async function foo1(): Promise<string> {
return;
@ -244,11 +244,11 @@ async function foo3(): Promise<string> {
function bar() {}
return bar();
}
"
`;
exports[`async2.js 1`] = `
"// @flow
// @flow
// misc basic
@ -274,7 +274,7 @@ function test1() {
function test2() {
async function voidoid1() {
console.log(\\"HEY\\");
console.log("HEY");
}
var voidoid2: () => Promise<void> = voidoid1; // ok
@ -287,7 +287,7 @@ function test2() {
function test3() {
async function voidoid4(): Promise<void> { // ok
console.log(\\"HEY\\");
console.log("HEY");
}
}
@ -298,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");
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -335,7 +335,7 @@ function test1() {
function test2() {
async function voidoid1() {
console.log(\\"HEY\\");
console.log("HEY");
}
var voidoid2: () => Promise<void> = voidoid1; // ok
@ -349,7 +349,7 @@ function test2() {
function test3() {
async function voidoid4(): Promise<void> {
// ok
console.log(\\"HEY\\");
console.log("HEY");
}
}
@ -361,21 +361,21 @@ 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[`async3.js 1`] = `
"// @flow
// @flow
/**
* test nested-promise unwrapping.
@ -439,11 +439,11 @@ async function baz() {
// Promise ~> string error for the same reason
var c: string = a;
}
"
`;
exports[`await_parse.js 1`] = `
"async function f() { await 1; }
async function f() { await 1; }
async function ft<T>(a: T) { await 1; }
class C {
@ -522,5 +522,5 @@ console.log(x.await);
var await = 3;
var y = { await };
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`delegate_yield.js 1`] = `
"async function *delegate_next() {
async function *delegate_next() {
async function *inner() {
var x: void = yield; // error: number ~> void
}
@ -54,11 +54,11 @@ async function* delegate_return() {
}
var x: void = yield* inner(); // error: number ~> void
}
"
`;
exports[`generator.js 1`] = `
"declare interface File {
declare interface File {
readLine(): Promise<string>;
close(): void;
EOF: boolean;
@ -79,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
}
}
@ -105,15 +105,15 @@ 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[`return.js 1`] = `
"declare var gen: AsyncGenerator<void,string,void>;
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
@ -121,7 +121,7 @@ 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 {
@ -130,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
}
@ -144,7 +144,7 @@ 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 {
@ -153,16 +153,16 @@ async function* refuse_return() {
return 0;
}
}
refuse_return().return(\\"string\\").then(result => {
refuse_return().return("string").then(result => {
if (result.done) {
(result.value: string); // error: number | void ~> string
}
});
"
`;
exports[`throw.js 1`] = `
"async function *catch_return() {
async function *catch_return() {
try {
yield 0;
} catch (e) {
@ -171,7 +171,7 @@ exports[`throw.js 1`] = `
}
(async () => {
catch_return().throw(\\"\\").then(({value}) => {
catch_return().throw("").then(({value}) => {
if (value !== undefined) {
(value: void); // error: number ~> void
}
@ -188,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
}
@ -204,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
}
@ -221,11 +221,11 @@ 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,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`customfun.js 1`] = `
"// @flow
// @flow
declare var idx: $Facebookism$Idx;
declare var merge: $Facebookism$Merge;
@ -24,14 +24,14 @@ declare var objectGetPrototypeOf: Object$GetPrototypeOf;
declare var objectAssign: Object$Assign;
m;
"
`;
exports[`unknown.js 1`] = `
"// @noflow
module.exports = { x: { y: \\"\\" } };
// @noflow
module.exports = { x: { y: "" } };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @noflow
module.exports = { x: { y: \\"\\" } };
"
module.exports = { x: { y: "" } };
`;

View File

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

View File

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

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`in.js 1`] = `
"// @flow
// @flow
let tests = [
// objects on RHS
@ -9,7 +9,7 @@ let tests = [
('foo' in {});
('foo' in { foo: null });
(0 in {});
(0 in { \\"0\\": null });
(0 in { "0": null });
},
// arrays on RHS
@ -61,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
@ -99,19 +99,19 @@ let tests = [
// in predicates
function() {
if (\\"foo\\" in 123) {
if ("foo" in 123) {
} // error
if (!\\"foo\\" in {}) {
if (!"foo" in {}) {
} // error, !'foo' is a boolean
if (!(\\"foo\\" in {})) {
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,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`const.js 1`] = `
"const x = 0;
const x = 0;
// errors: const cannot be reassigned
x++;
@ -19,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
@ -47,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
@ -56,11 +56,11 @@ declare var bazzes: { baz: string }[];
for (const { baz } of bazzes) {
(baz: number); // error: string ~> number
}
"
`;
exports[`rebinding.js 1`] = `
"/* @flow
/* @flow
* test errors on illegal rebinding/reassignment
*
* type class let const var (reassign)
@ -455,16 +455,16 @@ function fn_params_clash_fn_binding(x, y) {
let x = 0; // error: x already bound
var y = 0; // OK
}
"
`;
exports[`scope.js 1`] = `
"function block_scope() {
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
}
}
@ -472,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;
}
}
@ -488,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) {
@ -558,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
@ -573,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
}
}
@ -582,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;
}
}
@ -598,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 */; ; ) {
}
}
@ -674,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
@ -684,11 +684,11 @@ function default_param_2() {
return x;
}
}
"
`;
exports[`tdz.js 1`] = `
"/** @flow */
/** @flow */
// -- types ---
@ -742,7 +742,7 @@ 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...
@ -846,7 +846,7 @@ function f3() {
}
var s2: string = foo(); // ok, hoisted outer not clobbered
function foo() {
return \\"\\";
return "";
}
}
@ -899,5 +899,5 @@ f(a); // error: undefined ~/> number
a = 10;
f(a); // ok, a: number (not ?number)
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`FormData.js 1`] = `
"/* @flow */
/* @flow */
// constructor
const a: FormData = new FormData(); // correct
@ -73,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
@ -145,11 +145,11 @@ for (let [x, y]: [string, number] of a.entries()) {
} // incorrect
for (let [x, y]: [number, number] of a.entries()) {
} // incorrect
"
`;
exports[`MutationObserver.js 1`] = `
"/* @flow */
/* @flow */
// constructor
function callback(arr: Array<MutationRecord>, observer: MutationObserver): void {
@ -196,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
@ -211,5 +211,5 @@ o.takeRecords(); // correct
// disconnect
o.disconnect(); // correct
"
`;

View File

@ -1,22 +1,22 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`scope.js 1`] = `
"function foo<X, Y:X>(x:X, y:Y):void { }
foo(0, \\"\\");
function foo<X, Y:X>(x:X, y:Y):void { }
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;
}
"
`;
exports[`test.js 1`] = `
"function foo<T: number>(x: T): T {
function foo<T: number>(x: T): T {
var _ = x * 1; // OK
var y: string = x; // error
return x; // OK
@ -34,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
@ -63,12 +63,12 @@ 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
var q: number = c.qux(0);
/* 2 more errors, since argument U = number is incompatible with T = string, and
* result T = string is incompatible with number */
"
`;

View File

@ -1,11 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`break.js 1`] = `
"function foo(b) {
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
@ -14,10 +14,10 @@ exports[`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;
@ -29,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
@ -47,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
@ -59,7 +59,7 @@ function test_const() {
let st: string = 'abc';
for (let i = 1; i < 100; i++) {
const fooRes: ?string = \\"HEY\\";
const fooRes: ?string = "HEY";
if (!fooRes) {
break;
}
@ -75,7 +75,7 @@ function foo(b) {
var z;
while (b) {
if (x == null) {
z = \\"\\";
z = "";
break;
}
var y: number = x; // error: boolean !~> number
@ -86,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;
@ -101,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
@ -120,7 +120,7 @@ function qux(b) {
while (b) {
var y: number = z;
if (b) {
z = \\"\\";
z = "";
continue;
} // error: string !~> number
z = 0;
@ -131,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;
}
@ -144,5 +144,5 @@ function test_const() {
return st;
}
"
`;

View File

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

View File

@ -1,25 +1,25 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`array.js 1`] = `
"var a = [\\"...\\"];
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 = 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;
});
@ -28,25 +28,25 @@ 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;
}
"
`;
exports[`genericfoo.js 1`] = `
"class Foo<T> {
class Foo<T> {
x:T;
self():Foo<T> { return this; }
map<U>(callbackfn: () => U): Foo<U> { return new Foo(); }
@ -71,5 +71,5 @@ class Foo<T> {
}
module.exports = Foo;
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"// @flow
// @flow
const Immutable = require('immutable');
@ -14,7 +14,7 @@ for (let [taskStatus, tasksMap] of tasksPerStatusMap) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow
const Immutable = require(\\"immutable\\");
const Immutable = require("immutable");
const tasksPerStatusMap = new Map(
[].map(taskStatus => [taskStatus, new Map()])
@ -22,11 +22,11 @@ const tasksPerStatusMap = new Map(
for (let [taskStatus, tasksMap] of tasksPerStatusMap) {
tasksPerStatusMap.set(taskStatus, Immutable.Map(tasksMap));
}
"
`;
exports[`test2.js 1`] = `
"/* @flow */
/* @flow */
declare class Bar<K> {
update<K_>(updater: (value: this) => Bar<K_>): Bar<K_>;
@ -60,11 +60,11 @@ declare var items: Bar<string>;
declare var updater: (value: Bar<string>) => Bar<string>;
foo(items, acc => acc.update(updater));
"
`;
exports[`test3.js 1`] = `
"// @flow
// @flow
declare class ImmBox<T> {
static <U>(x: any): ImmBox<U>;
@ -97,5 +97,5 @@ declare class Box<T> {
const outer = new Box();
const inner = outer.get();
outer.set(ImmBox(inner));
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`core.js 1`] = `
"declare class Array<T> {
declare class Array<T> {
@@iterator(): Iterator<T>;
map<U>(callbackfn: (value: T, index: number, array: Array<T>) => U, thisArg?: any): Array<U>;
}
@ -55,11 +55,11 @@ declare class Map<K, V> {
constructor(iterable: ?Iterable<[K, V]>): void,
set(key: K, value: V): Map<K, V>
}
"
`;
exports[`immutable.js 1`] = `
"declare module \\"immutable\\" {
declare module "immutable" {
declare class Map<K,V> {
static <K,V>(iter: Iterator<[K,V]>): Map<K,V>;
static <K:string,V>(object: {+[k:K]:V}): Map<K,V>;
@ -68,7 +68,7 @@ exports[`immutable.js 1`] = `
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
declare module \\"immutable\\" {
declare module "immutable" {
declare class Map<K, V> {
static <K, V>(iter: Iterator<[K, V]>): Map<K, V>,
static <K: string, V>(object: { +[k: K]: V }): Map<K, V>,
@ -76,5 +76,5 @@ declare module \\"immutable\\" {
set(key: K, value: V): this
}
}
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"// @flow
// @flow
function Foo(items: ?Iterable<number>) {
Iterable(items || []).size;
@ -12,5 +12,5 @@ function Foo(items: ?Iterable<number>) {
function Foo(items: ?Iterable<number>) {
Iterable(items || []).size;
}
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`immutable.js 1`] = `
"// Copyright 2004-present Facebook. All Rights Reserved.
// Copyright 2004-present Facebook. All Rights Reserved.
declare class Array<T> { }
@ -20,5 +20,5 @@ declare class Iterable<S> {
static <T>(iter: Array<T>): Iterable<T>,
size: number
}
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`A.js 1`] = `
"// You should be able to call objects with call properties
// You should be able to call objects with call properties
function a(f: { (): string }, g: { (x: number): string } ): string {
return f() + g(123);
}
@ -13,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
@ -44,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
@ -62,70 +62,70 @@ function f(): number {
var x = {};
return x();
}
"
`;
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\\"; };
// 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"; };
// ...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[`C.js 1`] = `
"// You should be able to use an object as a function
// You should be able to use an object as a function
function a(x: { (z: number): string }): (z: number) => string {
return x;
}
@ -194,22 +194,22 @@ function f(x: { (z: number): string }): Function {
function g(x: {}): Function {
return x; // error
}
"
`;
exports[`D.js 1`] = `
"// Multiple call properties should also be supported
// Multiple call properties should also be supported
function a(f: { (): string; (x: number): string }): string {
return f() + f(123);
}
// 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
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 {
@ -228,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
var c: { (): string, (x: number): string } = function(x: number): string {
return \\"hi\\";
return "hi";
};
// Only one call property needs to match the function
@ -245,11 +245,11 @@ function d(x: { (): string, (x: number): string }): () => string {
function e(x: { (): string, (x: number): string }): () => number {
return x;
}
"
`;
exports[`E.js 1`] = `
"// 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
@ -270,54 +270,54 @@ var b: { apply: Function } = function() {};
var f = function() {};
f.myProp = 123;
var c: { myProp: number } = f;
"
`;
exports[`F.js 1`] = `
"// You should be able to use an arrow function as an object with a call property
// 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,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`optional.js 1`] = `
"type F = {
type F = {
(x: string): number;
p?: string;
}
@ -22,11 +22,11 @@ function f(x) {
}
(f: F);
"
`;
exports[`primitives.js 1`] = `
"var x = Boolean(4);
var x = Boolean(4);
function foo(fn:(value:any)=>boolean) { }
foo(Boolean);
@ -69,5 +69,5 @@ type Callable = {
declare var callable: Callable;
callable(0); // error, number ~> string
callable.call(null, 0); // error, number ~> string
"
`;

View File

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

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`base_class.js 1`] = `
"// @flow
// @flow
class Base {
unannotatedField;
@ -82,14 +82,14 @@ class Base {
initializedField = 42;
initializedFieldWithThis = this.initializedField;
annotatedInitializedFieldValid: ?number = 42;
annotatedInitializedFieldInvalid: number = \\"asdf\\"; // Error: string ~> number
annotatedInitializedFieldInvalid: number = "asdf"; // Error: string ~> number
static unannotatedField;
static annotatedField: number;
static initializedField = \\"asdf\\";
static initializedField = "asdf";
static initializedFieldWithThis = this.initializedField;
static annotatedInitializedFieldValid: ?number = 42;
static annotatedInitializedFieldInvalid: number = \\"asdf\\"; // Error: string ~> number
static annotatedInitializedFieldInvalid: number = "asdf"; // Error: string ~> number
}
var o = new Base();
@ -146,11 +146,11 @@ var o = new Base();
(o.annotatedInitializedFieldInvalid: string); // Error: number ~> string
(Base.annotatedInitializedFieldInvalid: number);
(Base.annotatedInitializedFieldInvalid: string); // Error: number ~> string
"
`;
exports[`derived_class.js 1`] = `
"// @flow
// @flow
class Base {
base_unannotatedField;
@ -293,14 +293,14 @@ class Base {
base_initializedField = 42;
base_initializedFieldWithThis = this.base_initializedField;
base_annotatedInitializedFieldValid: ?number = 42;
base_annotatedInitializedFieldInvalid: number = \\"asdf\\"; // Error: string ~> number
base_annotatedInitializedFieldInvalid: number = "asdf"; // Error: string ~> number
static base_unannotatedField;
static base_annotatedField: number;
static base_initializedField = \\"asdf\\";
static base_initializedField = "asdf";
static base_initializedFieldWithThis = this.base_initializedField;
static base_annotatedInitializedFieldValid: ?number = 42;
static base_annotatedInitializedFieldInvalid: number = \\"asdf\\"; // Error: string ~> number
static base_annotatedInitializedFieldInvalid: number = "asdf"; // Error: string ~> number
inherited_initializer = 42;
static inherited_initializer = 42;
@ -312,14 +312,14 @@ class Child extends Base {
child_initializedField = 42;
child_initializedFieldWithThis = this.child_initializedField;
child_annotatedInitializedFieldValid: ?number = 42;
child_annotatedInitializedFieldInvalid: number = \\"asdf\\"; // Error: string ~> number
child_annotatedInitializedFieldInvalid: number = "asdf"; // Error: string ~> number
static child_unannotatedField;
static child_annotatedField: number;
static child_initializedField = \\"asdf\\";
static child_initializedField = "asdf";
static child_initializedFieldWithThis = this.child_initializedField;
static child_annotatedInitializedFieldValid: ?number = 42;
static child_annotatedInitializedFieldInvalid: number = \\"asdf\\"; // Error: string ~> number
static child_annotatedInitializedFieldInvalid: number = "asdf"; // Error: string ~> number
inherited_initializer;
static inherited_initializer;
@ -418,11 +418,11 @@ var o = new Child();
(o.inherited_initializer: string); // Error: number ~> string
(Child.inherited_initializer: number);
(Child.inherited_initializer: string); // Error: number ~> string
"
`;
exports[`generic_class.js 1`] = `
"// @flow
// @flow
/**
* Fields annotated with a generic should assume a type once the type param
@ -484,11 +484,11 @@ class ClassGenericInitialized<T, U> {
static invalid: T = 42; // Error: number ~> Generic<T>
static valid: T = ((42: any): T);
}
"
`;
exports[`scoping.js 1`] = `
"// @flow
// @flow
var someVar = 42;
@ -543,7 +543,7 @@ class Foo {
static selfTypedInit = new Foo();
constructor() {
var someVar = \\"asdf\\";
var someVar = "asdf";
}
}
@ -569,5 +569,5 @@ class Foo {
(new Foo().selfTypedInit: number); // Error: Foo ~> number
(Foo.selfTypedInit: Foo);
(Foo.selfTypedInit: number); // Error: Foo ~> number
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`class_method_default_parameters.js 1`] = `
"class A {
class A {
b: string;
@ -42,5 +42,5 @@ class A {
// error
}
}
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`with_munging.js 1`] = `
"/**
/**
* @flow
*/
@ -23,7 +23,7 @@ class Bar extends Foo {
class Foo {
_method(): string {
return \\"this is private\\";
return "this is private";
}
}
@ -32,11 +32,11 @@ class Bar extends Foo {
(this._method(): string); // error
}
}
"
`;
exports[`without_munging.js 1`] = `
"/**
/**
* @flow
* @preventMunge
*/
@ -60,7 +60,7 @@ class Bar extends Foo {
class Foo {
_method(): string {
return \\"this is not private\\";
return "this is not private";
}
}
@ -69,5 +69,5 @@ class Bar extends Foo {
(this._method(): string); // ok
}
}
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"class A {
class A {
static x: number;
static y: string;
static foo(x: number) { }
@ -14,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
@ -76,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
@ -128,5 +128,5 @@ module.exports = {
D: D,
E: E
};
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"/* @flow */
/* @flow */
class A {}
class B {}
@ -12,12 +12,12 @@ class A {}
class B {}
module.exports = { A, B };
"
`;
exports[`test2.js 1`] = `
"/* @flow */
var I = require(\\"./test.js\\");
/* @flow */
var I = require("./test.js");
class C extends I.A {}
@ -25,17 +25,17 @@ var x: I.A = new C();
var y: I.B = new C();
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */
var I = require(\\"./test.js\\");
var I = require("./test.js");
class C extends I.A {}
var x: I.A = new C();
var y: I.B = new C();
"
`;
exports[`test3.js 1`] = `
"class A<X, Y, Z> {}
class A<X, Y, Z> {}
class B extends A<string, number, bool> {}
class C<X, Y, Z> extends B {}
@ -48,11 +48,11 @@ class C<X, Y, Z> extends B {}
var c: C<number, string, Array<boolean>> = new C(); // none of the type args matter
var a: A<string, number, Array<boolean>> = c; // the third type arg is incorrect
"
`;
exports[`test4.js 1`] = `
"class C<X> { x: X; }
class C<X> { x: X; }
function foo<X>(c: C<X>, x: X) { }
@ -83,5 +83,5 @@ class D extends C<O> {
}
foo(new D(), { f_: 0 });
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"class A { }
class A { }
function foo(x: Class<A>): A {
return new x(); // OK
}
@ -24,11 +24,11 @@ class B {
function bar(x: Class<B>): B {
return new x(); // error (too few args)
}
"
`;
exports[`test2.js 1`] = `
"// A function to typecheck values against their types. Covariance of Class<.>
// A function to typecheck values against their types. Covariance of Class<.>
// makes it useless in such a function (when limited to classes and instances),
// since everything can be trivially satisfied by going to \`mixed\`.
declare function check<X>(cls: $Type<X>, inst: X): void;
@ -57,5 +57,5 @@ check(A, new B());
check(C, new A());
check(C, new B());
check(B, new C());
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`A.js 1`] = `
"class A {
class A {
foo(x:number):void { }
}
@ -12,11 +12,11 @@ class A {
}
module.exports = A;
"
`;
exports[`B.js 1`] = `
"var A = require('./A');
var A = require('./A');
class B extends A { }
@ -25,7 +25,7 @@ let b = new B();
module.exports = B;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var A = require(\\"./A\\");
var A = require("./A");
class B extends A {}
@ -33,11 +33,11 @@ let b = new B();
(b.foo: number); // error, number !~> function
module.exports = B;
"
`;
exports[`C.js 1`] = `
"var B = require('./B');
var B = require('./B');
class C extends B {
foo(x:string):void { }
@ -48,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 {}
@ -58,22 +58,22 @@ let c = new C();
(c.foo: number); // error, number !~> function
module.exports = C;
"
`;
exports[`D.js 1`] = `
"class D { }
class D { }
class E { }
new E().x
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class D {}
class E {}
new E().x;
"
`;
exports[`class_shapes.js 1`] = `
"/* @flow */
/* @flow */
type Foo = {
a: string; // exists in TestClass
@ -144,11 +144,11 @@ class Test2Class extends Test2Superclass {
var z = new Test2Class();
var w: Foo = z;
"
`;
exports[`expr.js 1`] = `
"var Bar = class Foo {
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
}
@ -210,11 +210,11 @@ var _Alias = class Alias {
};
var alias1: Alias = new _Alias(); // error: bad pun
var alias2: Alias = _Alias.factory(); // error: bad pun
"
`;
exports[`extends_any.js 1`] = `
"const Base: any = class {}
const Base: any = class {}
class Derived1 extends Base {}
class Derived2 extends Derived1 {
m() {}
@ -225,11 +225,11 @@ class Derived1 extends Base {}
class Derived2 extends Derived1 {
m() {}
}
"
`;
exports[`loc.js 1`] = `
"/* @flow */
/* @flow */
type Foo = number
@ -240,16 +240,16 @@ class Foo {} // error, shadows type Foo
type Foo = number;
class Foo {} // error, shadows type Foo
"
`;
exports[`statics.js 1`] = `
"/* @flow */
/* @flow */
class C {
static p: string;
}
C.p = \\"hi\\";
C.p = "hi";
// Class static fields are compatible with object types
(C: {p:string}); // ok
@ -263,7 +263,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
@ -271,5 +271,5 @@ C.p = \\"hi\\";
declare var o: { p: number };
(o: Class<C>); // error, object type incompatible with class type
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Closure.js 1`] = `
"/***
/***
* Test tracking of variable types across closure calls.
* @flow
*/
@ -11,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; }
@ -29,7 +29,7 @@ global_x = 42; // shouldn't pollute linear refinement
function local_func() {
var local_x = \\"hello\\";
var local_x = "hello";
function local_f() { }
function local_g() { local_x = 42; }
@ -46,7 +46,7 @@ function local_func() {
// global write from method
//
var global_y = \\"hello\\";
var global_y = "hello";
var global_o = {
f: function() { },
@ -66,7 +66,7 @@ global_y = 42; // shouldn't pollute linear refinement
function local_meth() {
var local_y = \\"hello\\";
var local_y = "hello";
var local_o = {
f: function() { },
@ -92,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() {
@ -111,7 +111,7 @@ global_x = 42; // shouldn't pollute linear refinement
//
function local_func() {
var local_x = \\"hello\\";
var local_x = "hello";
function local_f() {}
function local_g() {
@ -130,7 +130,7 @@ function local_func() {
// global write from method
//
var global_y = \\"hello\\";
var global_y = "hello";
var global_o = {
f: function() {},
@ -151,7 +151,7 @@ global_y = 42; // shouldn't pollute linear refinement
//
function local_meth() {
var local_y = \\"hello\\";
var local_y = "hello";
var local_o = {
f: function() {},
@ -168,18 +168,18 @@ function local_meth() {
local_y = 42; // shouldn't pollute linear refinement
}
"
`;
exports[`cond_havoc.js 1`] = `
"// @flow
// @flow
// from sam, https://github.com/facebook/flow/issues/780
// call to f() within if should properly havoc x.
//
function example(b: bool): number {
var x = 0;
function f() { x = \\"\\" }
function f() { x = "" }
if (b) {
f();
}
@ -194,18 +194,18 @@ function example(b: bool): number {
function example(b: boolean): number {
var x = 0;
function f() {
x = \\"\\";
x = "";
}
if (b) {
f();
}
return x; // error, string ~/~> number (return type anno) TODO
}
"
`;
exports[`const.js 1`] = `
"/***
/***
* consts retain refinements
* @flow
*/
@ -232,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
}
}
@ -282,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
@ -314,5 +314,5 @@ function h(x: number | string | boolean) {
// in a galaxy far far away
call_me();
"
`;

View File

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

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"var ColorId = {
var ColorId = {
RED: 'R',
GREEN: 'G',
BLUE: 'B',
@ -26,15 +26,15 @@ 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 = {
@ -43,16 +43,16 @@ var ColorIdToNumber = {
[ColorId.BLUE]: ColorNumber.BLUE
};
(ColorIdToNumber[ColorId.RED]: \\"ffffff\\"); // oops
(ColorIdToNumber[ColorId.RED]: "ffffff"); // oops
ColorIdToNumber.XXX; // oops
module.exports = { ColorId, ColorNumber };
"
`;
exports[`test2.js 1`] = `
"var { ColorId, ColorNumber } = require('./test');
var { ColorId, ColorNumber } = require('./test');
var ColorIdToNumber = {
[ColorId.RED]: ColorNumber.RED,
[ColorId.GREEN]: ColorNumber.GREEN,
@ -63,41 +63,41 @@ var ColorIdToNumber = {
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[`test3.js 1`] = `
"var { ColorId } = require('./test');
var { ColorId } = require('./test');
var ColorIdToNumber = require('./test2');
(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[`test4.js 1`] = `
"module.exports = 'hello';
module.exports = 'hello';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
module.exports = \\"hello\\";
"
module.exports = "hello";
`;
exports[`test5.js 1`] = `
"var hello = require('./test4');
var hello = require('./test4');
var dummy = require('./test');
module.exports = {
...dummy,
@ -105,27 +105,27 @@ module.exports = {
...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[`test6.js 1`] = `
"var o = require('./test5');
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[`test7.js 1`] = `
"var obj = {x: 0, m() { return this.x }}
var obj = {x: 0, m() { return this.x }}
var x: string = obj['m'](); // error, number ~> string
var arr = [function() { return this.length }];
@ -137,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() {
@ -145,5 +145,5 @@ var arr = [
}
];
var y: string = arr[0](); // error: number ~> string
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`conditional.js 1`] = `
"/* @flow */
/* @flow */
function a(): number {
var x: ?string = null;
@ -51,5 +51,5 @@ function d(): string {
var x: ?number = null;
return x != null ? x : x != null;
}
"
`;

View File

@ -1,8 +1,8 @@
// 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
"
var x: number = "not a number"; // Error: string ~> number
`;

View File

@ -1,8 +1,8 @@
// 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
"
var x: number = "not a number"; // No error
`;

View File

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

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"/*
/*
* @flow
*/
@ -18,11 +18,11 @@ foo('Hello, world!');
*/
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,14 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`foo.js 1`] = `
"/* @flow */
/* @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,12 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`foo.js 1`] = `
"/* @flow */
/* @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,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`main.js 1`] = `
"// @flow
// @flow
import {test} from 'testmodule';
@ -10,9 +10,9 @@ 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,12 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`testmodule.js 1`] = `
"// @flow
// @flow
export let test = 42;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow
export let test = 42;
"
`;

View File

@ -1,14 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"// @flow
// @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,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`A.js 1`] = `
"/* @flow */
/* @flow */
var m1 = require('1DoesntExist');
import {numVal as numVal1} from '1DoesntExist';
@ -17,8 +17,8 @@ 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;
@ -26,13 +26,13 @@ var a_2: number = numVal1;
//
// 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[`Exists.js 1`] = `
"/**
/**
* @providesModule Exists
* @flow
*/
@ -49,5 +49,5 @@ module.exports = {
module.exports = {
numVal: 42
};
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`A.js 1`] = `
"/* @flow */
/* @flow */
var m1 = require('./1DoesntExist');
var a_1: number = m1.numVal;
@ -29,34 +29,34 @@ 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[`Exists.js 1`] = `
"/* @flow */
/* @flow */
module.exports = {
numVal: 42
@ -67,5 +67,5 @@ module.exports = {
module.exports = {
numVal: 42
};
"
`;

View File

@ -1,18 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`toplevel.js 1`] = `
"// @flow
// @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,12 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`index.js 1`] = `
"// @flow
// @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,12 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`index.js 1`] = `
"// @flow
// @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,18 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`sublevel.js 1`] = `
"// @flow
// @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,13 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`index.js 1`] = `
"// @flow
// @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,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`chain.js 1`] = `
"/* @flow */
/* @flow */
class A {
_property1: number;
@ -14,7 +14,7 @@ class A {
return 1;
}
static _sMethod(): string {
return \\"some string\\";
return "some string";
}
}
A._sProperty = 48;
@ -25,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 */
@ -49,7 +49,7 @@ class A {
return 1;
}
static _sMethod(): string {
return \\"some string\\";
return "some string";
}
}
A._sProperty = 48;
@ -60,21 +60,21 @@ 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[`commonjs_export.js 1`] = `
"/* @flow */
/* @flow */
class C {
_p: string;
@ -89,16 +89,16 @@ class C {
}
module.exports = new C();
"
`;
exports[`commonjs_import.js 1`] = `
"/* @flow */
/* @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,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`chain.js 1`] = `
"/* @flow */
/* @flow */
class A {
_property1: number;
@ -14,7 +14,7 @@ class A {
return 1;
}
static _sMethod(): string {
return \\"some string\\";
return "some string";
}
}
A._sProperty = 48;
@ -25,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 */
@ -49,7 +49,7 @@ class A {
return 1;
}
static _sMethod(): string {
return \\"some string\\";
return "some string";
}
}
A._sProperty = 48;
@ -60,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,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"/**
/**
* test handling of const params
* - reassignment prohibited
* - durable refinements
@ -17,7 +17,7 @@ exports[`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
@ -47,7 +47,7 @@ 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
@ -62,5 +62,5 @@ function durable_refi(x: ?number) {
};
}
}
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`constructor.js 1`] = `
"class C {
class C {
constructor() { }
}
@ -37,14 +37,14 @@ declare class Bar<T> {}
declare class Foo<T> {
constructor<U>(iterable: U): Bar<U>
}
(new Foo(\\"x\\"): Bar<string>); // ok
(new Foo("x"): Bar<string>); // ok
(new Foo(123): Bar<string>); // error, number !~> string
// also overrides when it returns a different specialization of the same class
declare class Baz<T> {
constructor<U>(iterable: U): Baz<U>
}
(new Baz(\\"x\\"): Baz<string>); // ok
(new Baz("x"): Baz<string>); // ok
(new Baz(123): Baz<string>); // error, number !~> string
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`constructors.js 1`] = `
"// Foo is a class-like function
// Foo is a class-like function
function Foo() {
this.x = 0; // constructs objects with property x
}
@ -48,11 +48,11 @@ interface IFoo extends IFooPrototype {
static y: boolean // error, should have declared static y: number instead
}
exports.Foo2 = (Foo: Class<IFoo>);
"
`;
exports[`test.js 1`] = `
"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();
@ -62,14 +62,14 @@ 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,17 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`dummy.js 1`] = `
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`;
exports[`test.js 1`] = `
"require('./dummy');
require('./dummy');
var xxx = 0;
xxx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
require(\\"./dummy\\");
require("./dummy");
var xxx = 0;
xxx;
"
`;

View File

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

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`boolean.js 1`] = `
"// @flow
// @flow
// Boolean (the class) tests. booleans (the literals) are not part of core.js
@ -15,7 +15,7 @@ let tests = [
new Boolean(false);
new Boolean(NaN);
new Boolean(undefined);
new Boolean(\\"\\");
new Boolean("");
},
// toString
@ -40,7 +40,7 @@ let tests = [
Boolean(false);
Boolean(NaN);
Boolean(undefined);
Boolean(\\"\\");
Boolean("");
},
];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -58,7 +58,7 @@ let tests = [
new Boolean(false);
new Boolean(NaN);
new Boolean(undefined);
new Boolean(\\"\\");
new Boolean("");
},
// toString
@ -83,14 +83,14 @@ let tests = [
Boolean(false);
Boolean(NaN);
Boolean(undefined);
Boolean(\\"\\");
Boolean("");
}
];
"
`;
exports[`map.js 1`] = `
"// @flow
// @flow
function* generator(): Iterable<[string, number]> {
while (true) {
@ -127,7 +127,7 @@ let tests = [
function* generator(): Iterable<[string, number]> {
while (true) {
yield [\\"foo\\", 123];
yield ["foo", 123];
}
}
@ -136,30 +136,30 @@ 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[`regexp.js 1`] = `
"// @flow
// @flow
let tests = [
// constructor
@ -194,35 +194,35 @@ 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[`weakset.js 1`] = `
"// @flow
// @flow
let ws = new WeakSet();
let obj: Object = {};
@ -263,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);
@ -281,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" };
}
}
@ -295,5 +295,5 @@ function* numbers(): Iterable<number> {
}
let ws5 = new WeakSet(numbers()); // error, must be objects
"
`;

View File

@ -1,10 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = `
"type CovArrayVerbose<X,Y:X> = Array<Y>;
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>;
@ -24,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>;
@ -54,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>;
@ -76,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>;
@ -102,5 +102,5 @@ n.x = [0];
(n.foo()[0]: string); // not an error!
*/
"
`;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`crash.js 1`] = `
"// This file triggers a violation of the \\"disjoint-or-nested ranges invariant\\"
// This file triggers a violation of the "disjoint-or-nested ranges invariant"
// that we implicitly assume in type-at-pos and coverage implementations. In
// particular, when unchecked it causes a crash with coverage --color.
@ -13,7 +13,7 @@ declare module bar {
// TODO
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// This file triggers a violation of the \\"disjoint-or-nested ranges invariant\\"
// This file triggers a violation of the "disjoint-or-nested ranges invariant"
// that we implicitly assume in type-at-pos and coverage implementations. In
// particular, when unchecked it causes a crash with coverage --color.
@ -22,11 +22,11 @@ declare module foo {
declare module bar {
// TODO
}
"
`;
exports[`declare_module.js 1`] = `
"// check coverage of declare module
// check coverage of declare module
declare module foo {
}
@ -35,20 +35,20 @@ declare module foo {
declare module foo {
}
"
`;
exports[`no_pragma.js 1`] = `
"let x = 0;
let x = 0;
(x: string);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
let x = 0;
(x: string);
"
`;
exports[`non-termination.js 1`] = `
"// This file triggers a violation of the \\"disjoint-or-nested ranges invariant\\"
// This file triggers a violation of the "disjoint-or-nested ranges invariant"
// that we implicitly assume in type-at-pos and coverage implementations. In
// particular, when unchecked it causes non-termination with coverage --color.
@ -63,7 +63,7 @@ declare module bar {
declare class qux {
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// This file triggers a violation of the \\"disjoint-or-nested ranges invariant\\"
// This file triggers a violation of the "disjoint-or-nested ranges invariant"
// that we implicitly assume in type-at-pos and coverage implementations. In
// particular, when unchecked it causes non-termination with coverage --color.
@ -73,5 +73,5 @@ declare module bar {
// TODO
}
declare class qux {}
"
`;

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