Files
test-repo/tests/format/flow-repo/tuples/__snapshots__/jsfmt.spec.js.snap
T

130 lines
4.3 KiB
Plaintext

// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`array.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80
| printWidth
=====================================input======================================
// @flow
function foo(x: Array<number>): [number, ?number] {
return x; // Error, can't enforce arity when flowing array to tuple
}
function foo(x: Array<number>): [number, ?number] {
return [x[0], x[1]]; // OK. This is unsound, but at least arity is enforced
}
=====================================output=====================================
// @flow
function foo(x: Array<number>): [number, ?number] {
return x; // Error, can't enforce arity when flowing array to tuple
}
function foo(x: Array<number>): [number, ?number] {
return [x[0], x[1]]; // OK. This is unsound, but at least arity is enforced
}
================================================================================
`;
exports[`optional.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80
| printWidth
=====================================input======================================
// @flow
([0, undefined]: [number, ?string]); // Ok, correct arity
([0]: [number, ?string]); // Error, arity is enforced
([]: [?number, string]); // error, since second element is not marked optional
=====================================output=====================================
// @flow
([0, undefined]: [number, ?string]); // Ok, correct arity
([0]: [number, ?string]); // Error, arity is enforced
([]: [?number, string]); // error, since second element is not marked optional
================================================================================
`;
exports[`spread.js [babel-flow] format 1`] = `
"Unexpected token (1:11)
> 1 | type A = [...S];
| ^
2 |
3 | type B = [...foo: S];
4 |
Cause: Unexpected token (1:10)"
`;
exports[`spread.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80
| printWidth
=====================================input======================================
type A = [...S];
type B = [...foo: S];
=====================================output=====================================
type A = [...S];
type B = [...foo: S];
================================================================================
`;
exports[`too-few.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80
| printWidth
=====================================input======================================
/* @flow */
function foo(a: [Object, Object]) {}
foo([ {} ]); // error, too few elements in array passed to a tuple
=====================================output=====================================
/* @flow */
function foo(a: [Object, Object]) {}
foo([{}]); // error, too few elements in array passed to a tuple
================================================================================
`;
exports[`tuples.js format 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80
| printWidth
=====================================input======================================
var a: [] = [];
var b: [] = [123]; // Error - arity mismatch
var c: [number] = []; // nope
var d: [number, string] = [123,'duck'];
var e: [number, string,] = [123,'duck'];
var f: [number, string] = [123, 456];
=====================================output=====================================
var a: [] = [];
var b: [] = [123]; // Error - arity mismatch
var c: [number] = []; // nope
var d: [number, string] = [123, "duck"];
var e: [number, string] = [123, "duck"];
var f: [number, string] = [123, 456];
================================================================================
`;