// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`issue-518.js 1`] = ` function doSomethingAsync(): Promise { return new Promise((resolve, reject) => { resolve(); // OK to leave out arg, same as resolve(undefined) var anotherVoidPromise: Promise = Promise.resolve(); resolve(anotherVoidPromise); }); } // simpler repro to show that too few args are fine when expecting void function foo(x: void) { } foo(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ function doSomethingAsync(): Promise { return new Promise((resolve, reject) => { resolve(); // OK to leave out arg, same as resolve(undefined) var anotherVoidPromise: Promise = Promise.resolve(); resolve(anotherVoidPromise); }); } // simpler repro to show that too few args are fine when expecting void function foo(x: void) {} foo(); `; exports[`undefined.js 1`] = ` function foo() { var x; x.foo(); } function bar() { var x:?{ bar():void; }; if (x) x.bar(); } function qux(x?: number, y:string = "", z) { } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ function foo() { var x; x.foo(); } function bar() { var x: ?{ bar(): void }; if (x) x.bar(); } function qux(x?: number, y: string = "", z) {} `; exports[`undefined2.js 1`] = ` // @flow let tests = [ function(x: number) { var id; var name = id ? 'John' : undefined; (name: boolean); // error, string or void const bar = [ undefined, 'bar', ]; (bar[x]: boolean); // error, string or void }, function(x: number) { var undefined = 'foo'; (undefined: string); // ok var x; if (x !== undefined) { x[0]; // should error, could be void } const bar = [ undefined, 'bar', ]; (bar[x]: boolean); // error, string only }, ]; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // @flow let tests = [ function(x: number) { var id; var name = id ? "John" : undefined; (name: boolean); // error, string or void const bar = [undefined, "bar"]; (bar[x]: boolean); // error, string or void }, function(x: number) { var undefined = "foo"; (undefined: string); // ok var x; if (x !== undefined) { x[0]; // should error, could be void } const bar = [undefined, "bar"]; (bar[x]: boolean); // error, string only } ]; `;