Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
381 changes: 356 additions & 25 deletions types/node/crypto.d.ts

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions types/node/diagnostics_channel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
*/
Expand Down
170 changes: 144 additions & 26 deletions types/node/http2.d.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion types/node/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/node",
"version": "24.7.9999",
"version": "24.8.9999",
"nonNpm": "conflict",
"nonNpmDescription": "Node.js",
"projects": [
Expand Down
9 changes: 9 additions & 0 deletions types/node/sea.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 v24.8.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[];
}
10 changes: 9 additions & 1 deletion types/node/stream.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1656,6 +1656,7 @@ declare module "stream" {
ref(): void;
unref(): void;
}
// TODO: these should all take webstream arguments
/**
* Returns whether the stream has encountered an error.
* @since v17.3.0, v16.14.0
Expand All @@ -1664,8 +1665,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;
}
Expand Down
47 changes: 47 additions & 0 deletions types/node/test/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,22 @@ import { promisify } from "node:util";
type: "pkcs8",
},
});

const slhdsaRes: {
publicKey: Buffer;
privateKey: string;
} = crypto.generateKeyPairSync("slh-dsa-sha2-128s", {
publicKeyEncoding: {
format: "der",
type: "spki",
},
privateKeyEncoding: {
cipher: "some-cipher",
format: "pem",
passphrase: "secret",
type: "pkcs8",
},
});
}

{
Expand Down Expand Up @@ -941,6 +957,21 @@ import { promisify } from "node:util";
},
(err: NodeJS.ErrnoException | null, publicKey: string, privateKey: string) => {},
);

crypto.generateKeyPair(
"slh-dsa-sha2-128s",
{
publicKeyEncoding: {
format: "pem",
type: "spki",
},
privateKeyEncoding: {
format: "pem",
type: "pkcs8",
},
},
(err: NodeJS.ErrnoException | null, publicKey: string, privateKey: string) => {},
);
}

{
Expand Down Expand Up @@ -1070,6 +1101,20 @@ import { promisify } from "node:util";
type: "pkcs8",
},
});

const slhdsaRes: Promise<{
publicKey: string;
privateKey: string;
}> = generateKeyPairPromisified("slh-dsa-sha2-128s", {
publicKeyEncoding: {
format: "pem",
type: "spki",
},
privateKeyEncoding: {
format: "pem",
type: "pkcs8",
},
});
}

{
Expand Down Expand Up @@ -1348,6 +1393,8 @@ import { promisify } from "node:util";
key: jwk,
dsaEncoding: "der",
});

crypto.sign("slh-dsa-sha2-128s", Buffer.from("asd"), { key, context: Uint8Array.of(1, 2, 3, 4).buffer });
}

{
Expand Down
20 changes: 15 additions & 5 deletions types/node/test/http2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,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", () => {});

Expand Down Expand Up @@ -179,9 +182,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;
Expand Down Expand Up @@ -237,7 +243,10 @@ import { URL } from "node:url";
server.on("sessionError", (err: Error) => {});
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, () => {});
Expand Down Expand Up @@ -336,6 +345,7 @@ import { URL } from "node:url";
response.writeHead(200, outgoingHeaders);
response.writeHead(200, "OK", outgoingHeaders);
response.writeHead(200, "OK");
response.writeHead(200, ["x-dts-library", "@types/node"]);
response.write("");
response.write("", (err: Error) => {});
response.write("", "utf8");
Expand Down
5 changes: 4 additions & 1 deletion types/node/test/sea.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getAsset, getAssetAsBlob, getRawAsset, isSea } from "node:sea";
import { getAsset, getAssetAsBlob, getAssetKeys, getRawAsset, isSea } from "node:sea";

{
// $ExpectType boolean
Expand All @@ -14,4 +14,7 @@ import { getAsset, getAssetAsBlob, getRawAsset, isSea } from "node:sea";

// $ExpectType ArrayBuffer
getRawAsset("d.webm");

// $ExpectType string[]
getAssetKeys();
}
7 changes: 5 additions & 2 deletions types/node/test/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
finished,
isErrored,
isReadable,
isWritable,
pipeline,
Readable,
Transform,
Expand Down Expand Up @@ -571,8 +572,10 @@ 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
}

{
Expand Down
58 changes: 54 additions & 4 deletions types/node/test/vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ import {
if (specifier === "foo") {
return new SourceTextModule(
`
// The "secret" variable refers to the global variable we added to
// "contextifiedObject" when creating the context.
export default secret;
`,
// The "secret" variable refers to the global variable we added to
// "contextifiedObject" when creating the context.
export default secret;
`,
{ context: referencingModule.context },
);
}
Expand All @@ -169,6 +169,56 @@ import {
}
});

(async () => {
const contextifiedObject = createContext({
secret: 42,
print: console.log,
});

const rootModule = new SourceTextModule(
`
import s from 'foo';
s;
print(s);
`,
{ context: contextifiedObject },
);

const moduleMap = new Map([
["root", rootModule],
]);

function resolveAndLinkDependencies(module: SourceTextModule) {
const requestedModules = module.moduleRequests.map((request) => {
const specifier = request.specifier;

let requestedModule = moduleMap.get(specifier);
if (requestedModule === undefined) {
requestedModule = new SourceTextModule(
`
// The "secret" variable refers to the global variable we added to
// "contextifiedObject" when creating the context.
export default secret;
`,
{ context: rootModule.context },
);
moduleMap.set(specifier, requestedModule);

resolveAndLinkDependencies(requestedModule);
}

return requestedModule;
});

module.linkRequests(requestedModules);
}

resolveAndLinkDependencies(rootModule);
rootModule.instantiate();

await rootModule.evaluate();
});

(async () => {
const source = "{ \"a\": 1 }";
const module = new SyntheticModule(["default"], function() {
Expand Down
3 changes: 3 additions & 0 deletions types/node/test/worker_threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ import { createContext } from "node:vm";
w.getHeapStatistics().then(statistics => {
statistics; // $ExpectType HeapInfo
});
w.startCpuProfile().then(handle => {
handle.stop().then(JSON.parse);
});
w.terminate().then(() => {
// woot
});
Expand Down
16 changes: 16 additions & 0 deletions types/node/v8.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,22 @@ declare module "v8" {
* @since v12.8.0
*/
function getHeapCodeStatistics(): HeapCodeStatistics;
/**
* @since v24.8.0
*/
interface CPUProfileHandle {
/**
* Stopping collecting the profile, then return a Promise that fulfills with an error or the
* profile data.
* @since v24.8.0
*/
stop(): Promise<string>;
/**
* Stopping collecting the profile and the profile will be discarded.
* @since v24.8.0
*/
[Symbol.asyncDispose](): Promise<void>;
}
/**
* V8 only supports `Latin-1/ISO-8859-1` and `UTF16` as the underlying representation of a string.
* If the `content` uses `Latin-1/ISO-8859-1` as the underlying representation, this function will return true;
Expand Down
Loading