Skip to content

Commit fbfb2a9

Browse files
authored
🤖 Merge PR DefinitelyTyped#73325 [node] v22.17 by @Renegade334
1 parent 25aff94 commit fbfb2a9

File tree

18 files changed

+318
-86
lines changed

18 files changed

+318
-86
lines changed

types/node/v22/buffer.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ declare module "buffer" {
118118
* Resolves a `'blob:nodedata:...'` an associated `Blob` object registered using
119119
* a prior call to `URL.createObjectURL()`.
120120
* @since v16.7.0
121-
* @experimental
122121
* @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`.
123122
*/
124123
export function resolveObjectURL(id: string): Blob | undefined;

types/node/v22/crypto.d.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3764,7 +3764,23 @@ declare module "crypto" {
37643764
*/
37653765
checkIP(ip: string): string | undefined;
37663766
/**
3767-
* Checks whether this certificate was issued by the given `otherCert`.
3767+
* Checks whether this certificate was potentially issued by the given `otherCert`
3768+
* by comparing the certificate metadata.
3769+
*
3770+
* This is useful for pruning a list of possible issuer certificates which have been
3771+
* selected using a more rudimentary filtering routine, i.e. just based on subject
3772+
* and issuer names.
3773+
*
3774+
* Finally, to verify that this certificate's signature was produced by a private key
3775+
* corresponding to `otherCert`'s public key use `x509.verify(publicKey)`
3776+
* with `otherCert`'s public key represented as a `KeyObject`
3777+
* like so
3778+
*
3779+
* ```js
3780+
* if (!x509.verify(otherCert.publicKey)) {
3781+
* throw new Error('otherCert did not issue x509');
3782+
* }
3783+
* ```
37683784
* @since v15.6.0
37693785
*/
37703786
checkIssued(otherCert: X509Certificate): boolean;

types/node/v22/fs.d.ts

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ declare module "fs" {
243243
*/
244244
name: Name;
245245
/**
246-
* The base path that this `fs.Dirent` object refers to.
247-
* @since v20.12.0
246+
* The path to the parent directory of the file this `fs.Dirent` object refers to.
247+
* @since v20.12.0, v18.20.0
248248
*/
249249
parentPath: string;
250250
/**
@@ -328,6 +328,19 @@ declare module "fs" {
328328
* @since v12.12.0
329329
*/
330330
readSync(): Dirent | null;
331+
/**
332+
* Calls `dir.close()` and returns a promise that fulfills when the
333+
* dir is closed.
334+
* @since v22.17.0
335+
* @experimental
336+
*/
337+
[Symbol.asyncDispose](): Promise<void>;
338+
/**
339+
* Calls `dir.closeSync()` and returns `undefined`.
340+
* @since v22.17.0
341+
* @experimental
342+
*/
343+
[Symbol.dispose](): void;
331344
}
332345
/**
333346
* Class: fs.StatWatcher
@@ -4200,7 +4213,6 @@ declare module "fs" {
42004213
* blob.stream();
42014214
* ```
42024215
* @since v19.8.0
4203-
* @experimental
42044216
*/
42054217
export function openAsBlob(path: PathLike, options?: OpenAsBlobOptions): Promise<Blob>;
42064218

@@ -4361,7 +4373,7 @@ declare module "fs" {
43614373
* Current working directory.
43624374
* @default process.cwd()
43634375
*/
4364-
cwd?: string | undefined;
4376+
cwd?: string | URL | undefined;
43654377
/**
43664378
* `true` if the glob should return paths as `Dirent`s, `false` otherwise.
43674379
* @default false
@@ -4386,49 +4398,65 @@ declare module "fs" {
43864398

43874399
/**
43884400
* Retrieves the files matching the specified pattern.
4401+
*
4402+
* ```js
4403+
* import { glob } from 'node:fs';
4404+
*
4405+
* glob('*.js', (err, matches) => {
4406+
* if (err) throw err;
4407+
* console.log(matches);
4408+
* });
4409+
* ```
4410+
* @since v22.0.0
43894411
*/
43904412
export function glob(
4391-
pattern: string | string[],
4413+
pattern: string | readonly string[],
43924414
callback: (err: NodeJS.ErrnoException | null, matches: string[]) => void,
43934415
): void;
43944416
export function glob(
4395-
pattern: string | string[],
4417+
pattern: string | readonly string[],
43964418
options: GlobOptionsWithFileTypes,
43974419
callback: (
43984420
err: NodeJS.ErrnoException | null,
43994421
matches: Dirent[],
44004422
) => void,
44014423
): void;
44024424
export function glob(
4403-
pattern: string | string[],
4425+
pattern: string | readonly string[],
44044426
options: GlobOptionsWithoutFileTypes,
44054427
callback: (
44064428
err: NodeJS.ErrnoException | null,
44074429
matches: string[],
44084430
) => void,
44094431
): void;
44104432
export function glob(
4411-
pattern: string | string[],
4433+
pattern: string | readonly string[],
44124434
options: GlobOptions,
44134435
callback: (
44144436
err: NodeJS.ErrnoException | null,
44154437
matches: Dirent[] | string[],
44164438
) => void,
44174439
): void;
44184440
/**
4419-
* Retrieves the files matching the specified pattern.
4441+
* ```js
4442+
* import { globSync } from 'node:fs';
4443+
*
4444+
* console.log(globSync('*.js'));
4445+
* ```
4446+
* @since v22.0.0
4447+
* @returns paths of files that match the pattern.
44204448
*/
4421-
export function globSync(pattern: string | string[]): string[];
4449+
export function globSync(pattern: string | readonly string[]): string[];
44224450
export function globSync(
4423-
pattern: string | string[],
4451+
pattern: string | readonly string[],
44244452
options: GlobOptionsWithFileTypes,
44254453
): Dirent[];
44264454
export function globSync(
4427-
pattern: string | string[],
4455+
pattern: string | readonly string[],
44284456
options: GlobOptionsWithoutFileTypes,
44294457
): string[];
44304458
export function globSync(
4431-
pattern: string | string[],
4459+
pattern: string | readonly string[],
44324460
options: GlobOptions,
44334461
): Dirent[] | string[];
44344462
}

types/node/v22/fs/promises.d.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ declare module "fs/promises" {
8888
highWaterMark?: number | undefined;
8989
flush?: boolean | undefined;
9090
}
91+
interface ReadableWebStreamOptions {
92+
autoClose?: boolean | undefined;
93+
}
9194
// TODO: Add `EventEmitter` close
9295
interface FileHandle {
9396
/**
@@ -260,9 +263,8 @@ declare module "fs/promises" {
260263
* While the `ReadableStream` will read the file to completion, it will not
261264
* close the `FileHandle` automatically. User code must still call the`fileHandle.close()` method.
262265
* @since v17.0.0
263-
* @experimental
264266
*/
265-
readableWebStream(): ReadableStream;
267+
readableWebStream(options?: ReadableWebStreamOptions): ReadableStream;
266268
/**
267269
* Asynchronously reads the entire contents of a file.
268270
*
@@ -475,7 +477,8 @@ declare module "fs/promises" {
475477
*/
476478
close(): Promise<void>;
477479
/**
478-
* An alias for {@link FileHandle.close()}.
480+
* Calls `filehandle.close()` and returns a promise that fulfills when the
481+
* filehandle is closed.
479482
* @since v20.4.0
480483
*/
481484
[Symbol.asyncDispose](): Promise<void>;
@@ -1252,20 +1255,28 @@ declare module "fs/promises" {
12521255
*/
12531256
function cp(source: string | URL, destination: string | URL, opts?: CopyOptions): Promise<void>;
12541257
/**
1255-
* Retrieves the files matching the specified pattern.
1258+
* ```js
1259+
* import { glob } from 'node:fs/promises';
1260+
*
1261+
* for await (const entry of glob('*.js'))
1262+
* console.log(entry);
1263+
* ```
1264+
* @since v22.0.0
1265+
* @returns An AsyncIterator that yields the paths of files
1266+
* that match the pattern.
12561267
*/
1257-
function glob(pattern: string | string[]): NodeJS.AsyncIterator<string>;
1268+
function glob(pattern: string | readonly string[]): NodeJS.AsyncIterator<string>;
12581269
function glob(
1259-
pattern: string | string[],
1260-
opt: GlobOptionsWithFileTypes,
1270+
pattern: string | readonly string[],
1271+
options: GlobOptionsWithFileTypes,
12611272
): NodeJS.AsyncIterator<Dirent>;
12621273
function glob(
1263-
pattern: string | string[],
1264-
opt: GlobOptionsWithoutFileTypes,
1274+
pattern: string | readonly string[],
1275+
options: GlobOptionsWithoutFileTypes,
12651276
): NodeJS.AsyncIterator<string>;
12661277
function glob(
1267-
pattern: string | string[],
1268-
opt: GlobOptions,
1278+
pattern: string | readonly string[],
1279+
options: GlobOptions,
12691280
): NodeJS.AsyncIterator<Dirent | string>;
12701281
}
12711282
declare module "node:fs/promises" {

types/node/v22/http2.d.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,10 @@ declare module "http2" {
965965
* * `:path` \= `/`
966966
* @since v8.4.0
967967
*/
968-
request(headers?: OutgoingHttpHeaders, options?: ClientSessionRequestOptions): ClientHttp2Stream;
968+
request(
969+
headers?: OutgoingHttpHeaders | readonly string[],
970+
options?: ClientSessionRequestOptions,
971+
): ClientHttp2Stream;
969972
addListener(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this;
970973
addListener(event: "origin", listener: (origins: string[]) => void): this;
971974
addListener(
@@ -1291,6 +1294,14 @@ declare module "http2" {
12911294
* @default 100000
12921295
*/
12931296
unknownProtocolTimeout?: number | undefined;
1297+
/**
1298+
* If `true`, it turns on strict leading
1299+
* and trailing whitespace validation for HTTP/2 header field names and values
1300+
* as per [RFC-9113](https://www.rfc-editor.org/rfc/rfc9113.html#section-8.2.1).
1301+
* @since v24.2.0
1302+
* @default true
1303+
*/
1304+
strictFieldWhitespaceValidation?: boolean | undefined;
12941305
}
12951306
export interface ClientSessionOptions extends SessionOptions {
12961307
/**

0 commit comments

Comments
 (0)