1 | declare module 'console' {
|
2 | import { InspectOptions } from 'util';
|
3 |
|
4 | global {
|
5 | // This needs to be global to avoid TS2403 in case lib.dom.d.ts is present in the same build
|
6 | interface Console {
|
7 | Console: NodeJS.ConsoleConstructor;
|
8 | /**
|
9 | * A simple assertion test that verifies whether `value` is truthy.
|
10 | * If it is not, an `AssertionError` is thrown.
|
11 | * If provided, the error `message` is formatted using `util.format()` and used as the error message.
|
12 | */
|
13 | assert(value: any, message?: string, ...optionalParams: any[]): void;
|
14 | /**
|
15 | * When `stdout` is a TTY, calling `console.clear()` will attempt to clear the TTY.
|
16 | * When `stdout` is not a TTY, this method does nothing.
|
17 | */
|
18 | clear(): void;
|
19 | /**
|
20 | * Maintains an internal counter specific to `label` and outputs to `stdout` the number of times `console.count()` has been called with the given `label`.
|
21 | */
|
22 | count(label?: string): void;
|
23 | /**
|
24 | * Resets the internal counter specific to `label`.
|
25 | */
|
26 | countReset(label?: string): void;
|
27 | /**
|
28 | * The `console.debug()` function is an alias for {@link console.log}.
|
29 | */
|
30 | debug(message?: any, ...optionalParams: any[]): void;
|
31 | /**
|
32 | * Uses {@link util.inspect} on `obj` and prints the resulting string to `stdout`.
|
33 | * This function bypasses any custom `inspect()` function defined on `obj`.
|
34 | */
|
35 | dir(obj: any, options?: InspectOptions): void;
|
36 | /**
|
37 | * This method calls {@link console.log} passing it the arguments received. Please note that this method does not produce any XML formatting
|
38 | */
|
39 | dirxml(...data: any[]): void;
|
40 | /**
|
41 | * Prints to `stderr` with newline.
|
42 | */
|
43 | error(message?: any, ...optionalParams: any[]): void;
|
44 | /**
|
45 | * Increases indentation of subsequent lines by two spaces.
|
46 | * If one or more `label`s are provided, those are printed first without the additional indentation.
|
47 | */
|
48 | group(...label: any[]): void;
|
49 | /**
|
50 | * The `console.groupCollapsed()` function is an alias for {@link console.group}.
|
51 | */
|
52 | groupCollapsed(...label: any[]): void;
|
53 | /**
|
54 | * Decreases indentation of subsequent lines by two spaces.
|
55 | */
|
56 | groupEnd(): void;
|
57 | /**
|
58 | * The {@link console.info} function is an alias for {@link console.log}.
|
59 | */
|
60 | info(message?: any, ...optionalParams: any[]): void;
|
61 | /**
|
62 | * Prints to `stdout` with newline.
|
63 | */
|
64 | log(message?: any, ...optionalParams: any[]): void;
|
65 | /**
|
66 | * This method does not display anything unless used in the inspector.
|
67 | * Prints to `stdout` the array `array` formatted as a table.
|
68 | */
|
69 | table(tabularData: any, properties?: ReadonlyArray<string>): void;
|
70 | /**
|
71 | * Starts a timer that can be used to compute the duration of an operation. Timers are identified by a unique `label`.
|
72 | */
|
73 | time(label?: string): void;
|
74 | /**
|
75 | * Stops a timer that was previously started by calling {@link console.time} and prints the result to `stdout`.
|
76 | */
|
77 | timeEnd(label?: string): void;
|
78 | /**
|
79 | * For a timer that was previously started by calling {@link console.time}, prints the elapsed time and other `data` arguments to `stdout`.
|
80 | */
|
81 | timeLog(label?: string, ...data: any[]): void;
|
82 | /**
|
83 | * Prints to `stderr` the string 'Trace :', followed by the {@link util.format} formatted message and stack trace to the current position in the code.
|
84 | */
|
85 | trace(message?: any, ...optionalParams: any[]): void;
|
86 | /**
|
87 | * The {@link console.warn} function is an alias for {@link console.error}.
|
88 | */
|
89 | warn(message?: any, ...optionalParams: any[]): void;
|
90 |
|
91 | // --- Inspector mode only ---
|
92 | /**
|
93 | * This method does not display anything unless used in the inspector.
|
94 | * Starts a JavaScript CPU profile with an optional label.
|
95 | */
|
96 | profile(label?: string): void;
|
97 | /**
|
98 | * This method does not display anything unless used in the inspector.
|
99 | * Stops the current JavaScript CPU profiling session if one has been started and prints the report to the Profiles panel of the inspector.
|
100 | */
|
101 | profileEnd(label?: string): void;
|
102 | /**
|
103 | * This method does not display anything unless used in the inspector.
|
104 | * Adds an event with the label `label` to the Timeline panel of the inspector.
|
105 | */
|
106 | timeStamp(label?: string): void;
|
107 | }
|
108 |
|
109 | var console: Console;
|
110 |
|
111 | namespace NodeJS {
|
112 | interface ConsoleConstructorOptions {
|
113 | stdout: WritableStream;
|
114 | stderr?: WritableStream | undefined;
|
115 | ignoreErrors?: boolean | undefined;
|
116 | colorMode?: boolean | 'auto' | undefined;
|
117 | inspectOptions?: InspectOptions | undefined;
|
118 | }
|
119 |
|
120 | interface ConsoleConstructor {
|
121 | prototype: Console;
|
122 | new(stdout: WritableStream, stderr?: WritableStream, ignoreErrors?: boolean): Console;
|
123 | new(options: ConsoleConstructorOptions): Console;
|
124 | }
|
125 |
|
126 | interface Global {
|
127 | console: typeof console;
|
128 | }
|
129 | }
|
130 | }
|
131 |
|
132 | export = console;
|
133 | }
|