Files
test-repo/tests/format/flow/as-satisfies-expression/__snapshots__/jsfmt.spec.js.snap
T

640 lines
18 KiB
Plaintext

// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`as.js [babel-flow] format 1`] = `
"Unexpected token, expected "," (3:27)
1 | // @flow
2 |
> 3 | const name = (description as Description).name || (description as string);
| ^
4 | this.isTabActionBar((e.target || e.srcElement) as HTMLElement);
5 | (originalError ? wrappedError(errMsg, originalError) : Error(errMsg)) as InjectionError;
6 | 'current' in (props.pagination as {...});
Cause: Unexpected token, expected "," (3:26)"
`;
exports[`as.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80
| printWidth
=====================================input======================================
// @flow
const name = (description as Description).name || (description as string);
this.isTabActionBar((e.target || e.srcElement) as HTMLElement);
(originalError ? wrappedError(errMsg, originalError) : Error(errMsg)) as InjectionError;
'current' in (props.pagination as {...});
('current' in props.pagination) as {...};
start + (yearSelectTotal as number);
(start + yearSelectTotal) as number;
scrollTop > (visibilityHeight as number);
(scrollTop > visibilityHeight) as number;
export default class Column<T> extends (RcTable.Column as Long.Thing<ColumnProps<T>,ColumnProps<T>,ColumnProps<T>,ColumnProps<T>>) {}
({}) as {};
function*g() {
const test = (yield 'foo') as number;
}
async function g1() {
const test = (await 'foo') as number;
}
({}) as X;
() => ({}) as X;
const state = JSON.stringify({
next: window.location.href,
nonce,
} as State);
(bValue as boolean) ? 0 : -1;
const value1 = thisIsAReallyReallyReallyReallyReallyLongIdentifier as SomeInterface;
const value2 = thisIsAnIdentifier as thisIsAReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLongInterface;
const value3 = thisIsAReallyLongIdentifier as (SomeInterface | SomeOtherInterface);
const value4 = thisIsAReallyLongIdentifier as { prop1: string, prop2: number, prop3: number }[];
const value5 = thisIsAReallyReallyReallyReallyReallyReallyReallyReallyReallyLongIdentifier as [string, number];
const iter1 = createIterator(this.controller, child, this.tag as BlahFunctionComponent);
const iter2 = createIterator(self.controller, child, self.tag as BlahFunctionComponent);
x as any as T;
(type) as T;
=====================================output=====================================
// @flow
const name = (description as Description).name || (description as string);
this.isTabActionBar((e.target || e.srcElement) as HTMLElement);
(originalError
? wrappedError(errMsg, originalError)
: Error(errMsg)) as InjectionError;
"current" in (props.pagination as { ... });
("current" in props.pagination) as { ... };
start + (yearSelectTotal as number);
(start + yearSelectTotal) as number;
scrollTop > (visibilityHeight as number);
(scrollTop > visibilityHeight) as number;
export default class Column<T> extends (RcTable.Column as Long.Thing<
ColumnProps<T>,
ColumnProps<T>,
ColumnProps<T>,
ColumnProps<T>,
>) {}
({}) as {};
function* g() {
const test = (yield "foo") as number;
}
async function g1() {
const test = (await "foo") as number;
}
({}) as X;
() => ({}) as X;
const state = JSON.stringify({
next: window.location.href,
nonce,
} as State);
(bValue as boolean) ? 0 : -1;
const value1 =
thisIsAReallyReallyReallyReallyReallyLongIdentifier as SomeInterface;
const value2 =
thisIsAnIdentifier as thisIsAReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyReallyLongInterface;
const value3 = thisIsAReallyLongIdentifier as
| SomeInterface
| SomeOtherInterface;
const value4 = thisIsAReallyLongIdentifier as {
prop1: string,
prop2: number,
prop3: number,
}[];
const value5 =
thisIsAReallyReallyReallyReallyReallyReallyReallyReallyReallyLongIdentifier as [
string,
number,
];
const iter1 = createIterator(
this.controller,
child,
this.tag as BlahFunctionComponent,
);
const iter2 = createIterator(
self.controller,
child,
self.tag as BlahFunctionComponent,
);
x as any as T;
(type) as T;
================================================================================
`;
exports[`as-const.js [babel-flow] format 1`] = `
"Unexpected token (12:11)
10 | INFO: 6,
11 | DEBUG: 7,
> 12 | } as const;
| ^
13 |
14 | (type) as const;
15 |
Cause: Unexpected token (12:10)"
`;
exports[`as-const.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80
| printWidth
=====================================input======================================
// @flow
export const LOG_LEVEL = {
EMERGENCY: 0,
ALERT: 1,
CRITICAL: 2,
ERROR: 3,
WARNING: 4,
NOTICE: 5,
INFO: 6,
DEBUG: 7,
} as const;
(type) as const;
=====================================output=====================================
// @flow
export const LOG_LEVEL = {
EMERGENCY: 0,
ALERT: 1,
CRITICAL: 2,
ERROR: 3,
WARNING: 4,
NOTICE: 5,
INFO: 6,
DEBUG: 7,
} as const;
(type) as const;
================================================================================
`;
exports[`assignment.js [babel-flow] format 1`] = `
"Unexpected token, expected "," (17:23)
15 | this.currentPreviewIndex++;
16 | }
> 17 | }, this.refreshDelay) as any);
| ^
18 |
19 | this.intervalID = (setInterval(() => {
20 | self.step();
Cause: Unexpected token, expected "," (17:22)"
`;
exports[`assignment.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80
| printWidth
=====================================input======================================
// @flow
const TYPE_MAP = {
'character device': 'special',
'character special file': 'special',
directory: 'directory',
'regular file': 'file',
socket: 'socket',
'symbolic link': 'link',
} as Foo;
this.previewPlayerHandle = (setInterval(async () => {
if (this.previewIsPlaying) {
await this.fetchNextPreviews();
this.currentPreviewIndex++;
}
}, this.refreshDelay) as any);
this.intervalID = (setInterval(() => {
self.step();
}, 30) as any);
=====================================output=====================================
// @flow
const TYPE_MAP = {
"character device": "special",
"character special file": "special",
directory: "directory",
"regular file": "file",
socket: "socket",
"symbolic link": "link",
} as Foo;
this.previewPlayerHandle = setInterval(async () => {
if (this.previewIsPlaying) {
await this.fetchNextPreviews();
this.currentPreviewIndex++;
}
}, this.refreshDelay) as any;
this.intervalID = setInterval(() => {
self.step();
}, 30) as any;
================================================================================
`;
exports[`export_default_as.js [babel-flow] format 1`] = `
"Unexpected token, expected "," (3:35)
1 | // @flow
2 |
> 3 | export default (function log() {} as typeof console.log)
| ^
4 |
Cause: Unexpected token, expected "," (3:34)"
`;
exports[`export_default_as.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80
| printWidth
=====================================input======================================
// @flow
export default (function log() {} as typeof console.log)
=====================================output=====================================
// @flow
export default (function log() {} as typeof console.log);
================================================================================
`;
exports[`long-identifiers.js [babel-flow] format 1`] = `
"Unexpected token, expected "," (11:37)
9 | averredBathersBoxroomBuggyNurl = {
10 | anodyneCondosMalateOverateRetinol:
> 11 | annularCooeedSplicesWalksWayWay as kochabCooieGameOnOboleUnweave
| ^
12 | };
13 |
14 | averredBathersBoxroomBuggyNurl(
Cause: Unexpected token, expected "," (11:36)"
`;
exports[`long-identifiers.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80
| printWidth
=====================================input======================================
// @flow
const bifornCringerMoshedPerplexSawder =
askTrovenaBeenaDependsRowans as glimseGlyphsHazardNoopsTieTie;
averredBathersBoxroomBuggyNurl.anodyneCondosMalateOverateRetinol =
annularCooeedSplicesWalksWayWay as kochabCooieGameOnOboleUnweave;
averredBathersBoxroomBuggyNurl = {
anodyneCondosMalateOverateRetinol:
annularCooeedSplicesWalksWayWay as kochabCooieGameOnOboleUnweave
};
averredBathersBoxroomBuggyNurl(
anodyneCondosMalateOverateRetinol.annularCooeedSplicesWalksWayWay as
kochabCooieGameOnOboleUnweave
);
=====================================output=====================================
// @flow
const bifornCringerMoshedPerplexSawder =
askTrovenaBeenaDependsRowans as glimseGlyphsHazardNoopsTieTie;
averredBathersBoxroomBuggyNurl.anodyneCondosMalateOverateRetinol =
annularCooeedSplicesWalksWayWay as kochabCooieGameOnOboleUnweave;
averredBathersBoxroomBuggyNurl = {
anodyneCondosMalateOverateRetinol:
annularCooeedSplicesWalksWayWay as kochabCooieGameOnOboleUnweave,
};
averredBathersBoxroomBuggyNurl(
anodyneCondosMalateOverateRetinol.annularCooeedSplicesWalksWayWay as kochabCooieGameOnOboleUnweave,
);
================================================================================
`;
exports[`nested-await-and-as.js [babel-flow] format 1`] = `
"Unexpected token, expected "," (7:33)
5 | ((await (
6 | await focusOnSection(BOOKMARKED_PROJECTS_SECTION_NAME)
> 7 | ).findItem("My bookmarks")) as TreeItem
| ^
8 | ).getChildren()
9 | ).length
10 |
Cause: Unexpected token, expected "," (7:32)"
`;
exports[`nested-await-and-as.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80
| printWidth
=====================================input======================================
// @flow
const getAccountCount = async () =>
(await
((await (
await focusOnSection(BOOKMARKED_PROJECTS_SECTION_NAME)
).findItem("My bookmarks")) as TreeItem
).getChildren()
).length
=====================================output=====================================
// @flow
const getAccountCount = async () =>
(
await (
(await (
await focusOnSection(BOOKMARKED_PROJECTS_SECTION_NAME)
).findItem("My bookmarks")) as TreeItem
).getChildren()
).length;
================================================================================
`;
exports[`return.js [babel-flow] format 1`] = `
"Missing semicolon. (7:4)
5 | foo: 1,
6 | bar: 2,
> 7 | } as Foo;
| ^
8 | }
9 |
Cause: Missing semicolon. (7:3)"
`;
exports[`return.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80
| printWidth
=====================================input======================================
// @flow
function foo() {
return {
foo: 1,
bar: 2,
} as Foo;
}
=====================================output=====================================
// @flow
function foo() {
return {
foo: 1,
bar: 2,
} as Foo;
}
================================================================================
`;
exports[`satisfies.js [babel-flow] format 1`] = `
"Unexpected token, expected "type" (32:8)
30 | satisfies satisfies mixed;
31 | as satisfies mixed;
> 32 | opaque satisfies mixed;
| ^
33 |
34 | abc satisfies mixed; // not a keyword
35 | }
Cause: Unexpected token, expected "type" (32:7)"
`;
exports[`satisfies.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80
| printWidth
=====================================input======================================
// @flow
const x = y satisfies T;
// demonstrating how "satisfies" expression can be practically used as expression statement.
const _ = (type: 'foo' | 'bar') => {
switch (type) {
case 'foo':
return 1;
case 'bar':
return 2;
default:
// exhaustiveness check idiom
(type) satisfies empty;
throw new Error('unreachable');
}
}
function needParens() {
(let) satisfies mixed;
(interface) satisfies mixed;
(module) satisfies mixed;
(using) satisfies mixed;
(yield) satisfies mixed;
(await) satisfies mixed;
}
function noNeedParens() {
async satisfies mixed;
satisfies satisfies mixed;
as satisfies mixed;
opaque satisfies mixed;
abc satisfies mixed; // not a keyword
}
function satisfiesChain() {
satisfies satisfies satisfies satisfies satisfies;
(type) satisfies empty satisfies mixed;
}
=====================================output=====================================
// @flow
const x = y satisfies T;
// demonstrating how "satisfies" expression can be practically used as expression statement.
const _ = (type: "foo" | "bar") => {
switch (type) {
case "foo":
return 1;
case "bar":
return 2;
default:
// exhaustiveness check idiom
(type) satisfies empty;
throw new Error("unreachable");
}
};
function needParens() {
(let) satisfies mixed;
(interface) satisfies mixed;
(module) satisfies mixed;
(using) satisfies mixed;
(yield) satisfies mixed;
(await) satisfies mixed;
}
function noNeedParens() {
async satisfies mixed;
satisfies satisfies mixed;
as satisfies mixed;
opaque satisfies mixed;
abc satisfies mixed; // not a keyword
}
function satisfiesChain() {
satisfies satisfies satisfies satisfies satisfies;
(type) satisfies empty satisfies mixed;
}
================================================================================
`;
exports[`ternary.js [babel-flow] format 1`] = `
"Unexpected token, expected "," (28:32)
26 | void ((coooooooooooooooooooooooooooooooooooooooooooooooooooond
27 | ? baaaaaaaaaaaaaaaaaaaaar
> 28 | : baaaaaaaaaaaaaaaaaaaaaz) as Fooooooooooo);
| ^
29 | }
30 |
31 | bifornCringerMoshedPerplexSawder =
Cause: Unexpected token, expected "," (28:31)"
`;
exports[`ternary.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80
| printWidth
=====================================input======================================
// @flow
foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond
? baaaaaaaaaaaaaaaaaaaaar
: baaaaaaaaaaaaaaaaaaaaaz) as Fooooooooooo;
foo = (condition ? firstValue : secondValue) as SomeType;
const foo = (coooooooooooooooooooooooooooooooooooooooooooooooooooond
? baaaaaaaaaaaaaaaaaaaaar
: baaaaaaaaaaaaaaaaaaaaaz) as Fooooooooooo;
function foo() {
return (coooooooooooooooooooooooooooooooooooooooooooooooooooond
? baaaaaaaaaaaaaaaaaaaaar
: baaaaaaaaaaaaaaaaaaaaaz) as Fooooooooooo;
}
function foo() {
throw (coooooooooooooooooooooooooooooooooooooooooooooooooooond
? baaaaaaaaaaaaaaaaaaaaar
: baaaaaaaaaaaaaaaaaaaaaz) as Fooooooooooo;
}
function foo() {
void ((coooooooooooooooooooooooooooooooooooooooooooooooooooond
? baaaaaaaaaaaaaaaaaaaaar
: baaaaaaaaaaaaaaaaaaaaaz) as Fooooooooooo);
}
bifornCringerMoshedPerplexSawder =
askTrovenaBeenaDependsRowans +
((glimseGlyphsHazardNoopsTieTie === 0
? averredBathersBoxroomBuggyNurl
: anodyneCondosMalateOverateRetinol) as AnnularCooeedSplicesWalksWayWay);
bifornCringerMoshedPerplexSawder =
askTrovenaBeenaDependsRowans +
((glimseGlyphsHazardNoopsTieTie === 0 &&
kochabCooieGameOnOboleUnweave === Math.PI
? averredBathersBoxroomBuggyNurl
: anodyneCondosMalateOverateRetinol) as AnnularCooeedSplicesWalksWayWay);
=====================================output=====================================
// @flow
foo = (
coooooooooooooooooooooooooooooooooooooooooooooooooooond
? baaaaaaaaaaaaaaaaaaaaar
: baaaaaaaaaaaaaaaaaaaaaz
) as Fooooooooooo;
foo = (condition ? firstValue : secondValue) as SomeType;
const foo = (
coooooooooooooooooooooooooooooooooooooooooooooooooooond
? baaaaaaaaaaaaaaaaaaaaar
: baaaaaaaaaaaaaaaaaaaaaz
) as Fooooooooooo;
function foo() {
return (
coooooooooooooooooooooooooooooooooooooooooooooooooooond
? baaaaaaaaaaaaaaaaaaaaar
: baaaaaaaaaaaaaaaaaaaaaz
) as Fooooooooooo;
}
function foo() {
throw (
coooooooooooooooooooooooooooooooooooooooooooooooooooond
? baaaaaaaaaaaaaaaaaaaaar
: baaaaaaaaaaaaaaaaaaaaaz
) as Fooooooooooo;
}
function foo() {
void ((
coooooooooooooooooooooooooooooooooooooooooooooooooooond
? baaaaaaaaaaaaaaaaaaaaar
: baaaaaaaaaaaaaaaaaaaaaz
) as Fooooooooooo);
}
bifornCringerMoshedPerplexSawder =
askTrovenaBeenaDependsRowans +
((glimseGlyphsHazardNoopsTieTie === 0
? averredBathersBoxroomBuggyNurl
: anodyneCondosMalateOverateRetinol) as AnnularCooeedSplicesWalksWayWay);
bifornCringerMoshedPerplexSawder =
askTrovenaBeenaDependsRowans +
((glimseGlyphsHazardNoopsTieTie === 0 &&
kochabCooieGameOnOboleUnweave === Math.PI
? averredBathersBoxroomBuggyNurl
: anodyneCondosMalateOverateRetinol) as AnnularCooeedSplicesWalksWayWay);
================================================================================
`;