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

107 lines
2.0 KiB
Plaintext

exports[`test typecheck.js 1`] = `
"/* @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)
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @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[`test unreachable.js 1`] = `
"/* @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);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* @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);
"
`;