Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add declaration for node.js’ process.emitWarning #3248

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>;
execPath : string;
exit(code? : number) : void;
Expand Down
70 changes: 68 additions & 2 deletions tests/node_tests/node_tests.exp
Original file line number Diff line number Diff line change
Expand Up @@ -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: <BUILTINS>/node.js:1624
Member 1:
1624: emitWarning(warning : string | Error, name? : string, ctor? : Function) : void;
^^^^^^ string. See lib: <BUILTINS>/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: <BUILTINS>/node.js:1624
Member 2:
1624: emitWarning(warning : string | Error, name? : string, ctor? : Function) : void;
^^^^^ Error. See lib: <BUILTINS>/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: <BUILTINS>/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: <BUILTINS>/node.js:1624
Member 1:
1624: emitWarning(warning : string | Error, name? : string, ctor? : Function) : void;
^^^^^^ string. See lib: <BUILTINS>/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: <BUILTINS>/node.js:1624
Member 2:
1624: emitWarning(warning : string | Error, name? : string, ctor? : Function) : void;
^^^^^ Error. See lib: <BUILTINS>/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: <BUILTINS>/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: <BUILTINS>/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: <BUILTINS>/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
14 changes: 14 additions & 0 deletions tests/node_tests/process/process.js
Original file line number Diff line number Diff line change
@@ -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