Skip to content

Commit 66d662d

Browse files
authored
🤖 Merge PR DefinitelyTyped#73444 node: v24.4 by @Renegade334
1 parent 946e2f4 commit 66d662d

File tree

16 files changed

+287
-36
lines changed

16 files changed

+287
-36
lines changed

types/node/buffer.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ declare module "buffer" {
139139
type?: string | undefined;
140140
}
141141
/**
142-
* A [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) encapsulates immutable, raw data that can be safely shared across
142+
* A `Blob` encapsulates immutable, raw data that can be safely shared across
143143
* multiple worker threads.
144144
* @since v15.7.0, v14.18.0
145145
*/

types/node/child_process.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* the parent Node.js process and the spawned subprocess. These pipes have
2525
* limited (and platform-specific) capacity. If the subprocess writes to
2626
* stdout in excess of that limit without the output being captured, the
27-
* subprocess blocks waiting for the pipe buffer to accept more data. This is
27+
* subprocess blocks, waiting for the pipe buffer to accept more data. This is
2828
* identical to the behavior of pipes in the shell. Use the `{ stdio: 'ignore' }` option if the output will not be consumed.
2929
*
3030
* The command lookup is performed using the `options.env.PATH` environment

types/node/crypto.d.ts

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3363,11 +3363,36 @@ declare module "crypto" {
33633363
options: { privateKey: KeyObject; publicKey: KeyObject },
33643364
callback: (err: Error | null, secret: Buffer) => void,
33653365
): void;
3366+
interface OneShotDigestOptions {
3367+
/**
3368+
* Encoding used to encode the returned digest.
3369+
* @default 'hex'
3370+
*/
3371+
outputEncoding?: BinaryToTextEncoding | "buffer" | undefined;
3372+
/**
3373+
* For XOF hash functions such as 'shake256', the outputLength option
3374+
* can be used to specify the desired output length in bytes.
3375+
*/
3376+
outputLength?: number | undefined;
3377+
}
3378+
interface OneShotDigestOptionsWithStringEncoding extends OneShotDigestOptions {
3379+
outputEncoding?: BinaryToTextEncoding | undefined;
3380+
}
3381+
interface OneShotDigestOptionsWithBufferEncoding extends OneShotDigestOptions {
3382+
outputEncoding: "buffer";
3383+
}
33663384
/**
3367-
* A utility for creating one-shot hash digests of data. It can be faster than the object-based `crypto.createHash()` when hashing a smaller amount of data
3368-
* (<= 5MB) that's readily available. If the data can be big or if it is streamed, it's still recommended to use `crypto.createHash()` instead. The `algorithm`
3369-
* is dependent on the available algorithms supported by the version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc. On recent releases
3370-
* of OpenSSL, `openssl list -digest-algorithms` will display the available digest algorithms.
3385+
* A utility for creating one-shot hash digests of data. It can be faster than
3386+
* the object-based `crypto.createHash()` when hashing a smaller amount of data
3387+
* (<= 5MB) that's readily available. If the data can be big or if it is streamed,
3388+
* it's still recommended to use `crypto.createHash()` instead.
3389+
*
3390+
* The `algorithm` is dependent on the available algorithms supported by the
3391+
* version of OpenSSL on the platform. Examples are `'sha256'`, `'sha512'`, etc.
3392+
* On recent releases of OpenSSL, `openssl list -digest-algorithms` will
3393+
* display the available digest algorithms.
3394+
*
3395+
* If `options` is a string, then it specifies the `outputEncoding`.
33713396
*
33723397
* Example:
33733398
*
@@ -3387,16 +3412,25 @@ declare module "crypto" {
33873412
* console.log(crypto.hash('sha1', Buffer.from(base64, 'base64'), 'buffer'));
33883413
* ```
33893414
* @since v21.7.0, v20.12.0
3390-
* @param data When `data` is a string, it will be encoded as UTF-8 before being hashed. If a different input encoding is desired for a string input, user
3391-
* could encode the string into a `TypedArray` using either `TextEncoder` or `Buffer.from()` and passing the encoded `TypedArray` into this API instead.
3392-
* @param [outputEncoding='hex'] [Encoding](https://nodejs.org/docs/latest-v24.x/api/buffer.html#buffers-and-character-encodings) used to encode the returned digest.
3415+
* @param data When `data` is a string, it will be encoded as UTF-8 before being hashed. If a different
3416+
* input encoding is desired for a string input, user could encode the string
3417+
* into a `TypedArray` using either `TextEncoder` or `Buffer.from()` and passing
3418+
* the encoded `TypedArray` into this API instead.
33933419
*/
3394-
function hash(algorithm: string, data: BinaryLike, outputEncoding?: BinaryToTextEncoding): string;
3395-
function hash(algorithm: string, data: BinaryLike, outputEncoding: "buffer"): Buffer;
33963420
function hash(
33973421
algorithm: string,
33983422
data: BinaryLike,
3399-
outputEncoding?: BinaryToTextEncoding | "buffer",
3423+
options?: OneShotDigestOptionsWithStringEncoding | BinaryToTextEncoding,
3424+
): string;
3425+
function hash(
3426+
algorithm: string,
3427+
data: BinaryLike,
3428+
options: OneShotDigestOptionsWithBufferEncoding | "buffer",
3429+
): Buffer;
3430+
function hash(
3431+
algorithm: string,
3432+
data: BinaryLike,
3433+
options: OneShotDigestOptions | BinaryToTextEncoding | "buffer",
34003434
): string | Buffer;
34013435
type CipherMode = "cbc" | "ccm" | "cfb" | "ctr" | "ecb" | "gcm" | "ocb" | "ofb" | "stream" | "wrap" | "xts";
34023436
interface CipherInfoOptions {

types/node/fs.d.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,6 +1966,39 @@ declare module "fs" {
19661966
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
19671967
*/
19681968
export function mkdtempSync(prefix: string, options?: EncodingOption): string | Buffer;
1969+
export interface DisposableTempDir extends AsyncDisposable {
1970+
/**
1971+
* The path of the created directory.
1972+
*/
1973+
path: string;
1974+
/**
1975+
* A function which removes the created directory.
1976+
*/
1977+
remove(): Promise<void>;
1978+
/**
1979+
* The same as `remove`.
1980+
*/
1981+
[Symbol.asyncDispose](): Promise<void>;
1982+
}
1983+
/**
1984+
* Returns a disposable object whose `path` property holds the created directory
1985+
* path. When the object is disposed, the directory and its contents will be
1986+
* removed if it still exists. If the directory cannot be deleted, disposal will
1987+
* throw an error. The object has a `remove()` method which will perform the same
1988+
* task.
1989+
*
1990+
* <!-- TODO: link MDN docs for disposables once https://github.com/mdn/content/pull/38027 lands -->
1991+
*
1992+
* For detailed information, see the documentation of `fs.mkdtemp()`.
1993+
*
1994+
* There is no callback-based version of this API because it is designed for use
1995+
* with the `using` syntax.
1996+
*
1997+
* The optional `options` argument can be a string specifying an encoding, or an
1998+
* object with an `encoding` property specifying the character encoding to use.
1999+
* @since v24.4.0
2000+
*/
2001+
export function mkdtempDisposableSync(prefix: string, options?: EncodingOption): DisposableTempDir;
19692002
/**
19702003
* Reads the contents of a directory. The callback gets two arguments `(err, files)` where `files` is an array of the names of the files in the directory excluding `'.'` and `'..'`.
19712004
*

types/node/fs/promises.d.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ declare module "fs/promises" {
2020
CopyOptions,
2121
Dir,
2222
Dirent,
23+
DisposableTempDir,
24+
EncodingOption,
2325
GlobOptions,
2426
GlobOptionsWithFileTypes,
2527
GlobOptionsWithoutFileTypes,
@@ -961,6 +963,26 @@ declare module "fs/promises" {
961963
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
962964
*/
963965
function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
966+
/**
967+
* The resulting Promise holds an async-disposable object whose `path` property
968+
* holds the created directory path. When the object is disposed, the directory
969+
* and its contents will be removed asynchronously if it still exists. If the
970+
* directory cannot be deleted, disposal will throw an error. The object has an
971+
* async `remove()` method which will perform the same task.
972+
*
973+
* Both this function and the disposal function on the resulting object are
974+
* async, so it should be used with `await` + `await using` as in
975+
* `await using dir = await fsPromises.mkdtempDisposable('prefix')`.
976+
*
977+
* <!-- TODO: link MDN docs for disposables once https://github.com/mdn/content/pull/38027 lands -->
978+
*
979+
* For detailed information, see the documentation of `fsPromises.mkdtemp()`.
980+
*
981+
* The optional `options` argument can be a string specifying an encoding, or an
982+
* object with an `encoding` property specifying the character encoding to use.
983+
* @since v24.4.0
984+
*/
985+
function mkdtempDisposable(prefix: PathLike, options?: EncodingOption): Promise<DisposableTempDir>;
964986
/**
965987
* Asynchronously writes data to a file, replacing the file if it already exists. `data` can be a string, a buffer, an
966988
* [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an

types/node/http.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,7 @@ declare module "http" {
20282028
*/
20292029
const maxHeaderSize: number;
20302030
/**
2031-
* A browser-compatible implementation of [WebSocket](https://nodejs.org/docs/latest/api/http.html#websocket).
2031+
* A browser-compatible implementation of `WebSocket`.
20322032
* @since v22.5.0
20332033
*/
20342034
const WebSocket: typeof import("undici-types").WebSocket;

types/node/module.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ declare module "module" {
359359
interface ImportAttributes extends NodeJS.Dict<string> {
360360
type?: string | undefined;
361361
}
362+
type ImportPhase = "source" | "evaluation";
362363
type ModuleFormat =
363364
| "addon"
364365
| "builtin"

types/node/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@types/node",
4-
"version": "24.3.9999",
4+
"version": "24.4.9999",
55
"nonNpm": "conflict",
66
"nonNpmDescription": "Node.js",
77
"projects": [
@@ -18,7 +18,7 @@
1818
}
1919
},
2020
"dependencies": {
21-
"undici-types": "~7.10.0"
21+
"undici-types": "~7.11.0"
2222
},
2323
"devDependencies": {
2424
"@types/node": "workspace:."

types/node/sqlite.d.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,33 @@ declare module "node:sqlite" {
9797
* @default 0
9898
*/
9999
timeout?: number | undefined;
100+
/**
101+
* If `true`, integer fields are read as JavaScript `BigInt` values. If `false`,
102+
* integer fields are read as JavaScript numbers.
103+
* @since v24.4.0
104+
* @default false
105+
*/
106+
readBigInts?: boolean | undefined;
107+
/**
108+
* If `true`, query results are returned as arrays instead of objects.
109+
* @since v24.4.0
110+
* @default false
111+
*/
112+
returnArrays?: boolean | undefined;
113+
/**
114+
* If `true`, allows binding named parameters without the prefix
115+
* character (e.g., `foo` instead of `:foo`).
116+
* @since v24.4.40
117+
* @default true
118+
*/
119+
allowBareNamedParameters?: boolean | undefined;
120+
/**
121+
* If `true`, unknown named parameters are ignored when binding.
122+
* If `false`, an exception is thrown for unknown named parameters.
123+
* @since v24.4.40
124+
* @default false
125+
*/
126+
allowUnknownNamedParameters?: boolean | undefined;
100127
}
101128
interface CreateSessionOptions {
102129
/**

types/node/test/crypto.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,8 +1100,16 @@ import { promisify } from "node:util";
11001100
}
11011101

11021102
{
1103+
// $ExpectType string
11031104
crypto.hash("sha1", "Node.js");
1105+
// $ExpectType Buffer || Buffer<ArrayBufferLike>
11041106
crypto.hash("sha1", Buffer.from("Tm9kZS5qcw==", "base64"), "buffer");
1107+
// $ExpectType string
1108+
crypto.hash("shake256", "Node.js", { outputLength: 256 });
1109+
// $ExpectType string
1110+
crypto.hash("shake256", Buffer.allocUnsafe(0), { outputEncoding: "base64" });
1111+
// $ExpectType Buffer || Buffer<ArrayBufferLike>
1112+
crypto.hash("shake256", "Node.js", { outputEncoding: "buffer", outputLength: 256 });
11051113
}
11061114

11071115
{

0 commit comments

Comments
 (0)