112 lines
1.8 KiB
Plaintext
112 lines
1.8 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`function_return.js 1`] = `
|
|
class C {
|
|
foo() { }
|
|
bar() { return; }
|
|
fn(x:number) { return x; }
|
|
}
|
|
|
|
function f(x): number {
|
|
if (x > 1) {
|
|
return 42;
|
|
}
|
|
}
|
|
|
|
function g(x): ?number {
|
|
if (x > 1) {
|
|
return 42;
|
|
}
|
|
}
|
|
|
|
function h(x): number {
|
|
if (x > 1) {
|
|
return 42;
|
|
}
|
|
return;
|
|
}
|
|
|
|
function i(x): ?number {
|
|
if (x > 1) {
|
|
return 42;
|
|
}
|
|
return;
|
|
}
|
|
|
|
module.exports = C;
|
|
|
|
//function fn(x:number) { return x; }
|
|
//module.exports = fn;
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
class C {
|
|
foo() {}
|
|
bar() {
|
|
return;
|
|
}
|
|
fn(x: number) {
|
|
return x;
|
|
}
|
|
}
|
|
|
|
function f(x): number {
|
|
if (x > 1) {
|
|
return 42;
|
|
}
|
|
}
|
|
|
|
function g(x): ?number {
|
|
if (x > 1) {
|
|
return 42;
|
|
}
|
|
}
|
|
|
|
function h(x): number {
|
|
if (x > 1) {
|
|
return 42;
|
|
}
|
|
return;
|
|
}
|
|
|
|
function i(x): ?number {
|
|
if (x > 1) {
|
|
return 42;
|
|
}
|
|
return;
|
|
}
|
|
|
|
module.exports = C;
|
|
|
|
//function fn(x:number) { return x; }
|
|
//module.exports = fn;
|
|
|
|
`;
|
|
|
|
exports[`void.js 1`] = `
|
|
/* This is a regression test. At one point we incorrectly inferred the return
|
|
type of functions that have an explicit \`undefined\` to be only \`undefined\` --
|
|
ignoring other possible exits. */
|
|
function f(b) {
|
|
if (b) {
|
|
return undefined;
|
|
} else {
|
|
return "nope";
|
|
}
|
|
}
|
|
|
|
(f(true): void); // error: string ~> void
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/* This is a regression test. At one point we incorrectly inferred the return
|
|
type of functions that have an explicit \`undefined\` to be only \`undefined\` --
|
|
ignoring other possible exits. */
|
|
function f(b) {
|
|
if (b) {
|
|
return undefined;
|
|
} else {
|
|
return "nope";
|
|
}
|
|
}
|
|
|
|
(f(true): void); // error: string ~> void
|
|
|
|
`;
|