Skip to content

Commit 7efea7e

Browse files
authored
🤖 Merge PR DefinitelyTyped#74356 node: v25.1 by @Renegade334
1 parent 9279ee1 commit 7efea7e

File tree

6 files changed

+74
-15
lines changed

6 files changed

+74
-15
lines changed

types/node/http.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,15 @@ declare module "node:http" {
357357
* @since v18.17.0, v20.2.0
358358
*/
359359
rejectNonStandardBodyWrites?: boolean | undefined;
360+
/**
361+
* If set to `true`, requests without `Content-Length`
362+
* or `Transfer-Encoding` headers (indicating no body) will be initialized with an
363+
* already-ended body stream, so they will never emit any stream events
364+
* (like `'data'` or `'end'`). You can use `req.readableEnded` to detect this case.
365+
* @since v25.1.0
366+
* @default false
367+
*/
368+
optimizeEmptyRequests?: boolean | undefined;
360369
}
361370
type RequestListener<
362371
Request extends typeof IncomingMessage = typeof IncomingMessage,

types/node/node-tests/http.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import * as url from "node:url";
3939
keepAliveTimeout: 100,
4040
keepAliveTimeoutBuffer: 200,
4141
headersTimeout: 50000,
42+
optimizeEmptyRequests: true,
4243
requireHostHeader: false,
4344
rejectNonStandardBodyWrites: false,
4445
shouldUpgradeCallback(request) {

types/node/node-tests/sqlite.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ import { TextEncoder } from "node:util";
8888
database.enableLoadExtension(false);
8989
}
9090

91+
{
92+
const database = new DatabaseSync(":memory:", { defensive: false });
93+
database.enableDefensive(true);
94+
}
95+
9196
{
9297
let statement!: StatementSync;
9398
statement.expandedSQL; // $ExpectType string

types/node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@types/node",
4-
"version": "25.0.9999",
4+
"version": "25.1.9999",
55
"nonNpm": "conflict",
66
"nonNpmDescription": "Node.js",
77
"projects": [

types/node/sqlite.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ declare module "node:sqlite" {
123123
* @default false
124124
*/
125125
allowUnknownNamedParameters?: boolean | undefined;
126+
/**
127+
* If `true`, enables the defensive flag. When the defensive flag is enabled,
128+
* language features that allow ordinary SQL to deliberately corrupt the database file are disabled.
129+
* The defensive flag can also be set using `enableDefensive()`.
130+
* @since v25.1.0
131+
* @default false
132+
*/
133+
defensive?: boolean | undefined;
126134
}
127135
interface CreateSessionOptions {
128136
/**
@@ -294,6 +302,14 @@ declare module "node:sqlite" {
294302
* @param allow Whether to allow loading extensions.
295303
*/
296304
enableLoadExtension(allow: boolean): void;
305+
/**
306+
* Enables or disables the defensive flag. When the defensive flag is active,
307+
* language features that allow ordinary SQL to deliberately corrupt the database file are disabled.
308+
* See [`SQLITE_DBCONFIG_DEFENSIVE`](https://www.sqlite.org/c3ref/c_dbconfig_defensive.html#sqlitedbconfigdefensive) in the SQLite documentation for details.
309+
* @since v25.1.0
310+
* @param active Whether to set the defensive flag.
311+
*/
312+
enableDefensive(active: boolean): void;
297313
/**
298314
* This method is a wrapper around [`sqlite3_db_filename()`](https://sqlite.org/c3ref/db_filename.html)
299315
* @since v24.0.0

types/node/vm.d.ts

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ declare module "node:vm" {
749749
* // "contextifiedObject" when creating the context.
750750
* export default secret;
751751
* `, { context: referencingModule.context });
752-
* moduleMap.set(specifier, linkedModule);
752+
* moduleMap.set(specifier, requestedModule);
753753
* // Resolve the dependencies of the new module as well.
754754
* resolveAndLinkDependencies(requestedModule);
755755
* }
@@ -819,19 +819,47 @@ declare module "node:vm" {
819819
*/
820820
status: ModuleStatus;
821821
/**
822-
* Evaluate the module.
823-
*
824-
* This must be called after the module has been linked; otherwise it will reject.
825-
* It could be called also when the module has already been evaluated, in which
826-
* case it will either do nothing if the initial evaluation ended in success
827-
* (`module.status` is `'evaluated'`) or it will re-throw the exception that the
828-
* initial evaluation resulted in (`module.status` is `'errored'`).
829-
*
830-
* This method cannot be called while the module is being evaluated
831-
* (`module.status` is `'evaluating'`).
832-
*
833-
* Corresponds to the [Evaluate() concrete method](https://tc39.es/ecma262/#sec-moduleevaluation) field of [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records) s in the
834-
* ECMAScript specification.
822+
* Evaluate the module and its depenendencies. Corresponds to the [Evaluate() concrete method](https://tc39.es/ecma262/#sec-moduleevaluation) field of
823+
* [Cyclic Module Record](https://tc39.es/ecma262/#sec-cyclic-module-records)s in the ECMAScript specification.
824+
*
825+
* If the module is a `vm.SourceTextModule`, `evaluate()` must be called after the module has been instantiated;
826+
* otherwise `evaluate()` will return a rejected promise.
827+
*
828+
* For a `vm.SourceTextModule`, the promise returned by `evaluate()` may be fulfilled either
829+
* synchronously or asynchronously:
830+
*
831+
* 1. If the `vm.SourceTextModule` has no top-level `await` in itself or any of its dependencies, the promise will be
832+
* fulfilled _synchronously_ after the module and all its dependencies have been evaluated.
833+
* 1. If the evaluation succeeds, the promise will be _synchronously_ resolved to `undefined`.
834+
* 2. If the evaluation results in an exception, the promise will be _synchronously_ rejected with the exception
835+
* that causes the evaluation to fail, which is the same as `module.error`.
836+
* 2. If the `vm.SourceTextModule` has top-level `await` in itself or any of its dependencies, the promise will be
837+
* fulfilled _asynchronously_ after the module and all its dependencies have been evaluated.
838+
* 1. If the evaluation succeeds, the promise will be _asynchronously_ resolved to `undefined`.
839+
* 2. If the evaluation results in an exception, the promise will be _asynchronously_ rejected with the exception
840+
* that causes the evaluation to fail.
841+
*
842+
* If the module is a `vm.SyntheticModule`, `evaluate()` always returns a promise that fulfills synchronously, see
843+
* the specification of [Evaluate() of a Synthetic Module Record](https://tc39.es/ecma262/#sec-smr-Evaluate):
844+
*
845+
* 1. If the `evaluateCallback` passed to its constructor throws an exception synchronously, `evaluate()` returns
846+
* a promise that will be synchronously rejected with that exception.
847+
* 2. If the `evaluateCallback` does not throw an exception, `evaluate()` returns a promise that will be
848+
* synchronously resolved to `undefined`.
849+
*
850+
* The `evaluateCallback` of a `vm.SyntheticModule` is executed synchronously within the `evaluate()` call, and its
851+
* return value is discarded. This means if `evaluateCallback` is an asynchronous function, the promise returned by
852+
* `evaluate()` will not reflect its asynchronous behavior, and any rejections from an asynchronous
853+
* `evaluateCallback` will be lost.
854+
*
855+
* `evaluate()` could also be called again after the module has already been evaluated, in which case:
856+
*
857+
* 1. If the initial evaluation ended in success (`module.status` is `'evaluated'`), it will do nothing
858+
* and return a promise that resolves to `undefined`.
859+
* 2. If the initial evaluation resulted in an exception (`module.status` is `'errored'`), it will re-reject
860+
* the exception that the initial evaluation resulted in.
861+
*
862+
* This method cannot be called while the module is being evaluated (`module.status` is `'evaluating'`).
835863
* @return Fulfills with `undefined` upon success.
836864
*/
837865
evaluate(options?: ModuleEvaluateOptions): Promise<void>;

0 commit comments

Comments
 (0)