prettier/tests/flow/type_param_variance2/__snapshots__/jsfmt.spec.js.snap

55 lines
1.1 KiB
Plaintext
Raw Normal View History

// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`promise.js 1`] = `
/**
* Here the definition of Promise<T> is routed to the class Promise
* in the user-specified library libs/Promise.js
*
* In such situations we must desugar async/await primitives
* to the shadowed library definition.
*
* @flow
*/
async function foo(x: boolean): Promise<?{bar: string}> {
if (x) {
return {bar: 'baz'}; // OK, because of covariant type param
} else {
return null;
}
}
async function run() {
console.log(await foo(true));
console.log(await foo(false));
}
run()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2016-12-27 21:29:31 +03:00
/**
* Here the definition of Promise<T> is routed to the class Promise
* in the user-specified library libs/Promise.js
*
* In such situations we must desugar async/await primitives
* to the shadowed library definition.
*
* @flow
*/
2016-12-27 21:29:31 +03:00
async function foo(x: boolean): Promise<?{ bar: string }> {
if (x) {
return { bar: "baz" }; // OK, because of covariant type param
2016-12-27 21:29:31 +03:00
} else {
return null;
2016-12-27 21:29:31 +03:00
}
}
2016-12-27 21:29:31 +03:00
async function run() {
console.log(await foo(true));
console.log(await foo(false));
2016-12-27 21:29:31 +03:00
}
2017-01-11 18:16:38 +03:00
run();
`;