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": [ "setupFiles": [
"<rootDir>/tests_config/run_spec.js" "<rootDir>/tests_config/run_spec.js"
], ],
"snapshotSerializers": [
"<rootDir>/tests_config/raw-serializer.js"
],
"testRegex": "jsfmt\\.spec\\.js$", "testRegex": "jsfmt\\.spec\\.js$",
"testPathIgnorePatterns": [ "testPathIgnorePatterns": [
"tests/new_react", "tests/new_react",

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,8 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`assignment_expression.js 1`] = ` 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; this.size = this._origin = this._capacity = 0;
"
`; `;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`binary.js 1`] = ` exports[`binary.js 1`] = `
"(class {}) + 1; (class {}) + 1;
(class a {}) + 1; (class a {}) + 1;
(class extends b {}) + 1; (class extends b {}) + 1;
(class a extends b {}) + 1; (class a extends b {}) + 1;
@ -10,11 +10,11 @@ exports[`binary.js 1`] = `
(class a {} + 1); (class a {} + 1);
(class extends b {} + 1); (class extends b {} + 1);
(class a extends b {} + 1); (class a extends b {} + 1);
"
`; `;
exports[`break.js 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() {} method() {}
} }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -23,18 +23,18 @@ class MyContractSelectionWidget
implements SomethingLarge { implements SomethingLarge {
method() {} method() {}
} }
"
`; `;
exports[`call.js 1`] = ` exports[`call.js 1`] = `
"(class {})(class {}); (class {})(class {});
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(class {}(class {})); (class {}(class {}));
"
`; `;
exports[`empty.js 1`] = ` exports[`empty.js 1`] = `
"class A { class A {
// comment // comment
} }
@ -61,21 +61,21 @@ class A {}
class A { class A {
m() {} m() {}
} }
"
`; `;
exports[`member.js 1`] = ` exports[`member.js 1`] = `
"(class {})[1]; (class {})[1];
(class {}).a; (class {}).a;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(class {}[1]); (class {}[1]);
(class {}.a); (class {}.a);
"
`; `;
exports[`ternary.js 1`] = ` exports[`ternary.js 1`] = `
"if (1) (class {}) ? 1 : 2; 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 // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`assignment-pattern.js 1`] = ` exports[`assignment-pattern.js 1`] = `
"const { a /* comment */ = 1 } = b; const { a /* comment */ = 1 } = b;
const { c = 1 /* comment */ } = d; const { c = 1 /* comment */ } = d;
@ -15,11 +15,11 @@ const { c = 1 /* comment */ } = d;
let { let {
a = b //comment a = b //comment
} = c; } = c;
"
`; `;
exports[`before-comma.js 1`] = ` exports[`before-comma.js 1`] = `
"const foo = { const foo = {
a: 'a' /* comment for this line */, a: 'a' /* comment for this line */,
/* Section B */ /* Section B */
@ -27,16 +27,16 @@ exports[`before-comma.js 1`] = `
}; };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const foo = { const foo = {
a: \\"a\\" /* comment for this line */, a: "a" /* comment for this line */,
/* Section B */ /* Section B */
b: \\"b\\" b: "b"
}; };
"
`; `;
exports[`blank.js 1`] = ` exports[`blank.js 1`] = `
"// This file only // This file only
// has comments. This comment // has comments. This comment
// should still exist // should still exist
// //
@ -79,11 +79,11 @@ exports[`blank.js 1`] = `
// comment // comment
// comment // comment
"
`; `;
exports[`call_comment.js 1`] = ` exports[`call_comment.js 1`] = `
"render( // Warm any cache render( // Warm any cache
<ChildUpdates renderAnchor={true} anchorClassOn={true} />, <ChildUpdates renderAnchor={true} anchorClassOn={true} />,
container container
); );
@ -104,11 +104,11 @@ React.render(
<ChildUpdates renderAnchor={true} anchorClassOn={true} />, <ChildUpdates renderAnchor={true} anchorClassOn={true} />,
container container
); );
"
`; `;
exports[`dangling.js 1`] = ` exports[`dangling.js 1`] = `
"var x = {/* dangling */}; var x = {/* dangling */};
var x = { var x = {
// dangling // dangling
}; };
@ -135,11 +135,11 @@ declare class Foo extends Qux<string> {
/* dangling */ /* dangling */
} }
export /* dangling */{}; export /* dangling */{};
"
`; `;
exports[`dangling_array.js 1`] = ` exports[`dangling_array.js 1`] = `
"expect(() => {}).toTriggerReadyStateChanges([ expect(() => {}).toTriggerReadyStateChanges([
// Nothing. // Nothing.
]); ]);
@ -152,11 +152,11 @@ expect(() => {}).toTriggerReadyStateChanges(
); );
[1 /*first comment */, 2 /* second comment */, 3]; [1 /*first comment */, 2 /* second comment */, 3];
"
`; `;
exports[`dangling_for.js 1`] = ` exports[`dangling_for.js 1`] = `
"for // comment for // comment
(;;); (;;);
for /* comment */(;;); for /* comment */(;;);
@ -166,37 +166,37 @@ for (;;);
/* comment */ /* comment */
for (;;); for (;;);
"
`; `;
exports[`export.js 1`] = ` exports[`export.js 1`] = `
"export //comment export //comment
{} {}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//comment //comment
export {}; export {};
"
`; `;
exports[`first-line.js 1`] = ` exports[`first-line.js 1`] = `
"a // comment a // comment
b b
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a; // comment a; // comment
b; b;
"
`; `;
exports[`flow_union.js 1`] = ` exports[`flow_union.js 1`] = `
"type UploadState<E, EM, D> type UploadState<E, EM, D>
// The upload hasnt begun yet // The upload hasnt begun yet
= {type: \\"Not_begun\\"} = {type: "Not_begun"}
// The upload timed out // The upload timed out
| {type: \\"Timed_out\\"} | {type: "Timed_out"}
// Failed somewhere on the line // Failed somewhere on the line
| {type: \\"Failed\\", error: E, errorMsg: EM} | {type: "Failed", error: E, errorMsg: EM}
// Uploading to aws3 and CreatePostMutation succeeded // Uploading to aws3 and CreatePostMutation succeeded
| {type: \\"Success\\", data: D}; | {type: "Success", data: D};
type UploadState<E, EM, D> type UploadState<E, EM, D>
// The upload hasnt begun yet // The upload hasnt begun yet
@ -210,13 +210,13 @@ type UploadState<E, EM, D>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
type UploadState<E, EM, D> = type UploadState<E, EM, D> =
// The upload hasnt begun yet // The upload hasnt begun yet
| { type: \\"Not_begun\\" } | { type: "Not_begun" }
// The upload timed out // The upload timed out
| { type: \\"Timed_out\\" } | { type: "Timed_out" }
// Failed somewhere on the line // Failed somewhere on the line
| { type: \\"Failed\\", error: E, errorMsg: EM } | { type: "Failed", error: E, errorMsg: EM }
// Uploading to aws3 and CreatePostMutation succeeded // Uploading to aws3 and CreatePostMutation succeeded
| { type: \\"Success\\", data: D }; | { type: "Success", data: D };
type UploadState<E, EM, D> = type UploadState<E, EM, D> =
// The upload hasnt begun yet // The upload hasnt begun yet
@ -227,22 +227,22 @@ type UploadState<E, EM, D> =
| C | C
// Uploading to aws3 and CreatePostMutation succeeded // Uploading to aws3 and CreatePostMutation succeeded
| D; | D;
"
`; `;
exports[`function-declaration.js 1`] = ` exports[`function-declaration.js 1`] = `
"function a(/* comment */) {} // comment function a(/* comment */) {} // comment
function b() {} // comment function b() {} // comment
function c(/* comment */ argA, argB, argC) {} // comment function c(/* comment */ argA, argB, argC) {} // comment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function a(/* comment */) {} // comment function a(/* comment */) {} // comment
function b() {} // comment function b() {} // comment
function c(/* comment */ argA, argB, argC) {} // comment function c(/* comment */ argA, argB, argC) {} // comment
"
`; `;
exports[`if.js 1`] = ` exports[`if.js 1`] = `
"if (1) if (1)
// comment // comment
{ {
false false
@ -292,11 +292,11 @@ if (1) {
} else { } else {
// comment // comment
} }
"
`; `;
exports[`issues.js 1`] = ` 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); this.call(a, /* comment */ b);
function f( function f(
@ -354,11 +354,11 @@ export type AsyncExecuteOptions = child_process$execFileOpts & {
// optional trailing comma gets moved all the way to the beginning // optional trailing comma gets moved all the way to the beginning
const regex = new RegExp( const regex = new RegExp(
'^\\\\\\\\s*' + // beginning of the line '^\\\\s*' + // beginning of the line
'name\\\\\\\\s*=\\\\\\\\s*' + // name = 'name\\\\s*=\\\\s*' + // name =
'[\\\\'\\"]' + // opening quotation mark '[\\'"]' + // opening quotation mark
escapeStringRegExp(target.name) + // target name escapeStringRegExp(target.name) + // target name
'[\\\\'\\"]' + // closing quotation mark '[\\'"]' + // closing quotation mark
',?$', // optional trailing comma ',?$', // optional trailing comma
); );
@ -425,30 +425,30 @@ throw new ProcessSystemError({
export type BuckWebSocketMessage = export type BuckWebSocketMessage =
| { | {
// Not actually from Buck - this is to let the receiver know that the socket is connected. // 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 progressValue: number
} }
| { | {
type: \\"BuildFinished\\", type: "BuildFinished",
exitCode: number 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 // 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 // optional trailing comma gets moved all the way to the beginning
const regex = new RegExp( const regex = new RegExp(
\\"^\\\\\\\\s*\\" + // beginning of the line "^\\\\s*" + // beginning of the line
\\"name\\\\\\\\s*=\\\\\\\\s*\\" + // name = "name\\\\s*=\\\\s*" + // name =
\\"['\\\\\\"]\\" + // opening quotation mark "['\\"]" + // opening quotation mark
escapeStringRegExp(target.name) + // target name escapeStringRegExp(target.name) + // target name
\\"['\\\\\\"]\\" + // closing quotation mark "['\\"]" + // closing quotation mark
\\",?$\\" // optional trailing comma ",?$" // optional trailing comma
); );
// The comment is moved and doesn't trigger the eslint rule anymore // 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 // Comments disappear in-between MemberExpressions
Observable.of(process) Observable.of(process)
@ -510,18 +510,18 @@ if (1) {
} }
// The comment makes the line break in a weird way // 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 // The closing paren is printed on the same line as the comment
foo( foo(
{} {}
// Hi // Hi
); );
"
`; `;
exports[`jsx.js 1`] = ` exports[`jsx.js 1`] = `
"<div> <div>
{ {
/* comment */ /* comment */
} }
@ -655,11 +655,11 @@ exports[`jsx.js 1`] = `
<div> <div>
{/*<div> Some very v ery very very long line to break line width limit </div>*/} {/*<div> Some very v ery very very long line to break line width limit </div>*/}
</div>; </div>;
"
`; `;
exports[`last-arg.js 1`] = ` exports[`last-arg.js 1`] = `
"type f = ( type f = (
currentRequest: {a: number}, currentRequest: {a: number},
// TODO this is a very very very very long comment that makes it go > 80 columns // TODO this is a very very very very long comment that makes it go > 80 columns
) => number; ) => number;
@ -726,11 +726,11 @@ function f(
): number { ): number {
return a + 1; return a + 1;
} }
"
`; `;
exports[`preserve-new-line-last.js 1`] = ` exports[`preserve-new-line-last.js 1`] = `
"function f() { function f() {
a a
/* eslint-disable */ /* eslint-disable */
} }
@ -773,11 +773,11 @@ function name() {
// comment3 why func3 commented // comment3 why func3 commented
// func3() // func3()
} }
"
`; `;
exports[`return-statement.js 1`] = ` exports[`return-statement.js 1`] = `
"function jsx() { function jsx() {
return ( return (
// Comment // Comment
<div /> <div />
@ -1026,17 +1026,17 @@ function taggedTemplate() {
function inlineComment() { function inlineComment() {
return /* hi */ 42 || 42; return /* hi */ 42 || 42;
} }
"
`; `;
exports[`switch.js 1`] = ` exports[`switch.js 1`] = `
"switch (node && node.type) { switch (node && node.type) {
case \\"Property\\": case "Property":
case \\"MethodDefinition\\": case "MethodDefinition":
prop = node.key; prop = node.key;
break; break;
case \\"MemberExpression\\": case "MemberExpression":
prop = node.property; prop = node.property;
break; break;
@ -1044,38 +1044,38 @@ exports[`switch.js 1`] = `
} }
switch (foo) { switch (foo) {
case \\"bar\\": case "bar":
doThing() doThing()
// no default // no default
} }
switch (foo) { switch (foo) {
case \\"bar\\": //comment case "bar": //comment
doThing(); //comment doThing(); //comment
case \\"baz\\": case "baz":
doOtherThing(); //comment doOtherThing(); //comment
} }
switch (foo) { switch (foo) {
case \\"bar\\": { case "bar": {
doThing(); doThing();
} //comment } //comment
case \\"baz\\": { case "baz": {
doThing(); doThing();
} //comment } //comment
} }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
switch (node && node.type) { switch (node && node.type) {
case \\"Property\\": case "Property":
case \\"MethodDefinition\\": case "MethodDefinition":
prop = node.key; prop = node.key;
break; break;
case \\"MemberExpression\\": case "MemberExpression":
prop = node.property; prop = node.property;
break; break;
@ -1083,34 +1083,34 @@ switch (node && node.type) {
} }
switch (foo) { switch (foo) {
case \\"bar\\": case "bar":
doThing(); doThing();
// no default // no default
} }
switch (foo) { switch (foo) {
case \\"bar\\": //comment case "bar": //comment
doThing(); //comment doThing(); //comment
case \\"baz\\": case "baz":
doOtherThing(); //comment doOtherThing(); //comment
} }
switch (foo) { switch (foo) {
case \\"bar\\": { case "bar": {
doThing(); doThing();
} //comment } //comment
case \\"baz\\": { case "baz": {
doThing(); doThing();
} //comment } //comment
} }
"
`; `;
exports[`template-literal.js 1`] = ` exports[`template-literal.js 1`] = `
"\` \`
\${a // comment \${a // comment
} }
@ -1135,11 +1135,11 @@ a}
/*comment*/ /*comment*/
d}; d};
\`; \`;
"
`; `;
exports[`try.js 1`] = ` exports[`try.js 1`] = `
"// comment 1 // comment 1
try { try {
// comment 2 // comment 2
} }
@ -1163,11 +1163,11 @@ try {
// comment 5 // comment 5
// comment 7 // comment 7
} }
"
`; `;
exports[`variable_declarator.js 1`] = ` exports[`variable_declarator.js 1`] = `
"let obj = // Comment let obj = // Comment
{ {
key: 'val' key: 'val'
} }
@ -1208,41 +1208,41 @@ let obj = [
let obj = let obj =
// Comment // Comment
{ {
key: \\"val\\" key: "val"
}; };
let obj = let obj =
// Comment // Comment
{ {
key: \\"val\\" key: "val"
}; };
let obj = { let obj = {
// Comment // Comment
key: \\"val\\" key: "val"
}; };
let obj = { let obj = {
// Comment // Comment
key: \\"val\\" key: "val"
}; };
let obj = let obj =
// Comment // Comment
[\\"val\\"]; ["val"];
let obj = let obj =
// Comment // Comment
[\\"val\\"]; ["val"];
let obj = [ let obj = [
// Comment // Comment
\\"val\\" "val"
]; ];
let obj = [ let obj = [
// Comment // Comment
\\"val\\" "val"
]; ];
"
`; `;

View File

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

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`comments.js 1`] = ` exports[`comments.js 1`] = `
"var inspect = 4 === util.inspect.length var inspect = 4 === util.inspect.length
? // node <= 0.8.x ? // node <= 0.8.x
(function(v, colors) { (function(v, colors) {
return util.inspect(v, void 0, void 0, colors); return util.inspect(v, void 0, void 0, colors);
@ -28,16 +28,16 @@ const extractTextPluginOptions = shouldUseRelativeAssetPaths
const extractTextPluginOptions = shouldUseRelativeAssetPaths const extractTextPluginOptions = shouldUseRelativeAssetPaths
? // Making sure that the publicPath goes back to to build folder. ? // 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. 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\\" const { configureStore } = process.env.NODE_ENV === "production"
? require(\\"./configureProdStore\\") // a ? require("./configureProdStore") // a
: require(\\"./configureDevStore\\"); // b : require("./configureDevStore"); // b
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var inspect = 4 === util.inspect.length var inspect = 4 === util.inspect.length
? // node <= 0.8.x ? // node <= 0.8.x
@ -61,42 +61,42 @@ var inspect = 4 === util.inspect.length
const extractTextPluginOptions = shouldUseRelativeAssetPaths const extractTextPluginOptions = shouldUseRelativeAssetPaths
? // Making sure that the publicPath goes back to to build folder. ? // 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 const extractTextPluginOptions = shouldUseRelativeAssetPaths
? // Making sure that the publicPath goes back to to build folder. ? // 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. 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\\" const { configureStore } = process.env.NODE_ENV === "production"
? require(\\"./configureProdStore\\") // a ? require("./configureProdStore") // a
: require(\\"./configureDevStore\\"); // b : require("./configureDevStore"); // b
"
`; `;
exports[`new-expression.js 1`] = ` exports[`new-expression.js 1`] = `
"const testConsole = new TestConsole( const testConsole = new TestConsole(
config.useStderr ? process.stderr : process.stdout config.useStderr ? process.stderr : process.stdout
); );
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const testConsole = new TestConsole( const testConsole = new TestConsole(
config.useStderr ? process.stderr : process.stdout config.useStderr ? process.stderr : process.stdout
); );
"
`; `;
exports[`no-confusing-arrow.js 1`] = ` exports[`no-confusing-arrow.js 1`] = `
"// no-confusing-arrow // no-confusing-arrow
var x = a => 1 ? 2 : 3; var x = a => 1 ? 2 : 3;
var x = a <= 1 ? 2 : 3; var x = a <= 1 ? 2 : 3;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// no-confusing-arrow // no-confusing-arrow
var x = a => (1 ? 2 : 3); var x = a => (1 ? 2 : 3);
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 // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`mobx.js 1`] = ` exports[`mobx.js 1`] = `
"import {observable} from \\"mobx\\"; import {observable} from "mobx";
@observer class OrderLine { @observer class OrderLine {
@observable price:number = 0; @observable price:number = 0;
@ -20,7 +20,7 @@ exports[`mobx.js 1`] = `
} }
} }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import { observable } from \\"mobx\\"; import { observable } from "mobx";
@observer class OrderLine { @observer class OrderLine {
@observable price: number = 0; @observable price: number = 0;
@ -38,11 +38,11 @@ import { observable } from \\"mobx\\";
this.price = price; this.price = price;
} }
} }
"
`; `;
exports[`multiple.js 1`] = ` exports[`multiple.js 1`] = `
"const dog = { const dog = {
@readonly @readonly
@nonenumerable @nonenumerable
@doubledValue @doubledValue
@ -55,11 +55,11 @@ const dog = {
@doubledValue @doubledValue
legs: 4 legs: 4
}; };
"
`; `;
exports[`redux.js 1`] = ` exports[`redux.js 1`] = `
"@connect(mapStateToProps, mapDispatchToProps) @connect(mapStateToProps, mapDispatchToProps)
export class MyApp extends React.Component {} export class MyApp extends React.Component {}
@connect(state => ({ todos: state.todos })) @connect(state => ({ todos: state.todos }))
@ -70,5 +70,5 @@ export class MyApp extends React.Component {}
@connect(state => ({ todos: state.todos })) @connect(state => ({ todos: state.todos }))
export class Home extends React.Component {} export class Home extends React.Component {}
"
`; `;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,8 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`body.js 1`] = ` exports[`body.js 1`] = `
"export default (class {}[1] = 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 // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`export.js 1`] = ` exports[`export.js 1`] = `
"export * as ns from 'mod'; export * as ns from 'mod';
export v from 'mod'; export v from 'mod';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
export * as ns from \\"mod\\"; export * as ns from "mod";
export v from \\"mod\\"; export v from "mod";
"
`; `;

View File

@ -1,13 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = ` 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 { export {
value1, value1,
@ -15,12 +15,12 @@ export {
value3, value3,
value4 as value4_renamed, value4 as value4_renamed,
value5 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 // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`no_regression.js 1`] = ` exports[`no_regression.js 1`] = `
"// Ensure no regression. // Ensure no regression.
\\"use strict\\"; "use strict";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Ensure no regression. // Ensure no regression.
\\"use strict\\"; "use strict";
"
`; `;
exports[`use_strict.js 1`] = ` exports[`use_strict.js 1`] = `
"// Parentheses around expression statement should be preserved in this case. // Parentheses around expression statement should be preserved in this case.
(\\"use strict\\"); ("use strict");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Parentheses around expression statement should be preserved in this case. // 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 // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = ` exports[`test.js 1`] = `
"setTimeout(function() { setTimeout(function() {
thing(); thing();
}, 500); }, 500);
[\\"a\\",\\"b\\",\\"c\\"].reduce(function(item, thing) { ["a","b","c"].reduce(function(item, thing) {
return thing + \\" \\" + item; return thing + " " + item;
}, \\"letters:\\") }, "letters:")
func(() => { func(() => {
thing(); thing();
@ -66,7 +66,7 @@ func(() => {
compose((a) => { compose((a) => {
return a.thing; return a.thing;
}, b => { }, b => {
return b + \\"\\"; return b + "";
}); });
compose((a) => { compose((a) => {
@ -93,9 +93,9 @@ setTimeout(function() {
thing(); thing();
}, 500); }, 500);
[\\"a\\", \\"b\\", \\"c\\"].reduce(function(item, thing) { ["a", "b", "c"].reduce(function(item, thing) {
return thing + \\" \\" + item; return thing + " " + item;
}, \\"letters:\\"); }, "letters:");
func(() => { func(() => {
thing(); thing();
@ -166,7 +166,7 @@ compose(
return a.thing; return a.thing;
}, },
b => { b => {
return b + \\"\\"; return b + "";
} }
); );
@ -196,5 +196,5 @@ setTimeout(
}, },
500 500
); );
"
`; `;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`break-continue.js 1`] = ` exports[`break-continue.js 1`] = `
"function foo() { function foo() {
while(true) { break; } while(true) { break; }
} }
@ -20,11 +20,11 @@ function bar() {
continue L; continue L;
} while (false); } while (false);
} }
"
`; `;
exports[`return.js 1`] = ` exports[`return.js 1`] = `
"function bar(x:number) { } function bar(x:number) { }
function foo() { function foo() {
var x = null; var x = null;
if (x == null) return; if (x == null) return;
@ -37,16 +37,16 @@ function foo() {
if (x == null) return; if (x == null) return;
bar(x); bar(x);
} }
"
`; `;
exports[`toplevel_throw.js 1`] = ` exports[`toplevel_throw.js 1`] = `
"// @flow // @flow
throw new Error('foo'); // no error throw new Error('foo'); // no error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow // @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 // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`annot.js 1`] = ` exports[`annot.js 1`] = `
"function foo(str:string, i:number):string { function foo(str:string, i:number):string {
return str; return str;
} }
var bar: (str:number, i:number)=> string = foo; var bar: (str:number, i:number)=> string = foo;
var qux = function(str:string, i:number):number { return foo(str,i); } 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 // array sugar
var array: number[] = [1,2,\\"...\\"]; var array: number[] = [1,2,"..."];
var matrix: number[][] = [[1,2],[3,4]]; var matrix: number[][] = [[1,2],[3,4]];
var matrix_parens: (number[])[] = matrix; 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_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; var array_of_tuple_parens: ([number, string])[] = array_of_tuple;
type ObjType = { 'bar-foo': string; 'foo-bar': number; }; 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 // param type annos are strict UBs like var type annos
function param_anno(n:number):void { function param_anno(n:number):void {
n = \\"hey\\"; // error n = "hey"; // error
} }
// another error on param UB, more typical of www (mis)use-cases // 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 } = { var obj: { str: string, i: number, j: boolean } = {
str: \\"...\\", str: "...",
i: \\"...\\", i: "...",
k: false k: false
}; };
var arr: Array<number> = [1, 2, \\"...\\"]; var arr: Array<number> = [1, 2, "..."];
// array sugar // array sugar
var array: number[] = [1, 2, \\"...\\"]; var array: number[] = [1, 2, "..."];
var matrix: number[][] = [[1, 2], [3, 4]]; var matrix: number[][] = [[1, 2], [3, 4]];
var matrix_parens: number[][] = matrix; 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_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; var array_of_tuple_parens: [number, string][] = array_of_tuple;
type ObjType = { \\"bar-foo\\": string, \\"foo-bar\\": number }; type ObjType = { "bar-foo": string, "foo-bar": number };
var test_obj: ObjType = { \\"bar-foo\\": \\"23\\" }; var test_obj: ObjType = { "bar-foo": "23" };
// param type annos are strict UBs like var type annos // param type annos are strict UBs like var type annos
function param_anno(n: number): void { function param_anno(n: number): void {
n = \\"hey\\"; // error n = "hey"; // error
} }
// another error on param UB, more typical of www (mis)use-cases // 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 { function barfoo(n: number | null | void): ?number {
return n; return n;
} }
"
`; `;
exports[`forward_ref.js 1`] = ` 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 { function bar(): MyClass {
return null; // forward ref ok, null ~> class error return null; // forward ref ok, null ~> class error
@ -166,22 +166,22 @@ function foo() {
class MyClass {} // looked up above class MyClass {} // looked up above
} }
"
`; `;
exports[`issue-530.js 1`] = ` exports[`issue-530.js 1`] = `
"function foo(...args: any) { } function foo(...args: any) { }
module.exports = foo; module.exports = foo;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function foo(...args: any) {} function foo(...args: any) {}
module.exports = foo; module.exports = foo;
"
`; `;
exports[`leak.js 1`] = ` exports[`leak.js 1`] = `
"/** @flow */ /** @flow */
/* This test documents an example we ran into of a type annotation leaking. /* 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 { function bar(y: MyObj): string {
return y.foo; return y.foo;
} }
"
`; `;
exports[`other.js 1`] = ` exports[`other.js 1`] = `
"class C { } class C { }
module.exports = (C: any); module.exports = (C: any);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class C {} class C {}
module.exports = (C: any); module.exports = (C: any);
"
`; `;
exports[`scope.js 1`] = ` exports[`scope.js 1`] = `
"type Merge<T> = (a: T, b: T) => T; type Merge<T> = (a: T, b: T) => T;
// hypothetical immutable map // hypothetical immutable map
declare class Map<K,V> { declare class Map<K,V> {
@ -292,14 +292,14 @@ class Foo<A> {
}; };
} }
} }
"
`; `;
exports[`test.js 1`] = ` exports[`test.js 1`] = `
"var C = require('./other'); var C = require('./other');
((0: C): string); ((0: C): string);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var C = require(\\"./other\\"); var C = require("./other");
((0: C): string); ((0: C): string);
"
`; `;

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Arith.js 1`] = ` exports[`Arith.js 1`] = `
"
/* @providesModule Arith */ /* @providesModule Arith */
function num(x:number) { } function num(x:number) { }
@ -10,7 +10,7 @@ function str(x:string) { }
function foo() { function foo() {
var x = 0; var x = 0;
var y = \\"...\\"; var y = "...";
var z = {}; var z = {};
num(x+x); num(x+x);
num(x+y); // error num(x+y); // error
@ -56,20 +56,20 @@ num(true + null); // === 1
num(undefined + true); // === NaN num(undefined + true); // === NaN
num(true + undefined); // === NaN num(true + undefined); // === NaN
str(\\"foo\\" + true); // error str("foo" + true); // error
str(true + \\"foo\\"); // error str(true + "foo"); // error
str(\\"foo\\" + null); // error str("foo" + null); // error
str(null + \\"foo\\"); // error str(null + "foo"); // error
str(\\"foo\\" + undefined); // error str("foo" + undefined); // error
str(undefined + \\"foo\\"); // error str(undefined + "foo"); // error
let tests = [ let tests = [
function(x: mixed, y: mixed) { function(x: mixed, y: mixed) {
(x + y); // error (x + y); // error
(x + 0); // error (x + 0); // error
(0 + x); // error (0 + x); // error
(x + \\"\\"); // error (x + ""); // error
(\\"\\" + x); // error ("" + x); // error
(x + {}); // error (x + {}); // error
({} + x); // error ({} + x); // error
}, },
@ -80,8 +80,8 @@ let tests = [
function() { function() {
((1 + {}): number); // error: object !~> number ((1 + {}): number); // error: object !~> number
(({} + 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) { function(x: any, y: number, z: string) {
@ -101,7 +101,7 @@ function str(x: string) {}
function foo() { function foo() {
var x = 0; var x = 0;
var y = \\"...\\"; var y = "...";
var z = {}; var z = {};
num(x + x); num(x + x);
num(x + y); // error num(x + y); // error
@ -147,20 +147,20 @@ num(true + null); // === 1
num(undefined + true); // === NaN num(undefined + true); // === NaN
num(true + undefined); // === NaN num(true + undefined); // === NaN
str(\\"foo\\" + true); // error str("foo" + true); // error
str(true + \\"foo\\"); // error str(true + "foo"); // error
str(\\"foo\\" + null); // error str("foo" + null); // error
str(null + \\"foo\\"); // error str(null + "foo"); // error
str(\\"foo\\" + undefined); // error str("foo" + undefined); // error
str(undefined + \\"foo\\"); // error str(undefined + "foo"); // error
let tests = [ let tests = [
function(x: mixed, y: mixed) { function(x: mixed, y: mixed) {
x + y; // error x + y; // error
x + 0; // error x + 0; // error
0 + x; // error 0 + x; // error
x + \\"\\"; // error x + ""; // error
\\"\\" + x; // error "" + x; // error
x + {}; // error x + {}; // error
({} + x); // error ({} + x); // error
}, },
@ -171,8 +171,8 @@ let tests = [
function() { function() {
(1 + {}: number); // error: object !~> number (1 + {}: number); // error: object !~> number
({} + 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) { function(x: any, y: number, z: string) {
@ -183,16 +183,16 @@ let tests = [
(z + x: empty); // error, string ~> empty (z + x: empty); // error, string ~> empty
} }
]; ];
"
`; `;
exports[`exponent.js 1`] = ` exports[`exponent.js 1`] = `
"/* @flow */ /* @flow */
let x: number = 2 ** 3; let x: number = 2 ** 3;
x **= 4; x **= 4;
let y: string = \\"123\\"; let y: string = "123";
y **= 2; // error y **= 2; // error
1 + 2 ** 3 + 4; 1 + 2 ** 3 + 4;
@ -204,17 +204,17 @@ y **= 2; // error
let x: number = 2 ** 3; let x: number = 2 ** 3;
x **= 4; x **= 4;
let y: string = \\"123\\"; let y: string = "123";
y **= 2; // error y **= 2; // error
1 + 2 ** 3 + 4; 1 + 2 ** 3 + 4;
2 ** 2; 2 ** 2;
(-2) ** 2; (-2) ** 2;
"
`; `;
exports[`generic.js 1`] = ` exports[`generic.js 1`] = `
"/* @flow */ /* @flow */
function f<A>(a: A): A { return a + a; } // error function f<A>(a: A): A { return a + a; } // error
function f<A,B>(a: A, b: B): A {return a + b; } // 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 { function f<A, B>(a: A, b: B): B {
return b + a; return b + a;
} // error } // error
"
`; `;
exports[`mult.js 1`] = ` exports[`mult.js 1`] = `
"/* @flow */ /* @flow */
function num(x:number) { } function num(x:number) { }
@ -253,7 +253,7 @@ num(1 * null);
let x: number = 2 * 3; let x: number = 2 * 3;
x *= 4; x *= 4;
let y: string = \\"123\\"; let y: string = "123";
y *= 2; // error y *= 2; // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */ /* @flow */
@ -266,23 +266,23 @@ num(1 * null);
let x: number = 2 * 3; let x: number = 2 * 3;
x *= 4; x *= 4;
let y: string = \\"123\\"; let y: string = "123";
y *= 2; // error y *= 2; // error
"
`; `;
exports[`relational.js 1`] = ` exports[`relational.js 1`] = `
"/* @flow */ /* @flow */
(1 < 2); (1 < 2);
(1 < \\"foo\\"); // error (1 < "foo"); // error
(\\"foo\\" < 1); // error ("foo" < 1); // error
(\\"foo\\" < \\"bar\\"); ("foo" < "bar");
(1 < {foo: 1}); // error (1 < {foo: 1}); // error
({foo: 1} < 1); // error ({foo: 1} < 1); // error
({foo: 1} < {foo: 1}); // error ({foo: 1} < {foo: 1}); // error
(\\"foo\\" < {foo: 1}); // error ("foo" < {foo: 1}); // error
({foo: 1} < \\"foo\\"); // error ({foo: 1} < "foo"); // error
var x = (null : ?number); var x = (null : ?number);
(1 < x); // 2 errors: null !~> number; undefined !~> number (1 < x); // 2 errors: null !~> number; undefined !~> number
@ -306,14 +306,14 @@ let tests = [
/* @flow */ /* @flow */
1 < 2; 1 < 2;
1 < \\"foo\\"; // error 1 < "foo"; // error
\\"foo\\" < 1; // error "foo" < 1; // error
\\"foo\\" < \\"bar\\"; "foo" < "bar";
1 < { foo: 1 }; // error 1 < { foo: 1 }; // error
({ foo: 1 } < 1); // error ({ foo: 1 } < 1); // error
({ foo: 1 } < { foo: 1 }); // error ({ foo: 1 } < { foo: 1 }); // error
\\"foo\\" < { foo: 1 }; // error "foo" < { foo: 1 }; // error
({ foo: 1 } < \\"foo\\"); // error ({ foo: 1 } < "foo"); // error
var x = (null: ?number); var x = (null: ?number);
1 < x; // 2 errors: null !~> number; undefined !~> number 1 < x; // 2 errors: null !~> number; undefined !~> number
@ -333,5 +333,5 @@ let tests = [
x > z; x > z;
} }
]; ];
"
`; `;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = ` exports[`test.js 1`] = `
"/* @flow */ /* @flow */
function filterOutVoids<T> (arr: Array<?T>): Array<T> { function filterOutVoids<T> (arr: Array<?T>): Array<T> {
return arr.filter(Boolean) return arr.filter(Boolean)
@ -20,11 +20,11 @@ function filterOutVoids<T>(arr: Array<?T>): Array<T> {
function filterOutSmall(arr: Array<?number>): Array<?number> { function filterOutSmall(arr: Array<?number>): Array<?number> {
return arr.filter(num => num && num > 10); return arr.filter(num => num && num > 10);
} }
"
`; `;
exports[`test2.js 1`] = ` exports[`test2.js 1`] = `
"/* @flow */ /* @flow */
function filterItems(items: Array<string|number>): Array<string|number> { function filterItems(items: Array<string|number>): Array<string|number> {
return items.map(item => { return items.map(item => {
@ -45,7 +45,7 @@ console.log(filteredItems);
function filterItems(items: Array<string | number>): Array<string | number> { function filterItems(items: Array<string | number>): Array<string | number> {
return items return items
.map(item => { .map(item => {
if (typeof item === \\"string\\") { if (typeof item === "string") {
return item.length > 2 ? item : null; return item.length > 2 ? item : null;
} else { } else {
return item * 10; return item * 10;
@ -54,8 +54,8 @@ function filterItems(items: Array<string | number>): Array<string | number> {
.filter(Boolean); .filter(Boolean);
} }
const filteredItems = filterItems([\\"foo\\", \\"b\\", 1, 2]); const filteredItems = filterItems(["foo", "b", 1, 2]);
console.log(filteredItems); console.log(filteredItems);
"
`; `;

View File

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

View File

@ -1,18 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`array_lib.js 1`] = ` exports[`array_lib.js 1`] = `
"/* @flow */ /* @flow */
function foo(x:string) { } function foo(x:string) { }
var a = [0]; 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 c: number = a[0];
var d: number = b[0]; var d: number = b[0];
var e:Array<string> = a.reverse(); var e:Array<string> = a.reverse();
var f = [\\"\\"]; var f = [""];
var g:number = f.map(function () { return 0; })[0]; var g:number = f.map(function () { return 0; })[0];
var h: Array<number> = [1,2,3]; var h: Array<number> = [1,2,3];
@ -46,13 +46,13 @@ function reduce_test() {
/* Added later, because the above is insufficient */ /* Added later, because the above is insufficient */
// acc is element type of array when no init is provided // acc is element type of array when no init is provided
[\\"\\"].reduce((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 [""].reduceRight((acc, str) => acc * str.length); // error, string ~> number
} }
function from_test() { function from_test() {
var a: Array<string> = Array.from([1, 2, 3], function(val, index) { 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) { var b: Array<string> = Array.from([1, 2, 3], function(val) {
return String(val); return String(val);
@ -65,7 +65,7 @@ function foo(x: string) {}
var a = [0]; var a = [0];
var b = a.map(function(x) { var b = a.map(function(x) {
foo(x); foo(x);
return \\"\\" + x; return "" + x;
}); });
var c: number = a[0]; var c: number = a[0];
@ -73,18 +73,18 @@ var d: number = b[0];
var e: Array<string> = a.reverse(); var e: Array<string> = a.reverse();
var f = [\\"\\"]; var f = [""];
var g: number = f.map(function() { var g: number = f.map(function() {
return 0; return 0;
})[0]; })[0];
var h: Array<number> = [1, 2, 3]; 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 j: Array<number | string> = h.concat(i);
var k: Array<number> = h.concat(h); var k: Array<number> = h.concat(h);
var l: Array<number> = h.concat(1, 2, 3); var l: Array<number> = h.concat(1, 2, 3);
var m: Array<number | string> = h.concat(\\"a\\", \\"b\\", \\"c\\"); var m: Array<number | string> = h.concat("a", "b", "c");
var n: Array<number> = h.concat(\\"a\\", \\"b\\", \\"c\\"); // Error var n: Array<number> = h.concat("a", "b", "c"); // Error
function reduce_test() { function reduce_test() {
/* Adapted from the following source: /* Adapted from the following source:
@ -109,17 +109,17 @@ function reduce_test() {
/* Added later, because the above is insufficient */ /* Added later, because the above is insufficient */
// acc is element type of array when no init is provided // acc is element type of array when no init is provided
[\\"\\"].reduce((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 [""].reduceRight((acc, str) => acc * str.length); // error, string ~> number
} }
function from_test() { function from_test() {
var a: Array<string> = Array.from([1, 2, 3], function(val, index) { 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) { var b: Array<string> = Array.from([1, 2, 3], function(val) {
return String(val); return String(val);
}); });
} }
"
`; `;

View File

@ -1,14 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Arrays.js 1`] = ` exports[`Arrays.js 1`] = `
"
/* @providesModule Arrays */ /* @providesModule Arrays */
function foo(x:string) { } function foo(x:string) { }
var a = []; var a = [];
a[0] = 1; a[0] = 1;
a[1] = \\"...\\"; a[1] = "...";
foo(a[1]); foo(a[1]);
var y; 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}, {x:0, y:0},
{x:0, y:0, a:true}, {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:1},
{x:0, y:0, c:\\"hey\\"} {x:0, y:0, c:"hey"}
]; ];
module.exports = \\"arrays\\"; module.exports = "arrays";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @providesModule Arrays */ /* @providesModule Arrays */
@ -47,7 +47,7 @@ function foo(x: string) {}
var a = []; var a = [];
a[0] = 1; a[0] = 1;
a[1] = \\"...\\"; a[1] = "...";
foo(a[1]); foo(a[1]);
var y; 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 }, { x: 0, y: 0 },
{ x: 0, y: 0, a: true }, { 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: 1 },
{ x: 0, y: 0, c: \\"hey\\" } { x: 0, y: 0, c: "hey" }
]; ];
module.exports = \\"arrays\\"; module.exports = "arrays";
"
`; `;
exports[`numeric_elem.js 1`] = ` exports[`numeric_elem.js 1`] = `
"var arr = []; var arr = [];
var day = new Date; var day = new Date;
// Date instances are numeric (see Flow_js.numeric) and thus can index into // Date instances are numeric (see Flow_js.numeric) and thus can index into
@ -98,5 +98,5 @@ var day = new Date();
// arrays. // arrays.
arr[day] = 0; arr[day] = 0;
(arr[day]: string); // error: number ~> string (arr[day]: string); // error: number ~> string
"
`; `;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`advanced_arrows.js 1`] = ` exports[`advanced_arrows.js 1`] = `
"/** /**
* @flow * @flow
*/ */
@ -11,7 +11,7 @@ var bad = (x: number): string => x; // Error!
var ident = <T>(x: T): T => x; var ident = <T>(x: T): T => x;
(ident(1): number); (ident(1): number);
(ident(\\"hi\\"): number); // Error (ident("hi"): number); // Error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/** /**
* @flow * @flow
@ -23,18 +23,18 @@ var bad = (x: number): string => x; // Error!
var ident = <T>(x: T): T => x; var ident = <T>(x: T): T => x;
(ident(1): number); (ident(1): number);
(ident(\\"hi\\"): number); // Error (ident("hi"): number); // Error
"
`; `;
exports[`arrows.js 1`] = ` exports[`arrows.js 1`] = `
"function selectBestEffortImageForWidth( function selectBestEffortImageForWidth(
maxWidth: number, maxWidth: number,
images: Array<Image> images: Array<Image>
): Image { ): Image {
var maxPixelWidth = maxWidth; var maxPixelWidth = maxWidth;
//images = images.sort(function (a, b) { return a.width - b.width }); //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) || return images.find(image => image.width >= maxPixelWidth) ||
images[images.length - 1]; images[images.length - 1];
} }
@ -45,11 +45,11 @@ function selectBestEffortImageForWidth(
): Image { ): Image {
var maxPixelWidth = maxWidth; var maxPixelWidth = maxWidth;
//images = images.sort(function (a, b) { return a.width - b.width }); //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 ( return (
images.find(image => image.width >= maxPixelWidth) || images.find(image => image.width >= maxPixelWidth) ||
images[images.length - 1] images[images.length - 1]
); );
} }
"
`; `;

View File

@ -1,10 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`async.js 1`] = ` exports[`async.js 1`] = `
"// @flow // @flow
// \\"For async functions, a Promise<T> is returned, // "For async functions, a Promise<T> is returned,
// and the type of return expressions must be T.\\" // and the type of return expressions must be T."
// //
async function f0(): Promise<number> { 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: // 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> { async function f4(p: Promise<number>): Promise<bool> {
return await p; // error, number != bool return await p; // error, number != bool
} }
@ -56,8 +56,8 @@ var objf : () => Promise<number> = obj.f;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow // @flow
// \\"For async functions, a Promise<T> is returned, // "For async functions, a Promise<T> is returned,
// and the type of return expressions must be T.\\" // and the type of return expressions must be T."
// //
async function f0(): Promise<number> { 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: // 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> { async function f4(p: Promise<number>): Promise<boolean> {
return await p; // error, number != bool return await p; // error, number != bool
} }
@ -114,11 +114,11 @@ class C {
var obj = { f: async () => await 1 }; var obj = { f: async () => await 1 };
var objf: () => Promise<number> = obj.f; var objf: () => Promise<number> = obj.f;
"
`; `;
exports[`async_base_class.js 1`] = ` exports[`async_base_class.js 1`] = `
"// This is kind of weird, but it should parse. This works in babel without the // 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) // parens around (await promise). From the es6 and async/await specs I (nmote)
// am not clear on whether it should. In any case it's a strange corner case // am not clear on whether it should. In any case it's a strange corner case
// that is probably not important to support. // that is probably not important to support.
@ -147,11 +147,11 @@ async function foo() {
class Bar extends (await P) {} class Bar extends (await P) {}
return Bar; return Bar;
} }
"
`; `;
exports[`async_parse.js 1`] = ` exports[`async_parse.js 1`] = `
"async function f() {} async function f() {}
async function ft<T>(a: T) {} async function ft<T>(a: T) {}
class C { class C {
@ -200,22 +200,22 @@ console.log(x.async);
var async = 3; var async = 3;
var y = { async }; var y = { async };
"
`; `;
exports[`async_promise.js 1`] = ` exports[`async_promise.js 1`] = `
"async function f(): Promise<number> { async function f(): Promise<number> {
return Promise.resolve(1); return Promise.resolve(1);
} }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
async function f(): Promise<number> { async function f(): Promise<number> {
return Promise.resolve(1); return Promise.resolve(1);
} }
"
`; `;
exports[`async_return_void.js 1`] = ` exports[`async_return_void.js 1`] = `
"// @flow // @flow
async function foo1(): Promise<string> { async function foo1(): Promise<string> {
return; return;
@ -244,11 +244,11 @@ async function foo3(): Promise<string> {
function bar() {} function bar() {}
return bar(); return bar();
} }
"
`; `;
exports[`async2.js 1`] = ` exports[`async2.js 1`] = `
"// @flow // @flow
// misc basic // misc basic
@ -274,7 +274,7 @@ function test1() {
function test2() { function test2() {
async function voidoid1() { async function voidoid1() {
console.log(\\"HEY\\"); console.log("HEY");
} }
var voidoid2: () => Promise<void> = voidoid1; // ok var voidoid2: () => Promise<void> = voidoid1; // ok
@ -287,7 +287,7 @@ function test2() {
function test3() { function test3() {
async function voidoid4(): Promise<void> { // ok async function voidoid4(): Promise<void> { // ok
console.log(\\"HEY\\"); console.log("HEY");
} }
} }
@ -298,14 +298,14 @@ function test3() {
function test4() { function test4() {
async function voidoid5(): void { // error, void != Promise<void> async function voidoid5(): void { // error, void != Promise<void>
console.log(\\"HEY\\"); console.log("HEY");
} }
} }
function test5() { function test5() {
async function voidoid6() async function voidoid6()
: Promise<number> { // error, number != void : Promise<number> { // error, number != void
console.log(\\"HEY\\"); console.log("HEY");
} }
} }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -335,7 +335,7 @@ function test1() {
function test2() { function test2() {
async function voidoid1() { async function voidoid1() {
console.log(\\"HEY\\"); console.log("HEY");
} }
var voidoid2: () => Promise<void> = voidoid1; // ok var voidoid2: () => Promise<void> = voidoid1; // ok
@ -349,7 +349,7 @@ function test2() {
function test3() { function test3() {
async function voidoid4(): Promise<void> { async function voidoid4(): Promise<void> {
// ok // ok
console.log(\\"HEY\\"); console.log("HEY");
} }
} }
@ -361,21 +361,21 @@ function test3() {
function test4() { function test4() {
async function voidoid5(): void { async function voidoid5(): void {
// error, void != Promise<void> // error, void != Promise<void>
console.log(\\"HEY\\"); console.log("HEY");
} }
} }
function test5() { function test5() {
async function voidoid6(): Promise<number> { async function voidoid6(): Promise<number> {
// error, number != void // error, number != void
console.log(\\"HEY\\"); console.log("HEY");
} }
} }
"
`; `;
exports[`async3.js 1`] = ` exports[`async3.js 1`] = `
"// @flow // @flow
/** /**
* test nested-promise unwrapping. * test nested-promise unwrapping.
@ -439,11 +439,11 @@ async function baz() {
// Promise ~> string error for the same reason // Promise ~> string error for the same reason
var c: string = a; var c: string = a;
} }
"
`; `;
exports[`await_parse.js 1`] = ` exports[`await_parse.js 1`] = `
"async function f() { await 1; } async function f() { await 1; }
async function ft<T>(a: T) { await 1; } async function ft<T>(a: T) { await 1; }
class C { class C {
@ -522,5 +522,5 @@ console.log(x.await);
var await = 3; var await = 3;
var y = { await }; var y = { await };
"
`; `;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`delegate_yield.js 1`] = ` exports[`delegate_yield.js 1`] = `
"async function *delegate_next() { async function *delegate_next() {
async function *inner() { async function *inner() {
var x: void = yield; // error: number ~> void var x: void = yield; // error: number ~> void
} }
@ -54,11 +54,11 @@ async function* delegate_return() {
} }
var x: void = yield* inner(); // error: number ~> void var x: void = yield* inner(); // error: number ~> void
} }
"
`; `;
exports[`generator.js 1`] = ` exports[`generator.js 1`] = `
"declare interface File { declare interface File {
readLine(): Promise<string>; readLine(): Promise<string>;
close(): void; close(): void;
EOF: boolean; EOF: boolean;
@ -79,7 +79,7 @@ async function* readLines(path) {
} }
async function f() { 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 (line: void); // error: string ~> void
} }
} }
@ -105,15 +105,15 @@ async function* readLines(path) {
} }
async function f() { 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 (line: void); // error: string ~> void
} }
} }
"
`; `;
exports[`return.js 1`] = ` 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 // You can pass whatever you like to return, it doesn't need to be related to
// the AsyncGenerator's return type // the AsyncGenerator's return type
@ -121,7 +121,7 @@ gen.return(0).then(result => {
(result.value: void); // error: string | number ~> void (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. // yielding or returning internally.
async function *refuse_return() { async function *refuse_return() {
try { try {
@ -130,7 +130,7 @@ async function *refuse_return() {
return 0; return 0;
} }
} }
refuse_return().return(\\"string\\").then(result => { refuse_return().return("string").then(result => {
if (result.done) { if (result.done) {
(result.value: string); // error: number | void ~> string (result.value: string); // error: number | void ~> string
} }
@ -144,7 +144,7 @@ gen.return(0).then(result => {
(result.value: void); // error: string | number ~> void (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. // yielding or returning internally.
async function* refuse_return() { async function* refuse_return() {
try { try {
@ -153,16 +153,16 @@ async function* refuse_return() {
return 0; return 0;
} }
} }
refuse_return().return(\\"string\\").then(result => { refuse_return().return("string").then(result => {
if (result.done) { if (result.done) {
(result.value: string); // error: number | void ~> string (result.value: string); // error: number | void ~> string
} }
}); });
"
`; `;
exports[`throw.js 1`] = ` exports[`throw.js 1`] = `
"async function *catch_return() { async function *catch_return() {
try { try {
yield 0; yield 0;
} catch (e) { } catch (e) {
@ -171,7 +171,7 @@ exports[`throw.js 1`] = `
} }
(async () => { (async () => {
catch_return().throw(\\"\\").then(({value}) => { catch_return().throw("").then(({value}) => {
if (value !== undefined) { if (value !== undefined) {
(value: void); // error: number ~> void (value: void); // error: number ~> void
} }
@ -188,7 +188,7 @@ async function *yield_return() {
} }
(async () => { (async () => {
yield_return().throw(\\"\\").then(({value}) => { yield_return().throw("").then(({value}) => {
if (value !== undefined) { if (value !== undefined) {
(value: void); // error: number ~> void (value: void); // error: number ~> void
} }
@ -204,7 +204,7 @@ async function* catch_return() {
} }
async () => { async () => {
catch_return().throw(\\"\\").then(({ value }) => { catch_return().throw("").then(({ value }) => {
if (value !== undefined) { if (value !== undefined) {
(value: void); // error: number ~> void (value: void); // error: number ~> void
} }
@ -221,11 +221,11 @@ async function* yield_return() {
} }
async () => { async () => {
yield_return().throw(\\"\\").then(({ value }) => { yield_return().throw("").then(({ value }) => {
if (value !== undefined) { if (value !== undefined) {
(value: void); // error: number ~> void (value: void); // error: number ~> void
} }
}); });
}; };
"
`; `;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`customfun.js 1`] = ` exports[`customfun.js 1`] = `
"// @flow // @flow
declare var idx: $Facebookism$Idx; declare var idx: $Facebookism$Idx;
declare var merge: $Facebookism$Merge; declare var merge: $Facebookism$Merge;
@ -24,14 +24,14 @@ declare var objectGetPrototypeOf: Object$GetPrototypeOf;
declare var objectAssign: Object$Assign; declare var objectAssign: Object$Assign;
m; m;
"
`; `;
exports[`unknown.js 1`] = ` exports[`unknown.js 1`] = `
"// @noflow // @noflow
module.exports = { x: { y: \\"\\" } }; module.exports = { x: { y: "" } };
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @noflow // @noflow
module.exports = { x: { y: \\"\\" } }; module.exports = { x: { y: "" } };
"
`; `;

View File

@ -1,8 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`client.js 1`] = ` exports[`client.js 1`] = `
"var y:number = x; 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 // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`lib.js 1`] = ` exports[`lib.js 1`] = `
"declare var x: string; 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 // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`in.js 1`] = ` exports[`in.js 1`] = `
"// @flow // @flow
let tests = [ let tests = [
// objects on RHS // objects on RHS
@ -9,7 +9,7 @@ let tests = [
('foo' in {}); ('foo' in {});
('foo' in { foo: null }); ('foo' in { foo: null });
(0 in {}); (0 in {});
(0 in { \\"0\\": null }); (0 in { "0": null });
}, },
// arrays on RHS // arrays on RHS
@ -61,31 +61,31 @@ let tests = [
let tests = [ let tests = [
// objects on RHS // objects on RHS
function() { function() {
\\"foo\\" in {}; "foo" in {};
\\"foo\\" in { foo: null }; "foo" in { foo: null };
0 in {}; 0 in {};
0 in { \\"0\\": null }; 0 in { "0": null };
}, },
// arrays on RHS // arrays on RHS
function() { function() {
\\"foo\\" in []; "foo" in [];
0 in []; 0 in [];
\\"length\\" in []; "length" in [];
}, },
// primitive classes on RHS // primitive classes on RHS
function() { function() {
\\"foo\\" in new String(\\"bar\\"); "foo" in new String("bar");
\\"foo\\" in new Number(123); "foo" in new Number(123);
}, },
// primitives on RHS // primitives on RHS
function() { function() {
\\"foo\\" in 123; // error "foo" in 123; // error
\\"foo\\" in \\"bar\\"; // error "foo" in "bar"; // error
\\"foo\\" in void 0; // error "foo" in void 0; // error
\\"foo\\" in null; // error "foo" in null; // error
}, },
// bogus stuff on LHS // bogus stuff on LHS
@ -99,19 +99,19 @@ let tests = [
// in predicates // in predicates
function() { function() {
if (\\"foo\\" in 123) { if ("foo" in 123) {
} // error } // error
if (!\\"foo\\" in {}) { if (!"foo" in {}) {
} // error, !'foo' is a boolean } // error, !'foo' is a boolean
if (!(\\"foo\\" in {})) { if (!("foo" in {})) {
} }
}, },
// annotations on RHS // annotations on RHS
function(x: Object, y: mixed) { function(x: Object, y: mixed) {
\\"foo\\" in x; // ok "foo" in x; // ok
\\"foo\\" in y; // error "foo" in y; // error
} }
]; ];
"
`; `;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`const.js 1`] = ` exports[`const.js 1`] = `
"const x = 0; const x = 0;
// errors: const cannot be reassigned // errors: const cannot be reassigned
x++; x++;
@ -19,8 +19,8 @@ x &= 0;
// regression tests -- OK to assign consts like this: // regression tests -- OK to assign consts like this:
const { foo } = { foo: \\"foo\\" } const { foo } = { foo: "foo" }
const [ bar ] = [\\"bar\\"]; const [ bar ] = ["bar"];
(foo: number); // error: string ~> number (foo: number); // error: string ~> number
(bar: number); // error: string ~> number (bar: number); // error: string ~> number
@ -47,8 +47,8 @@ x &= 0;
// regression tests -- OK to assign consts like this: // regression tests -- OK to assign consts like this:
const { foo } = { foo: \\"foo\\" }; const { foo } = { foo: "foo" };
const [bar] = [\\"bar\\"]; const [bar] = ["bar"];
(foo: number); // error: string ~> number (foo: number); // error: string ~> number
(bar: number); // error: string ~> number (bar: number); // error: string ~> number
@ -56,11 +56,11 @@ declare var bazzes: { baz: string }[];
for (const { baz } of bazzes) { for (const { baz } of bazzes) {
(baz: number); // error: string ~> number (baz: number); // error: string ~> number
} }
"
`; `;
exports[`rebinding.js 1`] = ` exports[`rebinding.js 1`] = `
"/* @flow /* @flow
* test errors on illegal rebinding/reassignment * test errors on illegal rebinding/reassignment
* *
* type class let const var (reassign) * 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 let x = 0; // error: x already bound
var y = 0; // OK var y = 0; // OK
} }
"
`; `;
exports[`scope.js 1`] = ` exports[`scope.js 1`] = `
"function block_scope() { function block_scope() {
let a: number = 0; let a: number = 0;
var b: number = 0; var b: number = 0;
{ {
let a = \\"\\"; // ok: local to block let a = ""; // ok: local to block
var b = \\"\\"; // error: string ~> number var b = ""; // error: string ~> number
} }
} }
@ -472,12 +472,12 @@ function switch_scope(x: string) {
let a: number = 0; let a: number = 0;
var b: number = 0; var b: number = 0;
switch (x) { switch (x) {
case \\"foo\\": case "foo":
let a = \\"\\"; // ok: local to switch let a = ""; // ok: local to switch
var b = \\"\\"; // error: string ~> number var b = ""; // error: string ~> number
break; break;
case \\"bar\\": case "bar":
let a = \\"\\"; // error: a already bound in switch let a = ""; // error: a already bound in switch
break; break;
} }
} }
@ -488,43 +488,43 @@ function switch_scope(x: string) {
function switch_scope2(x: number) { function switch_scope2(x: number) {
switch (x) { switch (x) {
case 0: case 0:
a = \\"\\"; // error: assign before declaration a = ""; // error: assign before declaration
break; break;
case 1: case 1:
var b = a; // error: use before declaration var b = a; // error: use before declaration
break; break;
case 2: case 2:
let a = \\"\\"; let a = "";
break; break;
case 3: case 3:
a = \\"\\"; // error: skipped initializer a = ""; // error: skipped initializer
break; break;
case 4: case 4:
var c:string = a; // error: skipped initializer var c:string = a; // error: skipped initializer
break; break;
} }
a = \\"\\"; // error: a no longer in scope a = ""; // error: a no longer in scope
} }
function try_scope() { function try_scope() {
let a: number = 0; let a: number = 0;
try { try {
let a = \\"\\"; // ok let a = ""; // ok
} catch (e) { } catch (e) {
let a = \\"\\"; // ok let a = ""; // ok
} finally { } finally {
let a = \\"\\"; // ok let a = ""; // ok
} }
} }
function for_scope_let() { function for_scope_let() {
let a: number = 0; let a: number = 0;
for (let a = \\"\\" /* ok: local to init */;;) {} for (let a = "" /* ok: local to init */;;) {}
} }
function for_scope_var() { function for_scope_var() {
var a: number = 0; var a: number = 0;
for (var a = \\"\\" /* error: string ~> number */;;) {} for (var a = "" /* error: string ~> number */;;) {}
} }
function for_in_scope_let(o: Object) { function for_in_scope_let(o: Object) {
@ -558,7 +558,7 @@ function default_param_1() {
function default_param_2() { function default_param_2() {
// fn body bindings not visible from param scope // fn body bindings not visible from param scope
let a = \\"\\"; let a = "";
function f0(x = () => a): number { function f0(x = () => a): number {
let a = 0; let a = 0;
return x(); // error: string ~> number return x(); // error: string ~> number
@ -573,8 +573,8 @@ function block_scope() {
let a: number = 0; let a: number = 0;
var b: number = 0; var b: number = 0;
{ {
let a = \\"\\"; // ok: local to block let a = ""; // ok: local to block
var b = \\"\\"; // error: string ~> number var b = ""; // error: string ~> number
} }
} }
@ -582,12 +582,12 @@ function switch_scope(x: string) {
let a: number = 0; let a: number = 0;
var b: number = 0; var b: number = 0;
switch (x) { switch (x) {
case \\"foo\\": case "foo":
let a = \\"\\"; // ok: local to switch let a = ""; // ok: local to switch
var b = \\"\\"; // error: string ~> number var b = ""; // error: string ~> number
break; break;
case \\"bar\\": case "bar":
let a = \\"\\"; // error: a already bound in switch let a = ""; // error: a already bound in switch
break; break;
} }
} }
@ -598,44 +598,44 @@ function switch_scope(x: string) {
function switch_scope2(x: number) { function switch_scope2(x: number) {
switch (x) { switch (x) {
case 0: case 0:
a = \\"\\"; // error: assign before declaration a = ""; // error: assign before declaration
break; break;
case 1: case 1:
var b = a; // error: use before declaration var b = a; // error: use before declaration
break; break;
case 2: case 2:
let a = \\"\\"; let a = "";
break; break;
case 3: case 3:
a = \\"\\"; // error: skipped initializer a = ""; // error: skipped initializer
break; break;
case 4: case 4:
var c: string = a; // error: skipped initializer var c: string = a; // error: skipped initializer
break; break;
} }
a = \\"\\"; // error: a no longer in scope a = ""; // error: a no longer in scope
} }
function try_scope() { function try_scope() {
let a: number = 0; let a: number = 0;
try { try {
let a = \\"\\"; // ok let a = ""; // ok
} catch (e) { } catch (e) {
let a = \\"\\"; // ok let a = ""; // ok
} finally { } finally {
let a = \\"\\"; // ok let a = ""; // ok
} }
} }
function for_scope_let() { function for_scope_let() {
let a: number = 0; let a: number = 0;
for (let a = \\"\\" /* ok: local to init */; ; ) { for (let a = "" /* ok: local to init */; ; ) {
} }
} }
function for_scope_var() { function for_scope_var() {
var a: number = 0; 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() { function default_param_2() {
// fn body bindings not visible from param scope // fn body bindings not visible from param scope
let a = \\"\\"; let a = "";
function f0(x = () => a): number { function f0(x = () => a): number {
let a = 0; let a = 0;
return x(); // error: string ~> number return x(); // error: string ~> number
@ -684,11 +684,11 @@ function default_param_2() {
return x; return x;
} }
} }
"
`; `;
exports[`tdz.js 1`] = ` exports[`tdz.js 1`] = `
"/** @flow */ /** @flow */
// -- types --- // -- types ---
@ -742,7 +742,7 @@ function f3() {
function foo() { return 0; } function foo() { return 0; }
} }
var s2: string = foo(); // ok, hoisted outer not clobbered var s2: string = foo(); // ok, hoisted outer not clobbered
function foo() { return \\"\\"; } function foo() { return ""; }
} }
// out-of-scope TDZ not enforced. sometimes right... // out-of-scope TDZ not enforced. sometimes right...
@ -846,7 +846,7 @@ function f3() {
} }
var s2: string = foo(); // ok, hoisted outer not clobbered var s2: string = foo(); // ok, hoisted outer not clobbered
function foo() { function foo() {
return \\"\\"; return "";
} }
} }
@ -899,5 +899,5 @@ f(a); // error: undefined ~/> number
a = 10; a = 10;
f(a); // ok, a: number (not ?number) f(a); // ok, a: number (not ?number)
"
`; `;

View File

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

View File

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

View File

@ -1,11 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`break.js 1`] = ` exports[`break.js 1`] = `
"function foo(b) { function foo(b) {
var x = b ? null: false; var x = b ? null: false;
var z; var z;
while(b) { while(b) {
if (x == null) { z = \\"\\"; break; } if (x == null) { z = ""; break; }
var y:number = x; // error: boolean !~> number var y:number = x; // error: boolean !~> number
} }
var w:number = z; // 2 errors: ?string !~> number var w:number = z; // 2 errors: ?string !~> number
@ -14,10 +14,10 @@ exports[`break.js 1`] = `
function bar(b) { function bar(b) {
var x = b ? null: false; var x = b ? null: false;
if (x == null) return; if (x == null) return;
switch (\\"\\") { switch ("") {
case 0: case 0:
var y:number = x; // error: boolean !~> number var y:number = x; // error: boolean !~> number
x = \\"\\"; x = "";
case 1: case 1:
var z:number = x; // 2 errors: (boolean | string) !~> number var z:number = x; // 2 errors: (boolean | string) !~> number
break; break;
@ -29,10 +29,10 @@ function bar(b) {
function bar2(b) { function bar2(b) {
var x = b ? null: false; var x = b ? null: false;
if (x == null) return; if (x == null) return;
switch (\\"\\") { switch ("") {
case 0: { case 0: {
let y:number = x; // error: boolean !~> number let y:number = x; // error: boolean !~> number
x = \\"\\"; x = "";
} }
case 1: { case 1: {
let z:number = x; // 2 errors: (boolean | string) !~> number let z:number = x; // 2 errors: (boolean | string) !~> number
@ -47,7 +47,7 @@ function qux(b) {
var z = 0; var z = 0;
while(b) { while(b) {
var y:number = z; var y:number = z;
if (b) { z = \\"\\"; continue; } // error: string !~> number if (b) { z = ""; continue; } // error: string !~> number
z = 0; z = 0;
} }
var w:number = z; // error: string !~> number var w:number = z; // error: string !~> number
@ -59,7 +59,7 @@ function test_const() {
let st: string = 'abc'; let st: string = 'abc';
for (let i = 1; i < 100; i++) { for (let i = 1; i < 100; i++) {
const fooRes: ?string = \\"HEY\\"; const fooRes: ?string = "HEY";
if (!fooRes) { if (!fooRes) {
break; break;
} }
@ -75,7 +75,7 @@ function foo(b) {
var z; var z;
while (b) { while (b) {
if (x == null) { if (x == null) {
z = \\"\\"; z = "";
break; break;
} }
var y: number = x; // error: boolean !~> number var y: number = x; // error: boolean !~> number
@ -86,10 +86,10 @@ function foo(b) {
function bar(b) { function bar(b) {
var x = b ? null : false; var x = b ? null : false;
if (x == null) return; if (x == null) return;
switch (\\"\\") { switch ("") {
case 0: case 0:
var y: number = x; // error: boolean !~> number var y: number = x; // error: boolean !~> number
x = \\"\\"; x = "";
case 1: case 1:
var z: number = x; // 2 errors: (boolean | string) !~> number var z: number = x; // 2 errors: (boolean | string) !~> number
break; break;
@ -101,10 +101,10 @@ function bar(b) {
function bar2(b) { function bar2(b) {
var x = b ? null : false; var x = b ? null : false;
if (x == null) return; if (x == null) return;
switch (\\"\\") { switch ("") {
case 0: { case 0: {
let y: number = x; // error: boolean !~> number let y: number = x; // error: boolean !~> number
x = \\"\\"; x = "";
} }
case 1: { case 1: {
let z: number = x; // 2 errors: (boolean | string) !~> number let z: number = x; // 2 errors: (boolean | string) !~> number
@ -120,7 +120,7 @@ function qux(b) {
while (b) { while (b) {
var y: number = z; var y: number = z;
if (b) { if (b) {
z = \\"\\"; z = "";
continue; continue;
} // error: string !~> number } // error: string !~> number
z = 0; z = 0;
@ -131,10 +131,10 @@ function qux(b) {
// same basic test as foo(), but with const. probes the // same basic test as foo(), but with const. probes the
// logic that still uses havoc to do env resets. // logic that still uses havoc to do env resets.
function test_const() { function test_const() {
let st: string = \\"abc\\"; let st: string = "abc";
for (let i = 1; i < 100; i++) { for (let i = 1; i < 100; i++) {
const fooRes: ?string = \\"HEY\\"; const fooRes: ?string = "HEY";
if (!fooRes) { if (!fooRes) {
break; break;
} }
@ -144,5 +144,5 @@ function test_const() {
return st; return st;
} }
"
`; `;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`A.js 1`] = ` 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 { function a(f: { (): string }, g: { (x: number): string } ): string {
return f() + g(123); return f() + g(123);
} }
@ -13,7 +13,7 @@ function b(f: { (): string }): number {
// ...or if the param type is wrong // ...or if the param type is wrong
function c(f: { (x: number): number }): number { function c(f: { (x: number): number }): number {
return f(\\"hello\\"); return f("hello");
} }
// ...or if the arity is wrong // ...or if the arity is wrong
@ -44,7 +44,7 @@ function b(f: { (): string }): number {
// ...or if the param type is wrong // ...or if the param type is wrong
function c(f: { (x: number): number }): number { function c(f: { (x: number): number }): number {
return f(\\"hello\\"); return f("hello");
} }
// ...or if the arity is wrong // ...or if the arity is wrong
@ -62,70 +62,70 @@ function f(): number {
var x = {}; var x = {};
return x(); return x();
} }
"
`; `;
exports[`B.js 1`] = ` exports[`B.js 1`] = `
"// You should be able to use a function as an object with a call property // You should be able to use a function as an object with a call property
var a: { (x: number): string } = function (x: number): string { return \\"hi\\"; }; var a: { (x: number): string } = function (x: number): string { return "hi"; };
// ...and it should notice when the return type is wrong // ...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 // ...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 // ...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 // ...but subtyping rules still apply
var e: { (x: any): void } = function() { } // arity 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 var g: { (x: string): void } = function(x: mixed) { } // param type
// A function can be an object // A function can be an object
var y : {} = function (x: number): string { return \\"hi\\"; }; var y : {} = function (x: number): string { return "hi"; };
var z : Object = 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 // You should be able to use a function as an object with a call property
var a: { (x: number): string } = function(x: number): string { var a: { (x: number): string } = function(x: number): string {
return \\"hi\\"; return "hi";
}; };
// ...and it should notice when the return type is wrong // ...and it should notice when the return type is wrong
var b: { (x: number): number } = function(x: number): string { var b: { (x: number): number } = function(x: number): string {
return \\"hi\\"; return "hi";
}; };
// ...or if the param type is wrong // ...or if the param type is wrong
var c: { (x: string): string } = function(x: number): string { var c: { (x: string): string } = function(x: number): string {
return \\"hi\\"; return "hi";
}; };
// ...or if the arity is wrong // ...or if the arity is wrong
var d: { (): string } = function(x: number): string { var d: { (): string } = function(x: number): string {
return \\"hi\\"; return "hi";
}; };
// ...but subtyping rules still apply // ...but subtyping rules still apply
var e: { (x: any): void } = function() {}; // arity var e: { (x: any): void } = function() {}; // arity
var f: { (): mixed } = function(): string { var f: { (): mixed } = function(): string {
return \\"hi\\"; return "hi";
}; // return type }; // return type
var g: { (x: string): void } = function(x: mixed) {}; // param type var g: { (x: string): void } = function(x: mixed) {}; // param type
// A function can be an object // A function can be an object
var y: {} = function(x: number): string { var y: {} = function(x: number): string {
return \\"hi\\"; return "hi";
}; };
var z: Object = function(x: number): string { var z: Object = function(x: number): string {
return \\"hi\\"; return "hi";
}; };
"
`; `;
exports[`C.js 1`] = ` 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 { function a(x: { (z: number): string }): (z: number) => string {
return x; return x;
} }
@ -194,22 +194,22 @@ function f(x: { (z: number): string }): Function {
function g(x: {}): Function { function g(x: {}): Function {
return x; // error return x; // error
} }
"
`; `;
exports[`D.js 1`] = ` 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 { function a(f: { (): string; (x: number): string }): string {
return f() + f(123); return f() + f(123);
} }
// It should be fine when a function satisfies them all // It should be fine when a function satisfies them all
var b: { (): string; (x: number): string } = var b: { (): string; (x: number): string } =
function (x?: number): string { return \\"hi\\"; }; function (x?: number): string { return "hi"; };
// ...but should notice when a function doesn't satisfy them all // ...but should notice when a function doesn't satisfy them all
var c: { (): string; (x: number): string } = 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 // Only one call property needs to match the function
function d(x: { (): string; (x: number): string }): () => string { 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 // It should be fine when a function satisfies them all
var b: { (): string, (x: number): string } = function(x?: number): string { var b: { (): string, (x: number): string } = function(x?: number): string {
return \\"hi\\"; return "hi";
}; };
// ...but should notice when a function doesn't satisfy them all // ...but should notice when a function doesn't satisfy them all
var c: { (): string, (x: number): string } = function(x: number): string { var c: { (): string, (x: number): string } = function(x: number): string {
return \\"hi\\"; return "hi";
}; };
// Only one call property needs to match the function // 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 { function e(x: { (): string, (x: number): string }): () => number {
return x; return x;
} }
"
`; `;
exports[`E.js 1`] = ` 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 () {}; var a : { someProp: number } = function () {};
// Expecting properties that do exist should be fine // Expecting properties that do exist should be fine
@ -270,54 +270,54 @@ var b: { apply: Function } = function() {};
var f = function() {}; var f = function() {};
f.myProp = 123; f.myProp = 123;
var c: { myProp: number } = f; var c: { myProp: number } = f;
"
`; `;
exports[`F.js 1`] = ` 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() var a: { (x: number): string } = (x) => x.toString()
// ...and it should notice when the return type is wrong // ...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 // ...or if the param type is wrong
var c: { (x: string): string } = (x) => x.toFixed() var c: { (x: string): string } = (x) => x.toFixed()
// ...or if the arity is wrong // ...or if the arity is wrong
var d: { (): string } = (x) => \\"hi\\" var d: { (): string } = (x) => "hi"
// ...but subtyping rules still apply // ...but subtyping rules still apply
var e: { (x: any): void } = () => { } // arity 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) var g: { (x: Date): void } = (x) => { x * 2 } // param type (date < number)
// A function can be an object // A function can be an object
var y : {} = (x) => \\"hi\\" var y : {} = (x) => "hi"
var z : Object = (x) => \\"hi\\" var z : Object = (x) => "hi"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// 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(); var a: { (x: number): string } = x => x.toString();
// ...and it should notice when the return type is wrong // ...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 // ...or if the param type is wrong
var c: { (x: string): string } = x => x.toFixed(); var c: { (x: string): string } = x => x.toFixed();
// ...or if the arity is wrong // ...or if the arity is wrong
var d: { (): string } = x => \\"hi\\"; var d: { (): string } = x => "hi";
// ...but subtyping rules still apply // ...but subtyping rules still apply
var e: { (x: any): void } = () => {}; // arity var e: { (x: any): void } = () => {}; // arity
var f: { (): mixed } = () => \\"hi\\"; // return type var f: { (): mixed } = () => "hi"; // return type
var g: { (x: Date): void } = x => { var g: { (x: Date): void } = x => {
x * 2; x * 2;
}; // param type (date < number) }; // param type (date < number)
// A function can be an object // A function can be an object
var y: {} = x => \\"hi\\"; var y: {} = x => "hi";
var z: Object = x => \\"hi\\"; var z: Object = x => "hi";
"
`; `;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`optional.js 1`] = ` exports[`optional.js 1`] = `
"type F = { type F = {
(x: string): number; (x: string): number;
p?: string; p?: string;
} }
@ -22,11 +22,11 @@ function f(x) {
} }
(f: F); (f: F);
"
`; `;
exports[`primitives.js 1`] = ` exports[`primitives.js 1`] = `
"var x = Boolean(4); var x = Boolean(4);
function foo(fn:(value:any)=>boolean) { } function foo(fn:(value:any)=>boolean) { }
foo(Boolean); foo(Boolean);
@ -69,5 +69,5 @@ type Callable = {
declare var callable: Callable; declare var callable: Callable;
callable(0); // error, number ~> string callable(0); // error, number ~> string
callable.call(null, 0); // error, number ~> string callable.call(null, 0); // error, number ~> string
"
`; `;

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = ` exports[`test.js 1`] = `
"class A { class A {
static x: number; static x: number;
static y: string; static y: string;
static foo(x: number) { } static foo(x: number) { }
@ -14,9 +14,9 @@ class B extends A {
static foo(x: string) { } // error? static foo(x: string) { } // error?
static main() { static main() {
B.x = 0; // error B.x = 0; // error
B.x = \\"\\"; B.x = "";
B.foo(0); // error B.foo(0); // error
B.foo(\\"\\"); B.foo("");
B.y = 0; // error B.y = 0; // error
B.bar(0); // error B.bar(0); // error
B.qux(0); // error B.qux(0); // error
@ -76,9 +76,9 @@ class B extends A {
static foo(x: string) {} // error? static foo(x: string) {} // error?
static main() { static main() {
B.x = 0; // error B.x = 0; // error
B.x = \\"\\"; B.x = "";
B.foo(0); // error B.foo(0); // error
B.foo(\\"\\"); B.foo("");
B.y = 0; // error B.y = 0; // error
B.bar(0); // error B.bar(0); // error
B.qux(0); // error B.qux(0); // error
@ -128,5 +128,5 @@ module.exports = {
D: D, D: D,
E: E E: E
}; };
"
`; `;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,8 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`no_at_flow.js 1`] = ` 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 // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`no_at_flow.js 1`] = ` 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 // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`no_at_flow.js 1`] = ` exports[`no_at_flow.js 1`] = `
"var x; var x;
x.length; x.length;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var x; var x;
x.length; x.length;
"
`; `;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = ` exports[`test.js 1`] = `
"/* /*
* @flow * @flow
*/ */
@ -18,11 +18,11 @@ foo('Hello, world!');
*/ */
function foo(x) { function foo(x) {
var a: number = \\"asdf\\"; var a: number = "asdf";
return x * 10; return x * 10;
} }
// This file should be ignored, so this should not result in an error // 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 // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`foo.js 1`] = ` exports[`foo.js 1`] = `
"/* @flow */ /* @flow */
// No error, this file is ignored // No error, this file is ignored
var x: number = \\"string\\"; var x: number = "string";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */ /* @flow */
// No error, this file is ignored // 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 // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`foo.js 1`] = ` exports[`foo.js 1`] = `
"/* @flow */ /* @flow */
var x: number = \\"string\\"; // Error string ~> number var x: number = "string"; // Error string ~> number
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */ /* @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 // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`main.js 1`] = ` exports[`main.js 1`] = `
"// @flow // @flow
import {test} from 'testmodule'; import {test} from 'testmodule';
@ -10,9 +10,9 @@ var b: string = test; // Error: number ~> string
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow // @flow
import { test } from \\"testmodule\\"; import { test } from "testmodule";
var a: number = test; var a: number = test;
var b: string = test; // Error: number ~> string var b: string = test; // Error: number ~> string
"
`; `;

View File

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

View File

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

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`A.js 1`] = ` exports[`A.js 1`] = `
"/* @flow */ /* @flow */
var m1 = require('1DoesntExist'); var m1 = require('1DoesntExist');
import {numVal as numVal1} from '1DoesntExist'; import {numVal as numVal1} from '1DoesntExist';
@ -17,8 +17,8 @@ import {numVal as numVal2} from '3DoesntExist'; // Error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */ /* @flow */
var m1 = require(\\"1DoesntExist\\"); var m1 = require("1DoesntExist");
import { numVal as numVal1 } from \\"1DoesntExist\\"; import { numVal as numVal1 } from "1DoesntExist";
var a_1: number = m1.numVal; var a_1: number = m1.numVal;
var a_2: number = numVal1; 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 // This tests that, for haste, the first name_mapper regexp that happens to
// match the given module name string is picked. // match the given module name string is picked.
var m2 = require(\\"2DoesntExist\\"); // Error var m2 = require("2DoesntExist"); // Error
import { numVal as numVal2 } from \\"3DoesntExist\\"; // Error import { numVal as numVal2 } from "3DoesntExist"; // Error
"
`; `;
exports[`Exists.js 1`] = ` exports[`Exists.js 1`] = `
"/** /**
* @providesModule Exists * @providesModule Exists
* @flow * @flow
*/ */
@ -49,5 +49,5 @@ module.exports = {
module.exports = { module.exports = {
numVal: 42 numVal: 42
}; };
"
`; `;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`A.js 1`] = ` exports[`A.js 1`] = `
"/* @flow */ /* @flow */
var m1 = require('./1DoesntExist'); var m1 = require('./1DoesntExist');
var a_1: number = m1.numVal; var a_1: number = m1.numVal;
@ -29,34 +29,34 @@ var c_4: string = numVal3; // Error: number ~> string
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */ /* @flow */
var m1 = require(\\"./1DoesntExist\\"); var m1 = require("./1DoesntExist");
var a_1: number = m1.numVal; var a_1: number = m1.numVal;
var a_2: string = m1.numVal; // Error: number ~> string var a_2: string = m1.numVal; // Error: number ~> string
import { numVal } from \\"./1DoesntExist\\"; import { numVal } from "./1DoesntExist";
var a_3: number = numVal; var a_3: number = numVal;
var a_4: string = numVal; // Error: number ~> string var a_4: string = numVal; // Error: number ~> string
// This tests that, for node, the first name mapping that both matches *and* // This tests that, for node, the first name mapping that both matches *and*
// results in a valid module filename is picked. // results in a valid module filename is picked.
var m2 = require(\\"./2DoesntExist\\"); var m2 = require("./2DoesntExist");
var b_1: number = m2.numVal; var b_1: number = m2.numVal;
var b_2: string = m2.numVal; // Error: number ~> string 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_3: number = numVal2;
var b_4: string = numVal2; // Error: number ~> string var b_4: string = numVal2; // Error: number ~> string
// node_modules/Exists/index.js // node_modules/Exists/index.js
var m3 = require(\\"4DoesntExist\\"); var m3 = require("4DoesntExist");
var c_1: number = m3.numVal; var c_1: number = m3.numVal;
var c_2: string = m3.numVal; // Error: number ~> string 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_3: number = numVal3;
var c_4: string = numVal3; // Error: number ~> string var c_4: string = numVal3; // Error: number ~> string
"
`; `;
exports[`Exists.js 1`] = ` exports[`Exists.js 1`] = `
"/* @flow */ /* @flow */
module.exports = { module.exports = {
numVal: 42 numVal: 42
@ -67,5 +67,5 @@ module.exports = {
module.exports = { module.exports = {
numVal: 42 numVal: 42
}; };
"
`; `;

View File

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

View File

@ -1,12 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`index.js 1`] = ` exports[`index.js 1`] = `
"// @flow // @flow
export var name: \\"otherdir/testproj\\" = \\"otherdir/testproj\\"; export var name: "otherdir/testproj" = "otherdir/testproj";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow // @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 // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`index.js 1`] = ` exports[`index.js 1`] = `
"// @flow // @flow
export var name: \\"otherdir/testproj2\\" = \\"otherdir/testproj2\\"; export var name: "otherdir/testproj2" = "otherdir/testproj2";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @flow // @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 // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`sublevel.js 1`] = ` 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: "node_modules/testproj2"); // Error: Resolve from sibling 'custom_resolve_dir' first!
(name: \\"subdir/custom_resolve_dir/testproj2\\"); (name: "subdir/custom_resolve_dir/testproj2");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// @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\\");
"
`; `;

View File

@ -1,13 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`index.js 1`] = ` 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 // @flow
export var name: \\"subdir/custom_resolve_dir/testproj2\\" = export var name: "subdir/custom_resolve_dir/testproj2" =
\\"subdir/custom_resolve_dir/testproj2\\"; "subdir/custom_resolve_dir/testproj2";
"
`; `;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`chain.js 1`] = ` exports[`chain.js 1`] = `
"/* @flow */ /* @flow */
class A { class A {
_property1: number; _property1: number;
@ -14,7 +14,7 @@ class A {
return 1; return 1;
} }
static _sMethod(): string { static _sMethod(): string {
return \\"some string\\"; return "some string";
} }
} }
A._sProperty = 48; A._sProperty = 48;
@ -25,16 +25,16 @@ class B extends A {
constructor() { constructor() {
super(); super();
this._property1 = \\"another string\\"; this._property1 = "another string";
} }
_method1(): string { _method1(): string {
return \\"yet another string\\"; return "yet another string";
} }
static _sMethod(): number { static _sMethod(): number {
return 23; return 23;
} }
} }
B._sProperty = \\"B._sProperty string\\"; B._sProperty = "B._sProperty string";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */ /* @flow */
@ -49,7 +49,7 @@ class A {
return 1; return 1;
} }
static _sMethod(): string { static _sMethod(): string {
return \\"some string\\"; return "some string";
} }
} }
A._sProperty = 48; A._sProperty = 48;
@ -60,21 +60,21 @@ class B extends A {
constructor() { constructor() {
super(); super();
this._property1 = \\"another string\\"; this._property1 = "another string";
} }
_method1(): string { _method1(): string {
return \\"yet another string\\"; return "yet another string";
} }
static _sMethod(): number { static _sMethod(): number {
return 23; return 23;
} }
} }
B._sProperty = \\"B._sProperty string\\"; B._sProperty = "B._sProperty string";
"
`; `;
exports[`commonjs_export.js 1`] = ` exports[`commonjs_export.js 1`] = `
"/* @flow */ /* @flow */
class C { class C {
_p: string; _p: string;
@ -89,16 +89,16 @@ class C {
} }
module.exports = new C(); module.exports = new C();
"
`; `;
exports[`commonjs_import.js 1`] = ` exports[`commonjs_import.js 1`] = `
"/* @flow */ /* @flow */
import {_p} from \\"./commonjs_export\\"; import {_p} from "./commonjs_export";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */ /* @flow */
import { _p } from \\"./commonjs_export\\"; import { _p } from "./commonjs_export";
"
`; `;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`chain.js 1`] = ` exports[`chain.js 1`] = `
"/* @flow */ /* @flow */
class A { class A {
_property1: number; _property1: number;
@ -14,7 +14,7 @@ class A {
return 1; return 1;
} }
static _sMethod(): string { static _sMethod(): string {
return \\"some string\\"; return "some string";
} }
} }
A._sProperty = 48; A._sProperty = 48;
@ -25,16 +25,16 @@ class B extends A {
constructor() { constructor() {
super(); super();
this._property1 = \\"another string\\"; this._property1 = "another string";
} }
_method1(): string { _method1(): string {
return \\"yet another string\\"; return "yet another string";
} }
static _sMethod(): number { static _sMethod(): number {
return 23; return 23;
} }
} }
B._sProperty = \\"B._sProperty string\\"; B._sProperty = "B._sProperty string";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @flow */ /* @flow */
@ -49,7 +49,7 @@ class A {
return 1; return 1;
} }
static _sMethod(): string { static _sMethod(): string {
return \\"some string\\"; return "some string";
} }
} }
A._sProperty = 48; A._sProperty = 48;
@ -60,15 +60,15 @@ class B extends A {
constructor() { constructor() {
super(); super();
this._property1 = \\"another string\\"; this._property1 = "another string";
} }
_method1(): string { _method1(): string {
return \\"yet another string\\"; return "yet another string";
} }
static _sMethod(): number { static _sMethod(): number {
return 23; 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 // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = ` exports[`test.js 1`] = `
"/** /**
* test handling of const params * test handling of const params
* - reassignment prohibited * - reassignment prohibited
* - durable refinements * - durable refinements
@ -17,7 +17,7 @@ exports[`test.js 1`] = `
*/ */
function cannot_reassign(x: string) { 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 // Note: const params use the same machinery as explicit
@ -47,7 +47,7 @@ function durable_refi(x: ?number) {
*/ */
function cannot_reassign(x: string) { 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 // 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 // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`constructor.js 1`] = ` exports[`constructor.js 1`] = `
"class C { class C {
constructor() { } constructor() { }
} }
@ -37,14 +37,14 @@ declare class Bar<T> {}
declare class Foo<T> { declare class Foo<T> {
constructor<U>(iterable: U): Bar<U> 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 (new Foo(123): Bar<string>); // error, number !~> string
// also overrides when it returns a different specialization of the same class // also overrides when it returns a different specialization of the same class
declare class Baz<T> { declare class Baz<T> {
constructor<U>(iterable: U): Baz<U> 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 (new Baz(123): Baz<string>); // error, number !~> string
"
`; `;

View File

@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`constructors.js 1`] = ` exports[`constructors.js 1`] = `
"// Foo is a class-like function // Foo is a class-like function
function Foo() { function Foo() {
this.x = 0; // constructs objects with property x 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 static y: boolean // error, should have declared static y: number instead
} }
exports.Foo2 = (Foo: Class<IFoo>); exports.Foo2 = (Foo: Class<IFoo>);
"
`; `;
exports[`test.js 1`] = ` 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 x: string = new Foo().x; // error, found number instead of string
var y: string = Foo.y; // error, found number instead of string var y: string = Foo.y; // error, found number instead of string
var z: string = new Foo().m(); 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 y2: string = Foo2.y; // error, found boolean instead of string
var z2: string = new Foo2().m(); 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 x: string = new Foo().x; // error, found number instead of string
var y: string = Foo.y; // error, found number instead of string var y: string = Foo.y; // error, found number instead of string
var z: string = new Foo().m(); 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 x2: string = new Foo2().x; // error, found boolean instead of string
var y2: string = Foo2.y; // error, found boolean instead of string var y2: string = Foo2.y; // error, found boolean instead of string
var z2: string = new Foo2().m(); var z2: string = new Foo2().m();
"
`; `;

View File

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

View File

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

View File

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

View File

@ -1,10 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`test.js 1`] = ` exports[`test.js 1`] = `
"type CovArrayVerbose<X,Y:X> = Array<Y>; type CovArrayVerbose<X,Y:X> = Array<Y>;
var b: CovArrayVerbose<number,*> = []; var b: CovArrayVerbose<number,*> = [];
var y: CovArrayVerbose<mixed,*> = b; var y: CovArrayVerbose<mixed,*> = b;
y[0] = \\"\\"; // error y[0] = ""; // error
class NVerbose<E,I:E> { class NVerbose<E,I:E> {
x: CovArrayVerbose<E,I>; x: CovArrayVerbose<E,I>;
@ -24,12 +24,12 @@ var z: CovArray<string> = c; // error
var d: CovArray<number> = []; var d: CovArray<number> = [];
var w: CovArray<mixed> = d; var w: CovArray<mixed> = d;
w[0] = \\"\\"; // error w[0] = ""; // error
type P<X> = CovArray<X>; type P<X> = CovArray<X>;
var p: P<mixed> = []; var p: P<mixed> = [];
(p[0]: number); // not an error! (p[0]: number); // not an error!
p[0] = \\"\\"; // error p[0] = ""; // error
class M { class M {
x: CovArray<number>; x: CovArray<number>;
@ -54,7 +54,7 @@ n.x = [0];
type CovArrayVerbose<X, Y: X> = Array<Y>; type CovArrayVerbose<X, Y: X> = Array<Y>;
var b: CovArrayVerbose<number, *> = []; var b: CovArrayVerbose<number, *> = [];
var y: CovArrayVerbose<mixed, *> = b; var y: CovArrayVerbose<mixed, *> = b;
y[0] = \\"\\"; // error y[0] = ""; // error
class NVerbose<E, I: E> { class NVerbose<E, I: E> {
x: CovArrayVerbose<E, I>; x: CovArrayVerbose<E, I>;
@ -76,12 +76,12 @@ var z: CovArray<string> = c; // error
var d: CovArray<number> = []; var d: CovArray<number> = [];
var w: CovArray<mixed> = d; var w: CovArray<mixed> = d;
w[0] = \\"\\"; // error w[0] = ""; // error
type P<X> = CovArray<X>; type P<X> = CovArray<X>;
var p: P<mixed> = []; var p: P<mixed> = [];
(p[0]: number); // not an error! (p[0]: number); // not an error!
p[0] = \\"\\"; // error p[0] = ""; // error
class M { class M {
x: CovArray<number>; x: CovArray<number>;
@ -102,5 +102,5 @@ n.x = [0];
(n.foo()[0]: string); // not an error! (n.foo()[0]: string); // not an error!
*/ */
"
`; `;

View File

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

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