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
37 changes: 36 additions & 1 deletion types/node/assert.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ declare module "assert" {
* @default true
*/
strict?: boolean | undefined;
/**
* If set to `true`, skips prototype and constructor
* comparison in deep equality checks.
* @since v24.9.0
* @default false
*/
skipPrototype?: boolean | undefined;
}
interface Assert extends Pick<typeof assert, AssertMethodNames> {
readonly [kOptions]: AssertOptions & { strict: false };
Expand All @@ -67,7 +74,8 @@ declare module "assert" {
* ```
*
* **Important**: When destructuring assertion methods from an `Assert` instance,
* the methods lose their connection to the instance's configuration options (such as `diff` and `strict` settings).
* the methods lose their connection to the instance's configuration options (such
* as `diff`, `strict`, and `skipPrototype` settings).
* The destructured methods will fall back to default behavior instead.
*
* ```js
Expand All @@ -81,6 +89,33 @@ declare module "assert" {
* strictEqual({ a: 1 }, { b: { c: 1 } });
* ```
*
* The `skipPrototype` option affects all deep equality methods:
*
* ```js
* class Foo {
* constructor(a) {
* this.a = a;
* }
* }
*
* class Bar {
* constructor(a) {
* this.a = a;
* }
* }
*
* const foo = new Foo(1);
* const bar = new Bar(1);
*
* // Default behavior - fails due to different constructors
* const assert1 = new Assert();
* assert1.deepStrictEqual(foo, bar); // AssertionError
*
* // Skip prototype comparison - passes if properties are equal
* const assert2 = new Assert({ skipPrototype: true });
* assert2.deepStrictEqual(foo, bar); // OK
* ```
*
* When destructured, methods lose access to the instance's `this` context and revert to default assertion behavior
* (diff: 'simple', non-strict mode).
* To maintain custom options when using destructured methods, avoid
Expand Down
24 changes: 18 additions & 6 deletions types/node/crypto.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4254,6 +4254,16 @@ declare module "crypto" {
* @since v15.6.0
*/
readonly serialNumber: string;
/**
* The algorithm used to sign the certificate or `undefined` if the signature algorithm is unknown by OpenSSL.
* @since v24.9.0
*/
readonly signatureAlgorithm: string | undefined;
/**
* The OID of the algorithm used to sign the certificate.
* @since v24.9.0
*/
readonly signatureAlgorithmOid: string;
/**
* The date/time from which this certificate is considered valid.
* @since v15.6.0
Expand Down Expand Up @@ -5138,9 +5148,9 @@ declare module "crypto" {
exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>;
exportKey(format: Exclude<KeyFormat, "jwk">, key: CryptoKey): Promise<ArrayBuffer>;
/**
* Using the method and parameters provided in `algorithm`, `subtle.generateKey()`
* attempts to generate new keying material. Depending the method used, the method
* may generate either a single `CryptoKey` or a `CryptoKeyPair`.
* Using the parameters provided in `algorithm`, this method
* attempts to generate new keying material. Depending on the algorithm used
* either a single `CryptoKey` or a `CryptoKeyPair` is generated.
*
* The `CryptoKeyPair` (public and private key) generating algorithms supported
* include:
Expand Down Expand Up @@ -5198,9 +5208,11 @@ declare module "crypto" {
*/
getPublicKey(key: CryptoKey, keyUsages: KeyUsage[]): Promise<CryptoKey>;
/**
* The `subtle.importKey()` method attempts to interpret the provided `keyData` as the given `format`
* to create a `<CryptoKey>` instance using the provided `algorithm`, `extractable`, and `keyUsages` arguments.
* If the import is successful, the returned promise will be resolved with the created `<CryptoKey>`.
* This method attempts to interpret the provided `keyData`
* as the given `format` to create a `CryptoKey` instance using the provided
* `algorithm`, `extractable`, and `keyUsages` arguments. If the import is
* successful, the returned promise will be resolved with a {CryptoKey}
* representation of the key material.
*
* If importing KDF algorithm keys, `extractable` must be `false`.
* @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, `'jwk'`, `'raw-secret'`,
Expand Down
11 changes: 11 additions & 0 deletions types/node/http.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,17 @@ declare module "http" {
* If the header's value is an array, the items will be joined using `; `.
*/
uniqueHeaders?: Array<string | string[]> | undefined;
/**
* A callback which receives an
* incoming request and returns a boolean, to control which upgrade attempts
* should be accepted. Accepted upgrades will fire an `'upgrade'` event (or
* their sockets will be destroyed, if no listener is registered) while
* rejected upgrades will fire a `'request'` event like any non-upgrade
* request.
* @since v24.9.0
* @default () => server.listenerCount('upgrade') > 0
*/
shouldUpgradeCallback?: ((request: InstanceType<Request>) => boolean) | undefined;
/**
* If set to `true`, an error is thrown when writing to an HTTP response which does not have a body.
* @default false
Expand Down
4 changes: 2 additions & 2 deletions 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.8.9999",
"version": "24.9.9999",
"nonNpm": "conflict",
"nonNpmDescription": "Node.js",
"projects": [
Expand All @@ -18,7 +18,7 @@
}
},
"dependencies": {
"undici-types": "~7.14.0"
"undici-types": "~7.16.0"
},
"devDependencies": {
"@types/node": "workspace:."
Expand Down
108 changes: 108 additions & 0 deletions types/node/sqlite.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,47 @@ declare module "node:sqlite" {
* @return The prepared statement.
*/
prepare(sql: string): StatementSync;
/**
* Creates a new `SQLTagStore`, which is an LRU (Least Recently Used) cache for
* storing prepared statements. This allows for the efficient reuse of prepared
* statements by tagging them with a unique identifier.
*
* When a tagged SQL literal is executed, the `SQLTagStore` checks if a prepared
* statement for that specific SQL string already exists in the cache. If it does,
* the cached statement is used. If not, a new prepared statement is created,
* executed, and then stored in the cache for future use. This mechanism helps to
* avoid the overhead of repeatedly parsing and preparing the same SQL statements.
*
* ```js
* import { DatabaseSync } from 'node:sqlite';
*
* const db = new DatabaseSync(':memory:');
* const sql = db.createSQLTagStore();
*
* db.exec('CREATE TABLE users (id INT, name TEXT)');
*
* // Using the 'run' method to insert data.
* // The tagged literal is used to identify the prepared statement.
* sql.run`INSERT INTO users VALUES (1, 'Alice')`;
* sql.run`INSERT INTO users VALUES (2, 'Bob')`;
*
* // Using the 'get' method to retrieve a single row.
* const id = 1;
* const user = sql.get`SELECT * FROM users WHERE id = ${id}`;
* console.log(user); // { id: 1, name: 'Alice' }
*
* // Using the 'all' method to retrieve all rows.
* const allUsers = sql.all`SELECT * FROM users ORDER BY id`;
* console.log(allUsers);
* // [
* // { id: 1, name: 'Alice' },
* // { id: 2, name: 'Bob' }
* // ]
* ```
* @since v24.9.0
* @returns A new SQL tag store for caching prepared statements.
*/
createTagStore(maxSize?: number): SQLTagStore;
/**
* Creates and attaches a session to the database. This method is a wrapper around
* [`sqlite3session_create()`](https://www.sqlite.org/session/sqlite3session_create.html) and
Expand Down Expand Up @@ -428,6 +469,73 @@ declare module "node:sqlite" {
*/
close(): void;
}
/**
* This class represents a single LRU (Least Recently Used) cache for storing
* prepared statements.
*
* Instances of this class are created via the database.createSQLTagStore() method,
* not by using a constructor. The store caches prepared statements based on the
* provided SQL query string. When the same query is seen again, the store
* retrieves the cached statement and safely applies the new values through
* parameter binding, thereby preventing attacks like SQL injection.
*
* The cache has a maxSize that defaults to 1000 statements, but a custom size can
* be provided (e.g., database.createSQLTagStore(100)). All APIs exposed by this
* class execute synchronously.
* @since v24.9.0
*/
interface SQLTagStore {
/**
* Executes the given SQL query and returns all resulting rows as an array of objects.
* @since v24.9.0
*/
all(
stringElements: TemplateStringsArray,
...boundParameters: SQLInputValue[]
): Record<string, SQLOutputValue>[];
/**
* Executes the given SQL query and returns the first resulting row as an object.
* @since v24.9.0
*/
get(
stringElements: TemplateStringsArray,
...boundParameters: SQLInputValue[]
): Record<string, SQLOutputValue> | undefined;
/**
* Executes the given SQL query and returns an iterator over the resulting rows.
* @since v24.9.0
*/
iterate(
stringElements: TemplateStringsArray,
...boundParameters: SQLInputValue[]
): NodeJS.Iterator<Record<string, SQLOutputValue>>;
/**
* Executes the given SQL query, which is expected to not return any rows (e.g., INSERT, UPDATE, DELETE).
* @since v24.9.0
*/
run(stringElements: TemplateStringsArray, ...boundParameters: SQLInputValue[]): StatementResultingChanges;
/**
* A read-only property that returns the number of prepared statements currently in the cache.
* @since v24.9.0
* @returns The maximum number of prepared statements the cache can hold.
*/
size(): number;
/**
* A read-only property that returns the maximum number of prepared statements the cache can hold.
* @since v24.9.0
*/
readonly capacity: number;
/**
* A read-only property that returns the `DatabaseSync` object associated with this `SQLTagStore`.
* @since v24.9.0
*/
readonly db: DatabaseSync;
/**
* Resets the LRU cache, clearing all stored prepared statements.
* @since v24.9.0
*/
clear(): void;
}
interface StatementColumnMetadata {
/**
* The unaliased name of the column in the origin
Expand Down
1 change: 1 addition & 0 deletions types/node/test/assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ assert.partialDeepStrictEqual({ a: 1, b: 2, c: 3 }, { a: 1, b: 2 });
// The type annotation is mandatory here to avoid TS2775
const strictCustomAssert: assert.AssertStrict = new assert.Assert({
diff: "full",
skipPrototype: true,
});
strictCustomAssert.equal(n, 1);
_1 = n;
Expand Down
2 changes: 2 additions & 0 deletions types/node/test/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,8 @@ import { promisify } from "node:util";
cert.publicKey; // $ExpectType KeyObject
cert.raw; // $ExpectType Buffer || Buffer<ArrayBufferLike>
cert.serialNumber; // $ExpectType string
cert.signatureAlgorithm; // $ExpectType string | undefined
cert.signatureAlgorithmOid; // $ExpectType string
cert.subject; // $ExpectType string
cert.subjectAltName; // $ExpectType string | undefined
cert.validFrom; // $ExpectType string
Expand Down
4 changes: 4 additions & 0 deletions types/node/test/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ import * as url from "node:url";
headersTimeout: 50000,
requireHostHeader: false,
rejectNonStandardBodyWrites: false,
shouldUpgradeCallback(request) {
request; // $ExpectType IncomingMessage
return true;
},
}, reqListener);

server.close();
Expand Down
21 changes: 21 additions & 0 deletions types/node/test/sqlite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { TextEncoder } from "node:util";
database.isOpen; // $ExpectType boolean
database.isTransaction; // $ExpectType boolean

database.createTagStore(); // $ExpectType SQLTagStore
database.createTagStore(100); // $ExpectType SQLTagStore

database.exec(`
CREATE TABLE data(
key INTEGER PRIMARY KEY,
Expand Down Expand Up @@ -142,3 +145,21 @@ import { TextEncoder } from "node:util";
},
);
}

{
const db = new DatabaseSync(":memory:");
const tagStore = db.createTagStore();

const id = 12345;
const name = "Alice";

tagStore.all`SELECT * FROM users ORDER BY id`; // $ExpectType Record<string, SQLOutputValue>[]
tagStore.get`SELECT * FROM users WHERE id = ${id}`; // $ExpectType Record<string, SQLOutputValue> | undefined
tagStore.iterate`SELECT * FROM users WHERE id = ${id}`; // $ExpectType Iterator<Record<string, SQLOutputValue>, undefined, any>
tagStore.run`INSERT INTO users VALUES (${id}, ${name})`; // $ExpectType StatementResultingChanges

tagStore.size(); // $ExpectType number
tagStore.capacity; // $ExpectType number
tagStore.db; // $ExpectType DatabaseSync
tagStore.clear();
}
3 changes: 2 additions & 1 deletion types/node/test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ util.deprecate(util.deprecate, "deprecate() is deprecated, use bar() instead");
util.deprecate(util.deprecate, "deprecate() is deprecated, use bar() instead", "DEP0001");

// util.isDeepStrictEqual
util.isDeepStrictEqual({ foo: "bar" }, { foo: "bar" });
util.isDeepStrictEqual({ foo: "bar" }, { foo: "bar" }); // $ExpectType boolean
util.isDeepStrictEqual({ foo: "bar" }, { foo: "bar" }, { skipPrototype: true }); // $ExpectType boolean

// util.TextDecoder()
const td = new util.TextDecoder();
Expand Down
3 changes: 3 additions & 0 deletions types/node/test/vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ import {
resolveAndLinkDependencies(rootModule);
rootModule.instantiate();

rootModule.hasAsyncGraph(); // $ExpectType boolean
rootModule.hasTopLevelAwait(); // $ExpectType boolean

await rootModule.evaluate();
});

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 @@ -79,6 +79,9 @@ import { createContext } from "node:vm";
w.startCpuProfile().then(handle => {
handle.stop().then(JSON.parse);
});
w.startHeapProfile().then(handle => {
handle.stop().then(JSON.parse);
});
w.terminate().then(() => {
// woot
});
Expand Down
11 changes: 10 additions & 1 deletion types/node/util.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,15 @@ declare module "util" {
* @return The deprecated function wrapped to emit a warning.
*/
export function deprecate<T extends Function>(fn: T, msg: string, code?: string): T;
export interface IsDeepStrictEqualOptions {
/**
* If `true`, prototype and constructor
* comparison is skipped during deep strict equality check.
* @since v24.9.0
* @default false
*/
skipPrototype?: boolean | undefined;
}
/**
* Returns `true` if there is deep strict equality between `val1` and `val2`.
* Otherwise, returns `false`.
Expand All @@ -861,7 +870,7 @@ declare module "util" {
* equality.
* @since v9.0.0
*/
export function isDeepStrictEqual(val1: unknown, val2: unknown): boolean;
export function isDeepStrictEqual(val1: unknown, val2: unknown, options?: IsDeepStrictEqualOptions): boolean;
/**
* Returns `str` with any ANSI escape codes removed.
*
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 @@ -416,6 +416,22 @@ declare module "v8" {
*/
[Symbol.asyncDispose](): Promise<void>;
}
/**
* @since v24.9.0
*/
interface HeapProfileHandle {
/**
* Stopping collecting the profile, then return a Promise that fulfills with an error or the
* profile data.
* @since v24.9.0
*/
stop(): Promise<string>;
/**
* Stopping collecting the profile and the profile will be discarded.
* @since v24.9.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