diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index ee0e647e71800f..3c33206965a4e5 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -2248,7 +2248,7 @@ declare namespace chrome { * * Permissions: "debugger" */ - export namespace _debugger { + namespace _debugger { /** Debuggee identifier. Either tabId, extensionId or targetId must be specified */ interface Debuggee { /** The id of the tab which you intend to debug. */ @@ -9223,11 +9223,6 @@ declare namespace chrome { | "webRequestBlocking" | "webRequestAuthProvider"; - /** - * @deprecated Use `ManifestPermission` instead. - */ - type ManifestPermissions = ManifestPermission; - /** Source : https://developer.chrome.com/docs/extensions/reference/api/permissions */ type ManifestOptionalPermission = Exclude< ManifestPermission, @@ -9245,11 +9240,6 @@ declare namespace chrome { | "webAuthenticationProxy" >; - /** - * @deprecated Use `ManifestOptionalPermission` instead. - */ - type ManifestOptionalPermissions = ManifestOptionalPermission; - interface SearchProvider { name?: string | undefined; keyword?: string | undefined; @@ -10118,12 +10108,7 @@ declare namespace chrome { * Permissions: "storage" */ export namespace storage { - /** NoInfer for old TypeScript versions (Required TS 5.4+) */ - type NoInferX = T[][T extends any ? 0 : never]; - // The next line prevents things without the export keyword from being automatically exported (like NoInferX) - export {}; - - export interface StorageArea { + interface StorageArea { /** * Gets the amount of space (in bytes) being used by one or more items. * @param keys A single key or list of keys to get the total usage for. An empty list will return 0. Pass in `null` to get the total usage of all of storage. @@ -10170,11 +10155,11 @@ declare namespace chrome { * Can return its result via Promise in Manifest V3 or later since Chrome 95. */ get( - keys?: NoInferX | Array> | Partial> | null, + keys?: NoInfer | Array> | Partial> | null | undefined, ): Promise; get(callback: (items: T) => void): void; get( - keys: NoInferX | Array> | Partial> | null | undefined, + keys: NoInfer | Array> | Partial> | null | undefined, callback: (items: T) => void, ): void; @@ -10201,19 +10186,19 @@ declare namespace chrome { getKeys(callback: (keys: string[]) => void): void; } - export interface StorageChange { + interface StorageChange { /** The new value of the item, if there is a new value. */ newValue?: unknown; /** The old value of the item, if there was an old value. */ oldValue?: unknown; } - export interface LocalStorageArea extends StorageArea { + interface LocalStorageArea extends StorageArea { /** The maximum amount (in bytes) of data that can be stored in local storage, as measured by the JSON stringification of every value plus every key's length. This value will be ignored if the extension has the unlimitedStorage permission. Updates that would cause this limit to be exceeded fail immediately and set runtime.lastError when using a callback, or a rejected Promise if using async/await. */ QUOTA_BYTES: 10485760; } - export interface SyncStorageArea extends StorageArea { + interface SyncStorageArea extends StorageArea { /** @deprecated The storage.sync API no longer has a sustained write operation quota. */ MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE: 1000000; /** The maximum total amount (in bytes) of data that can be stored in sync storage, as measured by the JSON stringification of every value plus every key's length. Updates that would cause this limit to be exceeded fail immediately and set runtime.lastError when using a callback, or when a Promise is rejected. */ @@ -10236,18 +10221,18 @@ declare namespace chrome { MAX_WRITE_OPERATIONS_PER_MINUTE: 120; } - export interface SessionStorageArea extends StorageArea { + interface SessionStorageArea extends StorageArea { /** The maximum amount (in bytes) of data that can be stored in memory, as measured by estimating the dynamically allocated memory usage of every value and key. Updates that would cause this limit to be exceeded fail immediately and set runtime.lastError when using a callback, or when a Promise is rejected. */ QUOTA_BYTES: 10485760; } - export type AreaName = "sync" | "local" | "managed" | "session"; + type AreaName = "sync" | "local" | "managed" | "session"; /** * The storage area's access level. * @since Chrome 102 */ - export enum AccessLevel { + enum AccessLevel { /** Specifies contexts originating from the extension itself. */ TRUSTED_CONTEXTS = "TRUSTED_CONTEXTS", /** Specifies contexts originating from outside the extension. */ @@ -10255,13 +10240,13 @@ declare namespace chrome { } /** Items in the `local` storage area are local to each machine. */ - export const local: LocalStorageArea; + const local: LocalStorageArea; /** Items in the `sync` storage area are synced using Chrome Sync. */ - export const sync: SyncStorageArea; + const sync: SyncStorageArea; /** Items in the `managed` storage area are set by an enterprise policy configured by the domain administrator, and are read-only for the extension; trying to modify this namespace results in an error. For information on configuring a policy, see Manifest for storage areas. */ - export const managed: StorageArea; + const managed: StorageArea; /** * Items in the `session` storage area are stored in-memory and will not be persisted to disk. @@ -10269,10 +10254,10 @@ declare namespace chrome { * MV3 only * @since Chrome 102 */ - export const session: SessionStorageArea; + const session: SessionStorageArea; /** Fired when one or more items change. */ - export const onChanged: events.Event<(changes: { [key: string]: StorageChange }, areaName: AreaName) => void>; + const onChanged: events.Event<(changes: { [key: string]: StorageChange }, areaName: AreaName) => void>; } //////////////////// @@ -10295,10 +10280,6 @@ declare namespace chrome { total: number; } - /** @deprecated Use {@link CpuTime} instead. */ - // eslint-disable-next-line @typescript-eslint/no-empty-interface - interface ProcessorUsage extends CpuTime {} - interface ProcessorInfo { /** Cumulative usage info for this logical processor. */ usage: CpuTime; @@ -12531,10 +12512,6 @@ declare namespace chrome { reconnect?: string | undefined; } - /** @deprecated Use {@link Parameters} instead */ - // eslint-disable-next-line @typescript-eslint/no-empty-interface - interface VpnSessionParameters extends Parameters {} - /** The enum is used by the platform to notify the client of the VPN session status. */ enum PlatformMessage { /** Indicates that the VPN configuration connected. */ @@ -13439,7 +13416,6 @@ declare namespace chrome { /** Fired before sending an HTTP request, once the request headers are available. This may occur after a TCP connection is made to the server, but before any HTTP data is sent. */ const onBeforeSendHeaders: WebRequestEvent< - // eslint-disable-next-line @typescript-eslint/no-invalid-void-type (details: OnBeforeSendHeadersDetails) => BlockingResponse | undefined, `${OnBeforeSendHeadersOptions}`[] >; diff --git a/types/chrome/package.json b/types/chrome/package.json index c043d0ad49af5e..91da517ec54d30 100644 --- a/types/chrome/package.json +++ b/types/chrome/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/chrome", - "version": "0.1.9999", + "version": "0.2.9999", "nonNpm": "conflict", "nonNpmDescription": "The complete reference to all APIs made available to Chrome Extensions", "projects": [ diff --git a/types/chrome/test/index.ts b/types/chrome/test/index.ts index a1eb5d42db9d30..547268f12ef49f 100644 --- a/types/chrome/test/index.ts +++ b/types/chrome/test/index.ts @@ -1301,6 +1301,9 @@ function testTabCapture() { // https://developer.chrome.com/docs/extensions/reference/api/debugger function testDebugger() { + // @ts-expect-error Property '_debugger' does not exist on type 'typeof chrome' + chrome._debugger; + chrome.debugger.DetachReason.CANCELED_BY_USER === "canceled_by_user"; chrome.debugger.DetachReason.TARGET_CLOSED === "target_closed"; @@ -1460,9 +1463,6 @@ function testStorage() { }; } - // @ts-expect-error - const testNoInferX: chrome.storage.NoInferX = "This test checks if NoInferX is accidentally exported"; - const StorageArea = ["sync", "managed", "local", "session"] as const; StorageArea.forEach((area) => { diff --git a/types/googlepay/index.d.ts b/types/googlepay/index.d.ts index 2ba7a91646ac90..3829e6840f3292 100644 --- a/types/googlepay/index.d.ts +++ b/types/googlepay/index.d.ts @@ -1116,9 +1116,7 @@ declare namespace google.payments.api { * transaction. * * You are required to show this message to the buyer as confirmation of - * their funding source. Please refer to the - * [documentation](https://developers.google.com/pay/api/|documentation) - * for more information. + * their funding source. * * **IMPORTANT:** Do not attempt to parse the contents of this string as * the format, contents, and length may change at any time. If you need diff --git a/types/node/v22/diagnostics_channel.d.ts b/types/node/v22/diagnostics_channel.d.ts index f3bac5277d457d..098f39c46587dc 100644 --- a/types/node/v22/diagnostics_channel.d.ts +++ b/types/node/v22/diagnostics_channel.d.ts @@ -189,7 +189,6 @@ declare module "diagnostics_channel" { * }); * ``` * @since v15.1.0, v14.17.0 - * @deprecated Since v18.7.0,v16.17.0 - Use {@link subscribe(name, onMessage)} * @param onMessage The handler to receive channel messages */ subscribe(onMessage: ChannelListener): void; @@ -210,7 +209,6 @@ declare module "diagnostics_channel" { * channel.unsubscribe(onMessage); * ``` * @since v15.1.0, v14.17.0 - * @deprecated Since v18.7.0,v16.17.0 - Use {@link unsubscribe(name, onMessage)} * @param onMessage The previous subscribed handler to remove * @return `true` if the handler was found, `false` otherwise. */ diff --git a/types/node/v22/fs.d.ts b/types/node/v22/fs.d.ts index d40515bfaf02bd..7eeeedc9b73ebf 100644 --- a/types/node/v22/fs.d.ts +++ b/types/node/v22/fs.d.ts @@ -4379,7 +4379,9 @@ declare module "fs" { /** * Function to filter out files/directories or a * list of glob patterns to be excluded. If a function is provided, return - * `true` to exclude the item, `false` to include it. + * `true` to exclude the item, `false` to include it. If a string array is + * provided, each string should be a glob pattern that specifies paths to exclude. + * Note: Negation patterns (e.g., '!foo.js') are not supported. * @default undefined */ exclude?: ((fileName: T) => boolean) | readonly string[] | undefined; diff --git a/types/node/v22/http.d.ts b/types/node/v22/http.d.ts index af7d21cd31d585..5907539093a64c 100644 --- a/types/node/v22/http.d.ts +++ b/types/node/v22/http.d.ts @@ -928,7 +928,7 @@ declare module "http" { * been transmitted are equal or not. * * Attempting to set a header field name or value that contains invalid characters - * will result in a `Error` being thrown. + * will result in a [`TypeError`](https://nodejs.org/docs/latest-v22.x/api/errors.html#class-typeerror) being thrown. * @since v0.1.30 */ writeHead( @@ -1472,6 +1472,14 @@ declare module "http" { * Only relevant if keepAlive is set to true. */ keepAliveMsecs?: number | undefined; + /** + * Milliseconds to subtract from the server-provided `keep-alive: timeout=...` hint when determining socket + * expiration time. This buffer helps ensure the agent closes the socket slightly before the server does, reducing + * the chance of sending a request on a socket that’s about to be closed by the server. + * @default 1000 + * @since v22.20.0 + */ + agentKeepAliveTimeoutBuffer?: number | undefined; /** * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity */ diff --git a/types/node/v22/http2.d.ts b/types/node/v22/http2.d.ts index 4937d8aa3a595b..92f111b1a75e5d 100644 --- a/types/node/v22/http2.d.ts +++ b/types/node/v22/http2.d.ts @@ -300,61 +300,111 @@ declare module "http2" { addListener(event: "continue", listener: () => {}): this; addListener( event: "headers", - listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + listener: ( + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + rawHeaders: string[], + ) => void, ): this; addListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this; addListener( event: "response", - listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + listener: ( + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + rawHeaders: string[], + ) => void, ): this; addListener(event: string | symbol, listener: (...args: any[]) => void): this; emit(event: "continue"): boolean; - emit(event: "headers", headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number): boolean; + emit( + event: "headers", + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + rawHeaders: string[], + ): boolean; emit(event: "push", headers: IncomingHttpHeaders, flags: number): boolean; - emit(event: "response", headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number): boolean; + emit( + event: "response", + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + rawHeaders: string[], + ): boolean; emit(event: string | symbol, ...args: any[]): boolean; on(event: "continue", listener: () => {}): this; on( event: "headers", - listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + listener: ( + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + rawHeaders: string[], + ) => void, ): this; on(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this; on( event: "response", - listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + listener: ( + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + rawHeaders: string[], + ) => void, ): this; on(event: string | symbol, listener: (...args: any[]) => void): this; once(event: "continue", listener: () => {}): this; once( event: "headers", - listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + listener: ( + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + rawHeaders: string[], + ) => void, ): this; once(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this; once( event: "response", - listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + listener: ( + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + rawHeaders: string[], + ) => void, ): this; once(event: string | symbol, listener: (...args: any[]) => void): this; prependListener(event: "continue", listener: () => {}): this; prependListener( event: "headers", - listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + listener: ( + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + rawHeaders: string[], + ) => void, ): this; prependListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this; prependListener( event: "response", - listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + listener: ( + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + rawHeaders: string[], + ) => void, ): this; prependListener(event: string | symbol, listener: (...args: any[]) => void): this; prependOnceListener(event: "continue", listener: () => {}): this; prependOnceListener( event: "headers", - listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + listener: ( + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + rawHeaders: string[], + ) => void, ): this; prependOnceListener(event: "push", listener: (headers: IncomingHttpHeaders, flags: number) => void): this; prependOnceListener( event: "response", - listener: (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => void, + listener: ( + headers: IncomingHttpHeaders & IncomingHttpStatusHeader, + flags: number, + rawHeaders: string[], + ) => void, ): this; prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; } @@ -440,7 +490,7 @@ declare module "http2" { * ``` * @since v8.4.0 */ - respond(headers?: OutgoingHttpHeaders, options?: ServerStreamResponseOptions): void; + respond(headers?: OutgoingHttpHeaders | readonly string[], options?: ServerStreamResponseOptions): void; /** * Initiates a response whose data is read from the given file descriptor. No * validation is performed on the given file descriptor. If an error occurs while @@ -1000,6 +1050,7 @@ declare module "http2" { stream: ClientHttp2Stream, headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number, + rawHeaders: string[], ) => void, ): this; addListener(event: string | symbol, listener: (...args: any[]) => void): this; @@ -1011,6 +1062,7 @@ declare module "http2" { stream: ClientHttp2Stream, headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number, + rawHeaders: string[], ): boolean; emit(event: string | symbol, ...args: any[]): boolean; on(event: "altsvc", listener: (alt: string, origin: string, stream: number) => void): this; @@ -1022,6 +1074,7 @@ declare module "http2" { stream: ClientHttp2Stream, headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number, + rawHeaders: string[], ) => void, ): this; on(event: string | symbol, listener: (...args: any[]) => void): this; @@ -1037,6 +1090,7 @@ declare module "http2" { stream: ClientHttp2Stream, headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number, + rawHeaders: string[], ) => void, ): this; once(event: string | symbol, listener: (...args: any[]) => void): this; @@ -1052,6 +1106,7 @@ declare module "http2" { stream: ClientHttp2Stream, headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number, + rawHeaders: string[], ) => void, ): this; prependListener(event: string | symbol, listener: (...args: any[]) => void): this; @@ -1067,6 +1122,7 @@ declare module "http2" { stream: ClientHttp2Stream, headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number, + rawHeaders: string[], ) => void, ): this; prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; @@ -1184,7 +1240,12 @@ declare module "http2" { ): this; addListener( event: "stream", - listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + listener: ( + stream: ServerHttp2Stream, + headers: IncomingHttpHeaders, + flags: number, + rawHeaders: string[], + ) => void, ): this; addListener(event: string | symbol, listener: (...args: any[]) => void): this; emit( @@ -1192,7 +1253,13 @@ declare module "http2" { session: ServerHttp2Session, socket: net.Socket | tls.TLSSocket, ): boolean; - emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean; + emit( + event: "stream", + stream: ServerHttp2Stream, + headers: IncomingHttpHeaders, + flags: number, + rawHeaders: string[], + ): boolean; emit(event: string | symbol, ...args: any[]): boolean; on( event: "connect", @@ -1203,7 +1270,12 @@ declare module "http2" { ): this; on( event: "stream", - listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + listener: ( + stream: ServerHttp2Stream, + headers: IncomingHttpHeaders, + flags: number, + rawHeaders: string[], + ) => void, ): this; on(event: string | symbol, listener: (...args: any[]) => void): this; once( @@ -1215,7 +1287,12 @@ declare module "http2" { ): this; once( event: "stream", - listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + listener: ( + stream: ServerHttp2Stream, + headers: IncomingHttpHeaders, + flags: number, + rawHeaders: string[], + ) => void, ): this; once(event: string | symbol, listener: (...args: any[]) => void): this; prependListener( @@ -1227,7 +1304,12 @@ declare module "http2" { ): this; prependListener( event: "stream", - listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + listener: ( + stream: ServerHttp2Stream, + headers: IncomingHttpHeaders, + flags: number, + rawHeaders: string[], + ) => void, ): this; prependListener(event: string | symbol, listener: (...args: any[]) => void): this; prependOnceListener( @@ -1239,7 +1321,12 @@ declare module "http2" { ): this; prependOnceListener( event: "stream", - listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + listener: ( + stream: ServerHttp2Stream, + headers: IncomingHttpHeaders, + flags: number, + rawHeaders: string[], + ) => void, ): this; prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; } @@ -1416,7 +1503,12 @@ declare module "http2" { ): this; addListener( event: "stream", - listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + listener: ( + stream: ServerHttp2Stream, + headers: IncomingHttpHeaders, + flags: number, + rawHeaders: string[], + ) => void, ): this; addListener(event: "timeout", listener: () => void): this; addListener(event: string | symbol, listener: (...args: any[]) => void): this; @@ -1435,7 +1527,13 @@ declare module "http2" { err: Error, session: ServerHttp2Session, ): boolean; - emit(event: "stream", stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number): boolean; + emit( + event: "stream", + stream: ServerHttp2Stream, + headers: IncomingHttpHeaders, + flags: number, + rawHeaders: string[], + ): boolean; emit(event: "timeout"): boolean; emit(event: string | symbol, ...args: any[]): boolean; on( @@ -1459,7 +1557,12 @@ declare module "http2" { ): this; on( event: "stream", - listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + listener: ( + stream: ServerHttp2Stream, + headers: IncomingHttpHeaders, + flags: number, + rawHeaders: string[], + ) => void, ): this; on(event: "timeout", listener: () => void): this; on(event: string | symbol, listener: (...args: any[]) => void): this; @@ -1484,7 +1587,12 @@ declare module "http2" { ): this; once( event: "stream", - listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + listener: ( + stream: ServerHttp2Stream, + headers: IncomingHttpHeaders, + flags: number, + rawHeaders: string[], + ) => void, ): this; once(event: "timeout", listener: () => void): this; once(event: string | symbol, listener: (...args: any[]) => void): this; @@ -1509,7 +1617,12 @@ declare module "http2" { ): this; prependListener( event: "stream", - listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + listener: ( + stream: ServerHttp2Stream, + headers: IncomingHttpHeaders, + flags: number, + rawHeaders: string[], + ) => void, ): this; prependListener(event: "timeout", listener: () => void): this; prependListener(event: string | symbol, listener: (...args: any[]) => void): this; @@ -1534,7 +1647,12 @@ declare module "http2" { ): this; prependOnceListener( event: "stream", - listener: (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => void, + listener: ( + stream: ServerHttp2Stream, + headers: IncomingHttpHeaders, + flags: number, + rawHeaders: string[], + ) => void, ): this; prependOnceListener(event: "timeout", listener: () => void): this; prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this; @@ -2289,8 +2407,8 @@ declare module "http2" { * will result in a `TypeError` being thrown. * @since v8.4.0 */ - writeHead(statusCode: number, headers?: OutgoingHttpHeaders): this; - writeHead(statusCode: number, statusMessage: string, headers?: OutgoingHttpHeaders): this; + writeHead(statusCode: number, headers?: OutgoingHttpHeaders | readonly string[]): this; + writeHead(statusCode: number, statusMessage: string, headers?: OutgoingHttpHeaders | readonly string[]): this; /** * Call `http2stream.pushStream()` with the given headers, and wrap the * given `Http2Stream` on a newly created `Http2ServerResponse` as the callback diff --git a/types/node/v22/index.d.ts b/types/node/v22/index.d.ts index c9edbd78860ac2..1993b43fbaa0b5 100644 --- a/types/node/v22/index.d.ts +++ b/types/node/v22/index.d.ts @@ -42,6 +42,7 @@ /// /// /// +/// /// /// /// diff --git a/types/node/v22/package.json b/types/node/v22/package.json index 2e47151239274f..ef968be1e1775a 100644 --- a/types/node/v22/package.json +++ b/types/node/v22/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/node", - "version": "22.19.9999", + "version": "22.20.9999", "nonNpm": "conflict", "nonNpmDescription": "Node.js", "projects": [ diff --git a/types/node/v22/sea.d.ts b/types/node/v22/sea.d.ts index 30130747622f34..3963a2da95d939 100644 --- a/types/node/v22/sea.d.ts +++ b/types/node/v22/sea.d.ts @@ -150,4 +150,13 @@ declare module "node:sea" { * @since v20.12.0 */ function getRawAsset(key: AssetKey): ArrayBuffer; + /** + * This method can be used to retrieve an array of all the keys of assets + * embedded into the single-executable application. + * An error is thrown when not running inside a single-executable application. + * @since v22.20.0 + * @returns An array containing all the keys of the assets + * embedded in the executable. If no assets are embedded, returns an empty array. + */ + function getAssetKeys(): string[]; } diff --git a/types/node/v22/sqlite.d.ts b/types/node/v22/sqlite.d.ts index 19d826d4199a17..2f3c218ef43691 100644 --- a/types/node/v22/sqlite.d.ts +++ b/types/node/v22/sqlite.d.ts @@ -637,8 +637,9 @@ declare module "node:sqlite" { */ rate?: number | undefined; /** - * Callback function that will be called with the number of pages copied and the total number of - * pages. + * An optional callback function that will be called after each backup step. The argument passed + * to this callback is an `Object` with `remainingPages` and `totalPages` properties, describing the current progress + * of the backup operation. */ progress?: ((progressInfo: BackupProgressInfo) => void) | undefined; } @@ -675,9 +676,9 @@ declare module "node:sqlite" { * the contents will be overwritten. * @param options Optional configuration for the backup. The * following properties are supported: - * @returns A promise that resolves when the backup is completed and rejects if an error occurs. + * @returns A promise that fulfills with the total number of backed-up pages upon completion, or rejects if an error occurs. */ - function backup(sourceDb: DatabaseSync, path: PathLike, options?: BackupOptions): Promise; + function backup(sourceDb: DatabaseSync, path: PathLike, options?: BackupOptions): Promise; /** * @since v22.13.0 */ diff --git a/types/node/v22/stream.d.ts b/types/node/v22/stream.d.ts index dec1bcc2171166..b4340eb1d15d6b 100644 --- a/types/node/v22/stream.d.ts +++ b/types/node/v22/stream.d.ts @@ -1676,8 +1676,15 @@ declare module "stream" { /** * Returns whether the stream is readable. * @since v17.4.0, v16.14.0 + * @returns Only returns `null` if `stream` is not a valid `Readable`, `Duplex` or `ReadableStream`. */ - function isReadable(stream: Readable | NodeJS.ReadableStream): boolean; + function isReadable(stream: Readable | NodeJS.ReadableStream): boolean | null; + /** + * Returns whether the stream is writable. + * @since v20.0.0 + * @returns Only returns `null` if `stream` is not a valid `Writable`, `Duplex` or `WritableStream`. + */ + function isWritable(stream: Writable | NodeJS.WritableStream): boolean | null; } export = Stream; } diff --git a/types/node/v22/stream/web.d.ts b/types/node/v22/stream/web.d.ts index c7432f8bbe120c..fbffa5593f2d0a 100644 --- a/types/node/v22/stream/web.d.ts +++ b/types/node/v22/stream/web.d.ts @@ -1,11 +1,7 @@ type _ByteLengthQueuingStrategy = typeof globalThis extends { onmessage: any } ? {} : import("stream/web").ByteLengthQueuingStrategy; -type _CompressionStream = typeof globalThis extends { onmessage: any; ReportingObserver: any } ? {} - : import("stream/web").CompressionStream; type _CountQueuingStrategy = typeof globalThis extends { onmessage: any } ? {} : import("stream/web").CountQueuingStrategy; -type _DecompressionStream = typeof globalThis extends { onmessage: any; ReportingObserver: any } ? {} - : import("stream/web").DecompressionStream; type _QueuingStrategy = typeof globalThis extends { onmessage: any } ? {} : import("stream/web").QueuingStrategy; type _ReadableByteStreamController = typeof globalThis extends { onmessage: any } ? {} @@ -412,22 +408,17 @@ declare module "stream/web" { prototype: TextDecoderStream; new(encoding?: string, options?: TextDecoderOptions): TextDecoderStream; }; - interface CompressionStream { + type CompressionFormat = "brotli" | "deflate" | "deflate-raw" | "gzip"; + class CompressionStream { + constructor(format: CompressionFormat); readonly readable: ReadableStream; readonly writable: WritableStream; } - const CompressionStream: { - prototype: CompressionStream; - new(format: "deflate" | "deflate-raw" | "gzip"): CompressionStream; - }; - interface DecompressionStream { + class DecompressionStream { + constructor(format: CompressionFormat); readonly writable: WritableStream; readonly readable: ReadableStream; } - const DecompressionStream: { - prototype: DecompressionStream; - new(format: "deflate" | "deflate-raw" | "gzip"): DecompressionStream; - }; global { interface ByteLengthQueuingStrategy extends _ByteLengthQueuingStrategy {} @@ -440,26 +431,6 @@ declare module "stream/web" { ? T : typeof import("stream/web").ByteLengthQueuingStrategy; - interface CompressionStream extends _CompressionStream {} - /** - * `CompressionStream` class is a global reference for `import { CompressionStream } from 'node:stream/web'`. - * https://nodejs.org/api/globals.html#class-compressionstream - * @since v18.0.0 - */ - var CompressionStream: typeof globalThis extends { - onmessage: any; - // CompressionStream, DecompressionStream and ReportingObserver was introduced in the same commit. - // If ReportingObserver check is removed, the type here will form a circular reference in TS5.0+lib.dom.d.ts - ReportingObserver: any; - CompressionStream: infer T; - } ? T - // TS 4.8, 4.9, 5.0 - : typeof globalThis extends { onmessage: any; TransformStream: { prototype: infer T } } ? { - prototype: T; - new(format: "deflate" | "deflate-raw" | "gzip"): T; - } - : typeof import("stream/web").CompressionStream; - interface CountQueuingStrategy extends _CountQueuingStrategy {} /** * `CountQueuingStrategy` class is a global reference for `import { CountQueuingStrategy } from 'node:stream/web'`. @@ -469,26 +440,6 @@ declare module "stream/web" { var CountQueuingStrategy: typeof globalThis extends { onmessage: any; CountQueuingStrategy: infer T } ? T : typeof import("stream/web").CountQueuingStrategy; - interface DecompressionStream extends _DecompressionStream {} - /** - * `DecompressionStream` class is a global reference for `import { DecompressionStream } from 'node:stream/web'`. - * https://nodejs.org/api/globals.html#class-decompressionstream - * @since v18.0.0 - */ - var DecompressionStream: typeof globalThis extends { - onmessage: any; - // CompressionStream, DecompressionStream and ReportingObserver was introduced in the same commit. - // If ReportingObserver check is removed, the type here will form a circular reference in TS5.0+lib.dom.d.ts - ReportingObserver: any; - DecompressionStream: infer T extends object; - } ? T - // TS 4.8, 4.9, 5.0 - : typeof globalThis extends { onmessage: any; TransformStream: { prototype: infer T } } ? { - prototype: T; - new(format: "deflate" | "deflate-raw" | "gzip"): T; - } - : typeof import("stream/web").DecompressionStream; - interface QueuingStrategy extends _QueuingStrategy {} interface ReadableByteStreamController extends _ReadableByteStreamController {} diff --git a/types/node/v22/test.d.ts b/types/node/v22/test.d.ts index 1e9613a84c7796..e9130ca0469935 100644 --- a/types/node/v22/test.d.ts +++ b/types/node/v22/test.d.ts @@ -242,8 +242,8 @@ declare module "node:test" { */ concurrency?: number | boolean | undefined; /** - * An array containing the list of files to run. If omitted, files are run according to the - * [test runner execution model](https://nodejs.org/docs/latest-v22.x/api/test.html#test-runner-execution-model). + * An array containing the list of files to run. + * **Default:** Same as [running tests from the command line](https://nodejs.org/docs/latest-v22.x/api/test.html#running-tests-from-the-command-line). */ files?: readonly string[] | undefined; /** @@ -255,8 +255,8 @@ declare module "node:test" { forceExit?: boolean | undefined; /** * An array containing the list of glob patterns to match test files. - * This option cannot be used together with `files`. If omitted, files are run according to the - * [test runner execution model](https://nodejs.org/docs/latest-v22.x/api/test.html#test-runner-execution-model). + * This option cannot be used together with `files`. + * **Default:** Same as [running tests from the command line](https://nodejs.org/docs/latest-v22.x/api/test.html#running-tests-from-the-command-line). * @since v22.6.0 */ globPatterns?: readonly string[] | undefined; @@ -1640,6 +1640,46 @@ declare module "node:test" { * @param options Optional configuration options for the mock module. */ module(specifier: string | URL, options?: MockModuleOptions): MockModuleContext; + /** + * Creates a mock for a property value on an object. This allows you to track and control access to a specific property, + * including how many times it is read (getter) or written (setter), and to restore the original value after mocking. + * + * ```js + * test('mocks a property value', (t) => { + * const obj = { foo: 42 }; + * const prop = t.mock.property(obj, 'foo', 100); + * + * assert.strictEqual(obj.foo, 100); + * assert.strictEqual(prop.mock.accessCount(), 1); + * assert.strictEqual(prop.mock.accesses[0].type, 'get'); + * assert.strictEqual(prop.mock.accesses[0].value, 100); + * + * obj.foo = 200; + * assert.strictEqual(prop.mock.accessCount(), 2); + * assert.strictEqual(prop.mock.accesses[1].type, 'set'); + * assert.strictEqual(prop.mock.accesses[1].value, 200); + * + * prop.mock.restore(); + * assert.strictEqual(obj.foo, 42); + * }); + * ``` + * @since v22.20.0 + * @param object The object whose value is being mocked. + * @param propertyName The identifier of the property on `object` to mock. + * @param value An optional value used as the mock value + * for `object[propertyName]`. **Default:** The original property value. + * @returns A proxy to the mocked object. The mocked object contains a + * special `mock` property, which is an instance of [`MockPropertyContext`](https://nodejs.org/docs/latest-v22.x/api/test.html#class-mockpropertycontext), + * and can be used for inspecting and changing the behavior of the mocked property. + */ + property< + MockedObject extends object, + PropertyName extends keyof MockedObject, + >( + object: MockedObject, + property: PropertyName, + value?: MockedObject[PropertyName], + ): MockedObject & { mock: MockPropertyContext }; /** * This function restores the default behavior of all mocks that were previously * created by this `MockTracker` and disassociates the mocks from the `MockTracker` instance. Once disassociated, the mocks can still be used, but the `MockTracker` instance can no longer be @@ -1809,6 +1849,68 @@ declare module "node:test" { */ restore(): void; } + /** + * @since v22.20.0 + */ + class MockPropertyContext { + /** + * A getter that returns a copy of the internal array used to track accesses (get/set) to + * the mocked property. Each entry in the array is an object with the following properties: + */ + readonly accesses: Array<{ + type: "get" | "set"; + value: PropertyType; + stack: Error; + }>; + /** + * This function returns the number of times that the property was accessed. + * This function is more efficient than checking `ctx.accesses.length` because + * `ctx.accesses` is a getter that creates a copy of the internal access tracking array. + * @returns The number of times that the property was accessed (read or written). + */ + accessCount(): number; + /** + * This function is used to change the value returned by the mocked property getter. + * @param value The new value to be set as the mocked property value. + */ + mockImplementation(value: PropertyType): void; + /** + * This function is used to change the behavior of an existing mock for a single + * invocation. Once invocation `onAccess` has occurred, the mock will revert to + * whatever behavior it would have used had `mockImplementationOnce()` not been + * called. + * + * The following example creates a mock function using `t.mock.property()`, calls the + * mock property, changes the mock implementation to a different value for the + * next invocation, and then resumes its previous behavior. + * + * ```js + * test('changes a mock behavior once', (t) => { + * const obj = { foo: 1 }; + * + * assert.strictEqual(obj.foo, 5); + * prop.mock.mockImplementationOnce(25); + * assert.strictEqual(obj.foo, 25); + * assert.strictEqual(obj.foo, 5); + * }); + * ``` + * @param value The value to be used as the mock's + * implementation for the invocation number specified by `onAccess`. + * @param onAccess The invocation number that will use `value`. If + * the specified invocation has already occurred then an exception is thrown. + * **Default:** The number of the next invocation. + */ + mockImplementationOnce(value: PropertyType, onAccess?: number): void; + /** + * Resets the access history of the mocked property. + */ + resetAccesses(): void; + /** + * Resets the implementation of the mock property to its original behavior. The + * mock can still be used after calling this function. + */ + restore(): void; + } interface MockTimersOptions { apis: ReadonlyArray<"setInterval" | "setTimeout" | "setImmediate" | "Date">; now?: number | Date | undefined; diff --git a/types/node/v22/test/http.ts b/types/node/v22/test/http.ts index cc8b1d25816110..9584ec8f49634e 100644 --- a/types/node/v22/test/http.ts +++ b/types/node/v22/test/http.ts @@ -351,6 +351,7 @@ import * as url from "node:url"; let agent: http.Agent = new http.Agent({ keepAlive: true, keepAliveMsecs: 10000, + agentKeepAliveTimeoutBuffer: 10000, maxSockets: Infinity, maxTotalSockets: Infinity, maxFreeSockets: 256, diff --git a/types/node/v22/test/http2.ts b/types/node/v22/test/http2.ts index e83c2a6df97e02..944938aeb8c944 100644 --- a/types/node/v22/test/http2.ts +++ b/types/node/v22/test/http2.ts @@ -73,7 +73,10 @@ import { URL } from "node:url"; http2Session.on("goaway", (errorCode: number, lastStreamID: number, opaqueData?: Buffer) => {}); http2Session.on("localSettings", (settings: Settings) => {}); http2Session.on("remoteSettings", (settings: Settings) => {}); - http2Session.on("stream", (stream: Http2Stream, headers: IncomingHttpHeaders, flags: number) => {}); + http2Session.on( + "stream", + (stream: Http2Stream, headers: IncomingHttpHeaders, flags: number, rawHeaders: string[]) => {}, + ); http2Session.on("timeout", () => {}); http2Session.on("ping", () => {}); @@ -189,9 +192,12 @@ import { URL } from "node:url"; const clientHttp2Stream: ClientHttp2Stream = {} as any; clientHttp2Stream.on("headers", (headers: IncomingHttpHeaders, flags: number) => {}); clientHttp2Stream.on("push", (headers: IncomingHttpHeaders, flags: number) => {}); - clientHttp2Stream.on("response", (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number) => { - const s: number = headers[":status"]!; - }); + clientHttp2Stream.on( + "response", + (headers: IncomingHttpHeaders & IncomingHttpStatusHeader, flags: number, rawHeaders: string[]) => { + const s: number = headers[":status"]!; + }, + ); // ServerHttp2Stream const serverHttp2Stream: ServerHttp2Stream = {} as any; @@ -212,6 +218,7 @@ import { URL } from "node:url"; serverHttp2Stream.respond(); serverHttp2Stream.respond(headers); serverHttp2Stream.respond(headers, options); + serverHttp2Stream.respond([":status", "400"]); const options2: ServerStreamFileResponseOptions = { statCheck: (stats: Stats, headers: OutgoingHttpHeaders, statOptions: StatOptions) => {}, @@ -246,7 +253,10 @@ import { URL } from "node:url"; server.on("sessionError", (err: Error, session: ServerHttp2Session) => {}); server.on("session", (session: ServerHttp2Session) => {}); server.on("checkContinue", (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => {}); - server.on("stream", (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number) => {}); + server.on( + "stream", + (stream: ServerHttp2Stream, headers: IncomingHttpHeaders, flags: number, rawHeaders: string[]) => {}, + ); server.on("request", (request: Http2ServerRequest, response: Http2ServerResponse) => {}); server.on("timeout", () => {}); server.setTimeout().setTimeout(5).setTimeout(5, () => {}); @@ -347,6 +357,7 @@ import { URL } from "node:url"; response.writeHead(200, outgoingHeaders); response.writeHead(200, "OK", outgoingHeaders); response.writeHead(200, "OK"); + response.writeHead(200, "OK", ["Content-Type", "application/json"]); response.write(""); response.write("", (err: Error) => {}); response.write("", "utf8"); diff --git a/types/node/v22/test/sea.ts b/types/node/v22/test/sea.ts index a73e559e8f2703..9feae9a6e0bc8d 100644 --- a/types/node/v22/test/sea.ts +++ b/types/node/v22/test/sea.ts @@ -1,4 +1,4 @@ -import { getAsset, getAssetAsBlob, getRawAsset, isSea } from "node:sea"; +import { getAsset, getAssetAsBlob, getAssetKeys, getRawAsset, isSea } from "node:sea"; { // $ExpectType boolean @@ -14,4 +14,7 @@ import { getAsset, getAssetAsBlob, getRawAsset, isSea } from "node:sea"; // $ExpectType ArrayBuffer getRawAsset("d.webm"); + + // $ExpectType string[] + getAssetKeys(); } diff --git a/types/node/v22/test/sqlite.ts b/types/node/v22/test/sqlite.ts index 907a714ff8c8b8..c48ea56eb54ada 100644 --- a/types/node/v22/test/sqlite.ts +++ b/types/node/v22/test/sqlite.ts @@ -130,7 +130,7 @@ import { TextEncoder } from "node:util"; { const db = new DatabaseSync(":memory:"); - // $ExpectType Promise + // $ExpectType Promise backup( db, "/var/lib/sqlite/backup", diff --git a/types/node/v22/test/stream.ts b/types/node/v22/test/stream.ts index fb7916597def0a..a8692a7a80cd10 100644 --- a/types/node/v22/test/stream.ts +++ b/types/node/v22/test/stream.ts @@ -6,6 +6,7 @@ import { finished, isErrored, isReadable, + isWritable, pipeline, Readable, Transform, @@ -571,8 +572,13 @@ addAbortSignal(new AbortSignal(), new Readable()); } { - isReadable(new Readable()); // $ExpectType boolean - isReadable(new Duplex()); // $ExpectType boolean + isReadable(new Readable()); // $ExpectType boolean | null + isReadable(new Duplex()); // $ExpectType boolean | null +} + +{ + isWritable(new Writable()); // $ExpectType boolean | null + isWritable(new Duplex()); // $ExpectType boolean | null } { diff --git a/types/node/v22/test/test.ts b/types/node/v22/test/test.ts index 5dcfae3157a9e9..fb5afdb4d5fa60 100644 --- a/types/node/v22/test/test.ts +++ b/types/node/v22/test/test.ts @@ -821,6 +821,26 @@ test("mocks a module", (t) => { }); }); +test("mocks a property", (t) => { + const object = { foo: "bar" }; + const mockedObject = t.mock.property(object, "foo"); + // $ExpectType string + mockedObject.foo; + + mockedObject.mock.mockImplementation("baz"); + mockedObject.mock.mockImplementationOnce("bash", 5); + + // $ExpectType number + mockedObject.mock.accessCount(); + + const access = mockedObject.mock.accesses[0]; + // $ExpectType string + access.value; + + mockedObject.mock.resetAccesses(); + mockedObject.mock.restore(); +}); + // @ts-expect-error dot(); // $ExpectType AsyncGenerator<"\n" | "." | "X", void, unknown> || AsyncGenerator<"\n" | "." | "X", void, any> diff --git a/types/node/v22/test/worker_threads.ts b/types/node/v22/test/worker_threads.ts index 1abc5f1fb3c51e..dbad68bc1a7177 100644 --- a/types/node/v22/test/worker_threads.ts +++ b/types/node/v22/test/worker_threads.ts @@ -76,6 +76,9 @@ import { createContext } from "node:vm"; w.getHeapStatistics().then(statistics => { statistics; // $ExpectType HeapInfo }); + w.startCpuProfile("demo").then(handle => { + handle.stop().then(JSON.parse); + }); w.terminate().then(() => { // woot }); diff --git a/types/node/v22/tls.d.ts b/types/node/v22/tls.d.ts index 51770320bb5ee6..5ae701ce21a437 100644 --- a/types/node/v22/tls.d.ts +++ b/types/node/v22/tls.d.ts @@ -1301,7 +1301,7 @@ declare module "tls" { * It can be assigned any of the supported OpenSSL ciphers. * Defaults to the content of `crypto.constants.defaultCoreCipherList`, unless * changed using CLI options using `--tls-default-ciphers`. - * @since v19.8.0 + * @since v0.11.3 */ let DEFAULT_CIPHERS: string; /** diff --git a/types/node/v22/ts5.6/index.d.ts b/types/node/v22/ts5.6/index.d.ts index 5a5af42a26b768..c452ddb485d846 100644 --- a/types/node/v22/ts5.6/index.d.ts +++ b/types/node/v22/ts5.6/index.d.ts @@ -42,6 +42,7 @@ /// /// /// +/// /// /// /// diff --git a/types/node/v22/vm.d.ts b/types/node/v22/vm.d.ts index a2609bf2ba2723..d9fe98da4c1c5c 100644 --- a/types/node/v22/vm.d.ts +++ b/types/node/v22/vm.d.ts @@ -762,14 +762,6 @@ declare module "vm" { * @experimental */ class Module { - /** - * The specifiers of all dependencies of this module. The returned array is frozen - * to disallow any changes to it. - * - * Corresponds to the `[[RequestedModules]]` field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s in - * the ECMAScript specification. - */ - dependencySpecifiers: readonly string[]; /** * If the `module.status` is `'errored'`, this property contains the exception * thrown by the module during evaluation. If the status is anything else, @@ -864,6 +856,21 @@ declare module "vm" { */ link(linker: ModuleLinker): Promise; } + /** + * A `ModuleRequest` represents the request to import a module with given import attributes and phase. + * @since v22.20.0 + */ + interface ModuleRequest { + /** + * The specifier of the requested module. + */ + specifier: string; + /** + * The `"with"` value passed to the `WithClause` in a `ImportDeclaration`, or an empty object if no value was + * provided. + */ + attributes: ImportAttributes; + } interface SourceTextModuleOptions extends Pick { /** * String used in stack traces. @@ -897,6 +904,52 @@ declare module "vm" { * @param code JavaScript Module code to parse */ constructor(code: string, options?: SourceTextModuleOptions); + /** + * The specifiers of all dependencies of this module. The returned array is frozen to disallow any changes to it. + * + * Corresponds to the [[RequestedModules]] field of [Cyclic Module Records](https://tc39.es/ecma262/#sec-cyclic-module-records) + * in the ECMAScript specification. + * @deprecated Use {@link moduleRequests} instead. + */ + readonly dependencySpecifiers: readonly string[]; + /** + * The requested import dependencies of this module. The returned array is frozen + * to disallow any changes to it. + * + * For example, given a source text: + * + * ```js + * import foo from 'foo'; + * import fooAlias from 'foo'; + * import bar from './bar.js'; + * import withAttrs from '../with-attrs.ts' with { arbitraryAttr: 'attr-val' }; + * ``` + * + * The value of the `sourceTextModule.moduleRequests` will be: + * + * ```js + * [ + * { + * specifier: 'foo', + * attributes: {}, + * }, + * { + * specifier: 'foo', + * attributes: {}, + * }, + * { + * specifier: './bar.js', + * attributes: {}, + * }, + * { + * specifier: '../with-attrs.ts', + * attributes: { arbitraryAttr: 'attr-val' }, + * }, + * ]; + * ``` + * @since v22.20.0 + */ + readonly moduleRequests: readonly ModuleRequest[]; } interface SyntheticModuleOptions { /** diff --git a/types/node/v22/web-globals/streams.d.ts b/types/node/v22/web-globals/streams.d.ts new file mode 100644 index 00000000000000..a70dde5604d91c --- /dev/null +++ b/types/node/v22/web-globals/streams.d.ts @@ -0,0 +1,22 @@ +export {}; + +import * as webstreams from "stream/web"; + +type _CompressionStream = typeof globalThis extends { onmessage: any } ? {} : webstreams.CompressionStream; +type _DecompressionStream = typeof globalThis extends { onmessage: any } ? {} : webstreams.DecompressionStream; + +declare global { + interface CompressionStream extends _CompressionStream {} + var CompressionStream: typeof globalThis extends { + onmessage: any; + CompressionStream: infer T; + } ? T + : typeof webstreams.CompressionStream; + + interface DecompressionStream extends _DecompressionStream {} + var DecompressionStream: typeof globalThis extends { + onmessage: any; + DecompressionStream: infer T; + } ? T + : typeof webstreams.DecompressionStream; +} diff --git a/types/node/v22/worker_threads.d.ts b/types/node/v22/worker_threads.d.ts index c4bbacf6e73bad..d80eb9fe5c8a1c 100644 --- a/types/node/v22/worker_threads.d.ts +++ b/types/node/v22/worker_threads.d.ts @@ -70,6 +70,7 @@ declare module "worker_threads" { const resourceLimits: ResourceLimits; const SHARE_ENV: unique symbol; const threadId: number; + const threadName: string | null; const workerData: any; /** * Instances of the `worker.MessageChannel` class represent an asynchronous, @@ -300,6 +301,10 @@ declare module "worker_threads" { */ stackSizeMb?: number | undefined; } + interface CPUProfileHandle { + stop(): Promise; + [Symbol.asyncDispose](): Promise; + } /** * The `Worker` class represents an independent JavaScript execution thread. * Most Node.js APIs are available inside of it. @@ -391,6 +396,12 @@ declare module "worker_threads" { * @since v10.5.0 */ readonly threadId: number; + /** + * A string identifier for the referenced thread or null if the thread is not running. + * Inside the worker thread, it is available as {@link threadName | `require('node:worker_threads').threadName`}. + * @since v22.20.0 + */ + readonly threadName: string | null; /** * Provides the set of JS engine resource constraints for this Worker thread. * If the `resourceLimits` option was passed to the `Worker` constructor, @@ -461,6 +472,30 @@ declare module "worker_threads" { * @since v22.16.0 */ getHeapStatistics(): Promise; + /** + * Starting a CPU profile with the given `name`, then return a Promise that fulfills + * with an error or an object which has a `stop` method. Calling the `stop` method will + * stop collecting the profile, then return a Promise that fulfills with an error or the + * profile data. + * + * ```js + * const { Worker } = require('node:worker_threads'); + * + * const worker = new Worker(` + * const { parentPort } = require('worker_threads'); + * parentPort.on('message', () => {}); + * `, { eval: true }); + * + * worker.on('online', async () => { + * const handle = await worker.startCpuProfile('demo'); + * const profile = await handle.stop(); + * console.log(profile); + * worker.terminate(); + * }); + * ``` + * @since v22.20.0 + */ + startCpuProfile(name: string): Promise; /** * Calls `worker.terminate()` when the dispose scope is exited. * diff --git a/types/numeric/index.d.ts b/types/numeric/index.d.ts index fe12ae43b734a3..9c12d6fe1bfb60 100644 --- a/types/numeric/index.d.ts +++ b/types/numeric/index.d.ts @@ -1118,22 +1118,22 @@ interface Numeric { ): Spline; // Unconstrained optimisations - uncmin( - f: (x: Vector) => Scalar, - x0: Vector, + uncmin( + f: (x: T) => Scalar, + x0: T, tol?: number, gradient?: any, maxit?: number, callback?: ( it: number, - x0: Vector, + x0: T, f0: Scalar, - g0: Vector, + g0: T, h1: Matrix, ) => any, options?: { Hinv: Matrix }, ): { - solution: Vector; + solution: T; f: Scalar; gradient: Vector; invHessian: Matrix; diff --git a/types/numeric/numeric-tests.ts b/types/numeric/numeric-tests.ts index eb398b5728a284..1a934b1acf67d5 100644 --- a/types/numeric/numeric-tests.ts +++ b/types/numeric/numeric-tests.ts @@ -609,6 +609,8 @@ spline.at(vector); // $ExpectType number | number[] || number | Vector numeric.uncmin((x: number[]) => 23, vector, 2, null, 3, () => undefined, { Hinv: matrix, }); +numeric.uncmin(([x, y]) => (x ** 2 + y ** 2), [1, 1]); +numeric.uncmin(([x, y]) => (x ** 2 + y ** 2), vector); numeric.gradient((x: number[]) => 44, vector); // $ExpectType number[] || Vector const dopri = numeric.dopri( diff --git a/types/numeric/tsconfig.json b/types/numeric/tsconfig.json index d98d61cb4aa0ec..d4315c83f2fa1b 100644 --- a/types/numeric/tsconfig.json +++ b/types/numeric/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "module": "node16", "lib": [ - "es5" + "es6" ], "noImplicitAny": true, "noImplicitThis": true,