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

126 lines
2.7 KiB
Plaintext

// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`typecheck.js 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80
| printWidth
=====================================input======================================
/* @flow */
function test1(): string {
return bar();
function bar() {
return 0;
}
}
// regression test for analysis after abnormal control flow:
// consts must not become bot (EmptyT).
function test2() {
const n = 0;
return;
function f() {
var x: typeof n = 0; // no error, n is still number
var y: string = n; // error, n is number (EmptyT would work)
}
}
=====================================output=====================================
/* @flow */
function test1(): string {
return bar();
function bar() {
return 0;
}
}
// regression test for analysis after abnormal control flow:
// consts must not become bot (EmptyT).
function test2() {
const n = 0;
return;
function f() {
var x: typeof n = 0; // no error, n is still number
var y: string = n; // error, n is number (EmptyT would work)
}
}
================================================================================
`;
exports[`unreachable.js 1`] = `
====================================options=====================================
parsers: ["flow"]
printWidth: 80
| printWidth
=====================================input======================================
/* @flow */
function foo(x, y) {
"use strict";
return bar(x) + baz(y);
// function declaration is hoisted, should not generate warning
function bar (ecks) {
return x + ecks;
}
// assignment is not hoisted, should generate warning
var baz = function (why) {
return y + why;
};
// variable declaration is hoisted, should not generate warning
var x, y, z;
// assignments are not hoisted, should generate 2 warnings
var t,
u = 5,
v,
w = 7;
}
foo(1, 2);
=====================================output=====================================
/* @flow */
function foo(x, y) {
"use strict";
return bar(x) + baz(y);
// function declaration is hoisted, should not generate warning
function bar(ecks) {
return x + ecks;
}
// assignment is not hoisted, should generate warning
var baz = function(why) {
return y + why;
};
// variable declaration is hoisted, should not generate warning
var x, y, z;
// assignments are not hoisted, should generate 2 warnings
var t,
u = 5,
v,
w = 7;
}
foo(1, 2);
================================================================================
`;