| | |
| | | declare module "node:process" { |
| | | import { Control, MessageOptions, SendHandle } from "node:child_process"; |
| | | import { InternalEventEmitter } from "node:events"; |
| | | import { PathLike } from "node:fs"; |
| | | import * as tty from "node:tty"; |
| | | import { Worker } from "node:worker_threads"; |
| | |
| | | /** |
| | | * A value that is `"strip"` by default, |
| | | * `"transform"` if Node.js is run with `--experimental-transform-types`, and `false` if |
| | | * Node.js is run with `--no-experimental-strip-types`. |
| | | * Node.js is run with `--no-strip-types`. |
| | | * @since v22.10.0 |
| | | */ |
| | | readonly typescript: "strip" | "transform" | false; |
| | |
| | | isTTY?: true | undefined; |
| | | } |
| | | // Alias for compatibility |
| | | interface ProcessEnv extends Dict<string> { |
| | | /** |
| | | * Can be used to change the default timezone at runtime |
| | | */ |
| | | TZ?: string | undefined; |
| | | } |
| | | interface ProcessEnv extends Dict<string> {} |
| | | interface HRTime { |
| | | /** |
| | | * This is the legacy version of {@link process.hrtime.bigint()} |
| | |
| | | */ |
| | | reportOnUncaughtException: boolean; |
| | | /** |
| | | * If true, a diagnostic report is generated without the environment variables. |
| | | * @default false |
| | | */ |
| | | excludeEnv: boolean; |
| | | /** |
| | | * The signal used to trigger the creation of a diagnostic report. |
| | | * @default 'SIGUSR2' |
| | | */ |
| | |
| | | readonly visibility: string; |
| | | }; |
| | | } |
| | | interface Process extends InternalEventEmitter<ProcessEventMap> { |
| | | interface Process extends EventEmitter { |
| | | /** |
| | | * The `process.stdout` property returns a stream connected to`stdout` (fd `1`). It is a `net.Socket` (which is a `Duplex` stream) unless fd `1` refers to a file, in which case it is |
| | | * a `Writable` stream. |
| | |
| | | * arguments passed when the Node.js process was launched. The first element will |
| | | * be {@link execPath}. See `process.argv0` if access to the original value |
| | | * of `argv[0]` is needed. The second element will be the path to the JavaScript |
| | | * file being executed. The remaining elements will be any additional command-line |
| | | * file being executed. If a [program entry point](https://nodejs.org/docs/latest-v25.x/api/cli.html#program-entry-point) was provided, the second element |
| | | * will be the absolute path to it. The remaining elements are additional command-line |
| | | * arguments. |
| | | * |
| | | * For example, assuming the following script for `process-args.js`: |
| | |
| | | readonly release: ProcessRelease; |
| | | readonly features: ProcessFeatures; |
| | | /** |
| | | * The `process.traceProcessWarnings` property indicates whether the `--trace-warnings` flag |
| | | * is set on the current Node.js process. This property allows programmatic control over the |
| | | * tracing of warnings, enabling or disabling stack traces for warnings at runtime. |
| | | * |
| | | * ```js |
| | | * // Enable trace warnings |
| | | * process.traceProcessWarnings = true; |
| | | * |
| | | * // Emit a warning with a stack trace |
| | | * process.emitWarning('Warning with stack trace'); |
| | | * |
| | | * // Disable trace warnings |
| | | * process.traceProcessWarnings = false; |
| | | * ``` |
| | | * @since v6.10.0 |
| | | */ |
| | | traceProcessWarnings: boolean; |
| | | /** |
| | | * `process.umask()` returns the Node.js process's file mode creation mask. Child |
| | | * processes inherit the mask from the parent process. |
| | | * @since v0.1.19 |
| | |
| | | sendHandle?: SendHandle, |
| | | options?: MessageOptions, |
| | | callback?: (error: Error | null) => void, |
| | | ): boolean; |
| | | send?( |
| | | message: any, |
| | | sendHandle: SendHandle, |
| | | callback?: (error: Error | null) => void, |
| | | ): boolean; |
| | | send?( |
| | | message: any, |
| | | callback: (error: Error | null) => void, |
| | | ): boolean; |
| | | /** |
| | | * If the Node.js process is spawned with an IPC channel (see the `Child Process` and `Cluster` documentation), the `process.disconnect()` method will close the |
| | |
| | | * **Default:** `process.env`. |
| | | */ |
| | | execve?(file: string, args?: readonly string[], env?: ProcessEnv): never; |
| | | // #region InternalEventEmitter |
| | | addListener<E extends keyof ProcessEventMap>( |
| | | eventName: E, |
| | | listener: (...args: ProcessEventMap[E]) => void, |
| | | ): this; |
| | | addListener(eventName: string | symbol, listener: (...args: any[]) => void): this; |
| | | emit<E extends keyof ProcessEventMap>(eventName: E, ...args: ProcessEventMap[E]): boolean; |
| | | emit(eventName: string | symbol, ...args: any[]): boolean; |
| | | listenerCount<E extends keyof ProcessEventMap>( |
| | | eventName: E, |
| | | listener?: (...args: ProcessEventMap[E]) => void, |
| | | ): number; |
| | | listenerCount(eventName: string | symbol, listener?: (...args: any[]) => void): number; |
| | | listeners<E extends keyof ProcessEventMap>(eventName: E): ((...args: ProcessEventMap[E]) => void)[]; |
| | | listeners(eventName: string | symbol): ((...args: any[]) => void)[]; |
| | | off<E extends keyof ProcessEventMap>( |
| | | eventName: E, |
| | | listener: (...args: ProcessEventMap[E]) => void, |
| | | ): this; |
| | | off(eventName: string | symbol, listener: (...args: any[]) => void): this; |
| | | on<E extends keyof ProcessEventMap>( |
| | | eventName: E, |
| | | listener: (...args: ProcessEventMap[E]) => void, |
| | | ): this; |
| | | on(eventName: string | symbol, listener: (...args: any[]) => void): this; |
| | | once<E extends keyof ProcessEventMap>( |
| | | eventName: E, |
| | | listener: (...args: ProcessEventMap[E]) => void, |
| | | ): this; |
| | | once(eventName: string | symbol, listener: (...args: any[]) => void): this; |
| | | prependListener<E extends keyof ProcessEventMap>( |
| | | eventName: E, |
| | | listener: (...args: ProcessEventMap[E]) => void, |
| | | ): this; |
| | | prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this; |
| | | prependOnceListener<E extends keyof ProcessEventMap>( |
| | | eventName: E, |
| | | listener: (...args: ProcessEventMap[E]) => void, |
| | | ): this; |
| | | prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this; |
| | | rawListeners<E extends keyof ProcessEventMap>(eventName: E): ((...args: ProcessEventMap[E]) => void)[]; |
| | | rawListeners(eventName: string | symbol): ((...args: any[]) => void)[]; |
| | | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics |
| | | removeAllListeners<E extends keyof ProcessEventMap>(eventName?: E): this; |
| | | removeAllListeners(eventName?: string | symbol): this; |
| | | removeListener<E extends keyof ProcessEventMap>( |
| | | eventName: E, |
| | | listener: (...args: ProcessEventMap[E]) => void, |
| | | ): this; |
| | | removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this; |
| | | // #endregion |
| | | } |
| | | } |
| | | } |