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