Skip to content

Commit 209e911

Browse files
🤖 Merge PR DefinitelyTyped#74607 [@types/node]: v24.12.0 by @kshitijanurag
1 parent 2adbdc1 commit 209e911

18 files changed

Lines changed: 315 additions & 131 deletions

types/node/v24/child_process.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*
66
* ```js
77
* import { spawn } from 'node:child_process';
8+
* import { once } from 'node:events';
89
* const ls = spawn('ls', ['-lh', '/usr']);
910
*
1011
* ls.stdout.on('data', (data) => {
@@ -15,9 +16,8 @@
1516
* console.error(`stderr: ${data}`);
1617
* });
1718
*
18-
* ls.on('close', (code) => {
19-
* console.log(`child process exited with code ${code}`);
20-
* });
19+
* const [code] = await once(ls, 'close');
20+
* console.log(`child process exited with code ${code}`);
2121
* ```
2222
*
2323
* By default, pipes for `stdin`, `stdout`, and `stderr` are established between
@@ -719,6 +719,7 @@ declare module "child_process" {
719719
*
720720
* ```js
721721
* import { spawn } from 'node:child_process';
722+
* import { once } from 'node:events';
722723
* const ls = spawn('ls', ['-lh', '/usr']);
723724
*
724725
* ls.stdout.on('data', (data) => {
@@ -729,9 +730,8 @@ declare module "child_process" {
729730
* console.error(`stderr: ${data}`);
730731
* });
731732
*
732-
* ls.on('close', (code) => {
733-
* console.log(`child process exited with code ${code}`);
734-
* });
733+
* const [code] = await once(ls, 'close');
734+
* console.log(`child process exited with code ${code}`);
735735
* ```
736736
*
737737
* Example: A very elaborate way to run `ps ax | grep ssh`

types/node/v24/crypto.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2709,12 +2709,12 @@ declare module "crypto" {
27092709
privateKey: T2;
27102710
}
27112711
/**
2712-
* Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC,
2713-
* Ed25519, Ed448, X25519, X448, DH, and ML-DSA are currently supported.
2712+
* Generates a new asymmetric key pair of the given `type`.
2713+
* See the supported [asymmetric key types](https://nodejs.org/docs/latest-v24.x/api/crypto.html#asymmetric-key-types).
27142714
*
27152715
* If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
2716-
* behaves as if `keyObject.export()` had been called on its result. Otherwise,
2717-
* the respective part of the key is returned as a `KeyObject`.
2716+
* behaves as if {@link KeyObject.export `keyObject.export()`} had been called on its result. Otherwise,
2717+
* the respective part of the key is returned as a {@link KeyObject `KeyObject`}.
27182718
*
27192719
* When encoding public keys, it is recommended to use `'spki'`. When encoding
27202720
* private keys, it is recommended to use `'pkcs8'` with a strong passphrase,
@@ -3007,12 +3007,12 @@ declare module "crypto" {
30073007
options?: SLHDSAKeyPairKeyObjectOptions,
30083008
): KeyPairKeyObjectResult;
30093009
/**
3010-
* Generates a new asymmetric key pair of the given `type`. RSA, RSA-PSS, DSA, EC,
3011-
* Ed25519, Ed448, X25519, X448, and DH are currently supported.
3010+
* Generates a new asymmetric key pair of the given `type`.
3011+
* See the supported [asymmetric key types](https://nodejs.org/docs/latest-v24.x/api/crypto.html#asymmetric-key-types).
30123012
*
30133013
* If a `publicKeyEncoding` or `privateKeyEncoding` was specified, this function
3014-
* behaves as if `keyObject.export()` had been called on its result. Otherwise,
3015-
* the respective part of the key is returned as a `KeyObject`.
3014+
* behaves as if {@link KeyObject.export `keyObject.export()`} had been called on its result. Otherwise,
3015+
* the respective part of the key is returned as a {@link KeyObject `KeyObject`}.
30163016
*
30173017
* It is recommended to encode public keys as `'spki'` and private keys as `'pkcs8'` with encryption for long-term storage:
30183018
*

types/node/v24/http.d.ts

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,14 @@ declare module "http" {
357357
* @since v18.17.0, v20.2.0
358358
*/
359359
rejectNonStandardBodyWrites?: boolean | undefined;
360+
/**
361+
* If set to `true`, requests without `Content-Length` or `Transfer-Encoding` headers (indicating no body)
362+
* will be initialized with an already-ended body stream, so they will never emit any stream events
363+
* (like `'data'` or `'end'`). You can use `req.readableEnded` to detect this case.
364+
* @default false
365+
* @since v24.12.0
366+
*/
367+
optimizeEmptyRequests?: boolean | undefined;
360368
}
361369
type RequestListener<
362370
Request extends typeof IncomingMessage = typeof IncomingMessage,
@@ -1020,6 +1028,7 @@ declare module "http" {
10201028
*
10211029
* ```js
10221030
* import http from 'node:http';
1031+
* const agent = new http.Agent({ keepAlive: true });
10231032
*
10241033
* // Server has a 5 seconds keep-alive timeout by default
10251034
* http
@@ -1661,20 +1670,31 @@ declare module "http" {
16611670
/**
16621671
* Produces a socket/stream to be used for HTTP requests.
16631672
*
1664-
* By default, this function is the same as `net.createConnection()`. However,
1665-
* custom agents may override this method in case greater flexibility is desired.
1673+
* By default, this function behaves identically to `net.createConnection()`, synchronously
1674+
* returning the created socket. The optional `callback` parameter in the signature is not
1675+
* used by this default implementation.
16661676
*
1667-
* A socket/stream can be supplied in one of two ways: by returning the
1668-
* socket/stream from this function, or by passing the socket/stream to `callback`.
1677+
* However, custom agents may override this method to provide greater flexibility,
1678+
* for example, to create sockets asynchronously. When overriding `createConnection`:
16691679
*
1670-
* This method is guaranteed to return an instance of the `net.Socket` class,
1671-
* a subclass of `stream.Duplex`, unless the user specifies a socket
1672-
* type other than `net.Socket`.
1680+
* 1. **Synchronous socket creation**: The overriding method can return the socket/stream directly.
1681+
* 2. **Asynchronous socket creation**: The overriding method can accept the `callback` and pass
1682+
* the created socket/stream to it (e.g., `callback(null, newSocket)`). If an error occurs during
1683+
* socket creation, it should be passed as the first argument to the `callback` (e.g., `callback(err)`).
16731684
*
1674-
* `callback` has a signature of `(err, stream)`.
1685+
* The agent will call the provided `createConnection` function with `options` and this internal
1686+
* `callback`. The `callback` provided by the agent has a signature of `(err, stream)`.
16751687
* @since v0.11.4
1676-
* @param options Options containing connection details. Check `createConnection` for the format of the options
1677-
* @param callback Callback function that receives the created socket
1688+
* @param options Options containing connection details. Check `net.createConnection()`
1689+
* for the format of the options. For custom agents, this object is passed
1690+
* to the custom `createConnection` function.
1691+
* @param callback (Optional, primarily for custom agents) A function to be called by a custom
1692+
* `createConnection` implementation when the socket is created, especially for
1693+
* asynchronous operations.
1694+
* @returns `stream.Duplex` The created socket. This is returned by the default implementation
1695+
* or by a custom synchronous `createConnection` implementation. If a
1696+
* custom `createConnection` uses the `callback` for asynchronous operation,
1697+
* this return value might not be the primary way to obtain the socket.
16781698
*/
16791699
createConnection(
16801700
options: ClientRequestArgs,

types/node/v24/https.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ declare module "https" {
2525
}
2626
/**
2727
* An `Agent` object for HTTPS similar to `http.Agent`. See {@link request} for more information.
28+
*
29+
* Like `http.Agent`, the `createConnection(options[, callback])` method can be overridden to customize
30+
* how TLS connections are established.
31+
*
32+
* > See [`agent.createConnection()`](https://nodejs.org/docs/latest-v24.x/api/http.html#agentcreateconnectionoptions-callback)
33+
* for details on overriding this method, including asynchronous socket creation with a callback.
2834
* @since v0.4.5
2935
*/
3036
class Agent extends http.Agent {

types/node/v24/module.d.ts

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,37 +80,48 @@ declare module "module" {
8080
*/
8181
directory?: string;
8282
}
83+
interface EnableCompileCacheOptions {
84+
/**
85+
* Optional. Directory to store the compile cache. If not specified, the directory specified by
86+
* the [`NODE_COMPILE_CACHE=dir`](https://nodejs.org/docs/latest-v24.x/api/cli.html#node_compile_cachedir)
87+
* environment variable will be used if it's set, or `path.join(os.tmpdir(), 'node-compile-cache')` otherwise.
88+
* @since v24.12.0
89+
*/
90+
directory?: string | undefined;
91+
/**
92+
* Optional. If `true`, enables portable compile cache so that the cache can be reused even if the project directory
93+
* is moved. This is a best-effort feature. If not specified, it will depend on whether the environment variable
94+
* [NODE_COMPILE_CACHE_PORTABLE=1](https://nodejs.org/docs/latest-v24.x/api/cli.html#node_compile_cache_portable1) is set.
95+
* @since v24.12.0
96+
*/
97+
portable?: boolean | undefined;
98+
}
8399
/**
84100
* Enable [module compile cache](https://nodejs.org/docs/latest-v24.x/api/module.html#module-compile-cache)
85101
* in the current Node.js instance.
86102
*
87-
* If `cacheDir` is not specified, Node.js will either use the directory specified by the
88-
* `NODE_COMPILE_CACHE=dir` environment variable if it's set, or use
89-
* `path.join(os.tmpdir(), 'node-compile-cache')` otherwise. For general use cases, it's
90-
* recommended to call `module.enableCompileCache()` without specifying the `cacheDir`,
91-
* so that the directory can be overridden by the `NODE_COMPILE_CACHE` environment
103+
* For general use cases, it's recommended to call `module.enableCompileCache()` without specifying the
104+
* `options.directory`, so that the directory can be overridden by the `NODE_COMPILE_CACHE` environment
92105
* variable when necessary.
93106
*
94-
* Since compile cache is supposed to be a quiet optimization that is not required for the
95-
* application to be functional, this method is designed to not throw any exception when the
96-
* compile cache cannot be enabled. Instead, it will return an object containing an error
97-
* message in the `message` field to aid debugging.
98-
* If compile cache is enabled successfully, the `directory` field in the returned object
99-
* contains the path to the directory where the compile cache is stored. The `status`
100-
* field in the returned object would be one of the `module.constants.compileCacheStatus`
101-
* values to indicate the result of the attempt to enable the
107+
* Since compile cache is supposed to be a optimization that is not mission critical, this method is
108+
* designed to not throw any exception when the compile cache cannot be enabled. Instead, it will return
109+
* an object containing an error message in the `message` field to aid debugging. If compile cache is
110+
* enabled successfully, the `directory` field in the returned object contains the path to the directory
111+
* where the compile cache is stored. The `status` field in the returned object would be one of the
112+
* `module.constants.compileCacheStatus` values to indicate the result of the attempt to enable the
102113
* [module compile cache](https://nodejs.org/docs/latest-v24.x/api/module.html#module-compile-cache).
103114
*
104115
* This method only affects the current Node.js instance. To enable it in child worker threads,
105116
* either call this method in child worker threads too, or set the
106117
* `process.env.NODE_COMPILE_CACHE` value to compile cache directory so the behavior can
107118
* be inherited into the child workers. The directory can be obtained either from the
108-
* `directory` field returned by this method, or with {@link getCompileCacheDir}.
119+
* `directory` field returned by this method, or with {@link getCompileCacheDir `module.getCompileCacheDir()`}.
109120
* @since v22.8.0
110-
* @param cacheDir Optional path to specify the directory where the compile cache
121+
* @param options Optional. If a string is passed, it is considered to be `options.directory`.
111122
* will be stored/retrieved.
112123
*/
113-
function enableCompileCache(cacheDir?: string): EnableCompileCacheResult;
124+
function enableCompileCache(options?: string | EnableCompileCacheOptions): EnableCompileCacheResult;
114125
/**
115126
* Flush the [module compile cache](https://nodejs.org/docs/latest-v24.x/api/module.html#module-compile-cache)
116127
* accumulated from modules already loaded

types/node/v24/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@types/node",
4-
"version": "24.11.9999",
4+
"version": "24.12.9999",
55
"nonNpm": "conflict",
66
"nonNpmDescription": "Node.js",
77
"projects": [

0 commit comments

Comments
 (0)