diff --git a/lib/node.js b/lib/node.js index aafd46521d5..5135f4e2458 100644 --- a/lib/node.js +++ b/lib/node.js @@ -1621,6 +1621,7 @@ declare class Process extends events$EventEmitter { cwd() : string; disconnect? : () => void; env : { [key: string] : ?string }; + emitWarning(warning : string | Error, name? : string, ctor? : Function) : void; execArgv : Array; execPath : string; exit(code? : number) : void; diff --git a/tests/node_tests/node_tests.exp b/tests/node_tests/node_tests.exp index 37c82cc622a..71543fecb6c 100644 --- a/tests/node_tests/node_tests.exp +++ b/tests/node_tests/node_tests.exp @@ -274,5 +274,71 @@ os/userInfo.js:14 14: (u3.username: string); // error ^^^^^^ string - -Found 33 errors +process/process.js:10 + 10: process.emitWarning(); // error + ^^^^^^^^^^^^^^^^^^^^^ call of method `emitWarning` + 10: process.emitWarning(); // error + ^^^^^^^^^^^^^^^^^^^^^ undefined (too few arguments, expected default/rest parameters). This type is incompatible with +1624: emitWarning(warning : string | Error, name? : string, ctor? : Function) : void; + ^^^^^^^^^^^^^^ union: string | Error. See lib: /node.js:1624 + Member 1: + 1624: emitWarning(warning : string | Error, name? : string, ctor? : Function) : void; + ^^^^^^ string. See lib: /node.js:1624 + Error: + 10: process.emitWarning(); // error + ^^^^^^^^^^^^^^^^^^^^^ undefined (too few arguments, expected default/rest parameters). This type is incompatible with + 1624: emitWarning(warning : string | Error, name? : string, ctor? : Function) : void; + ^^^^^^ string. See lib: /node.js:1624 + Member 2: + 1624: emitWarning(warning : string | Error, name? : string, ctor? : Function) : void; + ^^^^^ Error. See lib: /node.js:1624 + Error: + 10: process.emitWarning(); // error + ^^^^^^^^^^^^^^^^^^^^^ undefined (too few arguments, expected default/rest parameters). This type is incompatible with + 1624: emitWarning(warning : string | Error, name? : string, ctor? : Function) : void; + ^^^^^ Error. See lib: /node.js:1624 + +process/process.js:11 + 11: process.emitWarning(42); // error + ^^^^^^^^^^^^^^^^^^^^^^^ call of method `emitWarning` + 11: process.emitWarning(42); // error + ^^ number. This type is incompatible with +1624: emitWarning(warning : string | Error, name? : string, ctor? : Function) : void; + ^^^^^^^^^^^^^^ union: string | Error. See lib: /node.js:1624 + Member 1: + 1624: emitWarning(warning : string | Error, name? : string, ctor? : Function) : void; + ^^^^^^ string. See lib: /node.js:1624 + Error: + 11: process.emitWarning(42); // error + ^^ number. This type is incompatible with + 1624: emitWarning(warning : string | Error, name? : string, ctor? : Function) : void; + ^^^^^^ string. See lib: /node.js:1624 + Member 2: + 1624: emitWarning(warning : string | Error, name? : string, ctor? : Function) : void; + ^^^^^ Error. See lib: /node.js:1624 + Error: + 11: process.emitWarning(42); // error + ^^ number. This type is incompatible with + 1624: emitWarning(warning : string | Error, name? : string, ctor? : Function) : void; + ^^^^^ Error. See lib: /node.js:1624 + +process/process.js:12 + 12: process.emitWarning("blah", 42); // error + ^^ number. This type is incompatible with the expected param type of +1624: emitWarning(warning : string | Error, name? : string, ctor? : Function) : void; + ^^^^^^ string. See lib: /node.js:1624 + +process/process.js:13 + 13: process.emitWarning("blah", "blah", 42); // error + ^^ number. This type is incompatible with the expected param type of +1624: emitWarning(warning : string | Error, name? : string, ctor? : Function) : void; + ^^^^^^^^ function type. See lib: /node.js:1624 + +process/process.js:14 + 14: (process.emitWarning("blah"): string); // error + ^^^^^^^^^^^^^^^^^^^^^^^^^^^ undefined. This type is incompatible with + 14: (process.emitWarning("blah"): string); // error + ^^^^^^ string + + +Found 38 errors diff --git a/tests/node_tests/process/process.js b/tests/node_tests/process/process.js new file mode 100644 index 00000000000..dffcdab7f3a --- /dev/null +++ b/tests/node_tests/process/process.js @@ -0,0 +1,14 @@ +/* @flow */ + +/* emitWarning */ + +process.emitWarning("blah"); +process.emitWarning(new Error("blah")); +process.emitWarning("blah", "blah"); +process.emitWarning("blah", "blah", () => {}); + +process.emitWarning(); // error +process.emitWarning(42); // error +process.emitWarning("blah", 42); // error +process.emitWarning("blah", "blah", 42); // error +(process.emitWarning("blah"): string); // error