Skip to content

Commit 57ef31b

Browse files
chore(NODE-6939): update typescript to 5.8.3 (#4526)
Co-authored-by: Bailey Pearson <[email protected]>
1 parent e278263 commit 57ef31b

File tree

24 files changed

+171
-159
lines changed

24 files changed

+171
-159
lines changed

package-lock.json

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@
107107
"socks": "^2.8.1",
108108
"source-map-support": "^0.5.21",
109109
"ts-node": "^10.9.2",
110-
"tsd": "^0.31.2",
111-
"typescript": "5.5",
110+
"tsd": "^0.32.0",
111+
"typescript": "5.8.3",
112112
"typescript-cached-transpile": "^0.0.6",
113113
"v8-heapsnapshot": "^1.3.1",
114114
"yargs": "^17.7.2"

src/bulk/common.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -894,16 +894,14 @@ export abstract class BulkOperationBase {
894894
/** @internal */
895895
s: BulkOperationPrivate;
896896
operationId?: number;
897+
private collection: Collection;
897898

898899
/**
899900
* Create a new OrderedBulkOperation or UnorderedBulkOperation instance
900901
* @internal
901902
*/
902-
constructor(
903-
private collection: Collection,
904-
options: BulkWriteOptions,
905-
isOrdered: boolean
906-
) {
903+
constructor(collection: Collection, options: BulkWriteOptions, isOrdered: boolean) {
904+
this.collection = collection;
907905
// determine whether bulkOperation is ordered or unordered
908906
this.isOrdered = isOrdered;
909907

src/client-side-encryption/state_machine.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,13 @@ export type StateMachineOptions = {
186186
*/
187187
// TODO(DRIVERS-2671): clarify CSOT behavior for FLE APIs
188188
export class StateMachine {
189-
constructor(
190-
private options: StateMachineOptions,
191-
private bsonOptions = pluckBSONSerializeOptions(options)
192-
) {}
189+
private options: StateMachineOptions;
190+
private bsonOptions: BSONSerializeOptions;
191+
192+
constructor(options: StateMachineOptions, bsonOptions = pluckBSONSerializeOptions(options)) {
193+
this.options = options;
194+
this.bsonOptions = bsonOptions;
195+
}
193196

194197
/**
195198
* Executes the state machine according to the specification

src/cmap/commands.ts

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,10 @@ export class OpQueryRequest {
7676
partial: boolean;
7777
/** moreToCome is an OP_MSG only concept */
7878
moreToCome = false;
79+
databaseName: string;
80+
query: Document;
7981

80-
constructor(
81-
public databaseName: string,
82-
public query: Document,
83-
options: OpQueryOptions
84-
) {
82+
constructor(databaseName: string, query: Document, options: OpQueryOptions) {
8583
// Basic options needed to be passed in
8684
// TODO(NODE-3483): Replace with MongoCommandError
8785
const ns = `${databaseName}.$cmd`;
@@ -97,7 +95,9 @@ export class OpQueryRequest {
9795
throw new MongoRuntimeError('Namespace cannot contain a null character');
9896
}
9997

100-
// Basic options
98+
// Basic optionsa
99+
this.databaseName = databaseName;
100+
this.query = query;
101101
this.ns = ns;
102102

103103
// Additional options
@@ -496,17 +496,18 @@ export class OpMsgRequest {
496496
checksumPresent: boolean;
497497
moreToCome: boolean;
498498
exhaustAllowed: boolean;
499+
databaseName: string;
500+
command: Document;
501+
options: OpQueryOptions;
499502

500-
constructor(
501-
public databaseName: string,
502-
public command: Document,
503-
public options: OpQueryOptions
504-
) {
503+
constructor(databaseName: string, command: Document, options: OpQueryOptions) {
505504
// Basic options needed to be passed in
506505
if (command == null)
507506
throw new MongoInvalidArgumentError('Query document must be specified for query');
508507

509-
// Basic options
508+
// Basic optionsa
509+
this.databaseName = databaseName;
510+
this.command = command;
510511
this.command.$db = databaseName;
511512

512513
// Ensure empty options
@@ -724,16 +725,30 @@ export class OpMsgResponse {
724725
const MESSAGE_HEADER_SIZE = 16;
725726
const COMPRESSION_DETAILS_SIZE = 9; // originalOpcode + uncompressedSize, compressorID
726727

728+
/**
729+
* @internal
730+
*/
731+
export interface OpCompressesRequestOptions {
732+
zlibCompressionLevel: number;
733+
agreedCompressor: CompressorName;
734+
}
735+
727736
/**
728737
* @internal
729738
*
730739
* An OP_COMPRESSED request wraps either an OP_QUERY or OP_MSG message.
731740
*/
732741
export class OpCompressedRequest {
733-
constructor(
734-
private command: WriteProtocolMessageType,
735-
private options: { zlibCompressionLevel: number; agreedCompressor: CompressorName }
736-
) {}
742+
private command: WriteProtocolMessageType;
743+
private options: OpCompressesRequestOptions;
744+
745+
constructor(command: WriteProtocolMessageType, options: OpCompressesRequestOptions) {
746+
this.command = command;
747+
this.options = {
748+
zlibCompressionLevel: options.zlibCompressionLevel,
749+
agreedCompressor: options.agreedCompressor
750+
};
751+
}
737752

738753
// Return whether a command contains an uncompressible command term
739754
// Will return true if command contains no uncompressible command terms

src/cmap/handshake/client_metadata.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ export class LimitedSizeDocument {
5353
private document = new Map();
5454
/** BSON overhead: Int32 + Null byte */
5555
private documentSize = 5;
56-
constructor(private maxSize: number) {}
56+
private maxSize: number;
57+
58+
constructor(maxSize: number) {
59+
this.maxSize = maxSize;
60+
}
5761

5862
/** Only adds key/value if the bsonByteLength is less than MAX_SIZE */
5963
public ifItFitsItSits(key: string, value: Record<string, any> | string): boolean {

src/cmap/wire_protocol/compression.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { MongoDecompressionError, MongoInvalidArgumentError } from '../../error'
77
import {
88
type MessageHeader,
99
OpCompressedRequest,
10+
type OpCompressesRequestOptions,
1011
OpMsgResponse,
1112
OpReply,
1213
type WriteProtocolMessageType
@@ -60,7 +61,7 @@ function loadSnappy() {
6061

6162
// Facilitate compressing a message using an agreed compressor
6263
export async function compress(
63-
options: { zlibCompressionLevel: number; agreedCompressor: CompressorName },
64+
options: OpCompressesRequestOptions,
6465
dataToBeCompressed: Buffer
6566
): Promise<Buffer> {
6667
const zlibOptions = {} as zlib.ZlibOptions;

src/cmap/wire_protocol/on_data.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ export function onData(
8787

8888
[Symbol.asyncIterator]() {
8989
return this;
90+
},
91+
92+
// Note this should currently not be used, but is required by the AsyncGenerator interface.
93+
async [Symbol.asyncDispose]() {
94+
await closeHandler();
9095
}
9196
};
9297

src/cmap/wire_protocol/on_demand/document.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ import {
1414
toUTF8
1515
} from '../../../bson';
1616

17-
// eslint-disable-next-line no-restricted-syntax
18-
const enum BSONElementOffset {
19-
type = 0,
20-
nameOffset = 1,
21-
nameLength = 2,
22-
offset = 3,
23-
length = 4
24-
}
17+
const BSONElementOffset = {
18+
type: 0,
19+
nameOffset: 1,
20+
nameLength: 2,
21+
offset: 3,
22+
length: 4
23+
} as const;
2524

2625
/** @internal */
2726
export type JSTypeOf = {
@@ -67,17 +66,23 @@ export class OnDemandDocument {
6766

6867
/** All bson elements in this document */
6968
private readonly elements: ReadonlyArray<BSONElement>;
69+
/** BSON bytes, this document begins at offset */
70+
protected readonly bson: Uint8Array;
71+
/** The start of the document */
72+
private readonly offset: number;
73+
/** If this is an embedded document, indicates if this was a BSON array */
74+
public readonly isArray: boolean;
7075

7176
constructor(
72-
/** BSON bytes, this document begins at offset */
73-
protected readonly bson: Uint8Array,
74-
/** The start of the document */
75-
private readonly offset = 0,
76-
/** If this is an embedded document, indicates if this was a BSON array */
77-
public readonly isArray = false,
77+
bson: Uint8Array,
78+
offset = 0,
79+
isArray = false,
7880
/** If elements was already calculated */
7981
elements?: BSONElement[]
8082
) {
83+
this.bson = bson;
84+
this.offset = offset;
85+
this.isArray = isArray;
8186
this.elements = elements ?? parseToElementsToArray(this.bson, offset);
8287
}
8388

src/cmap/wire_protocol/responses.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ import {
2020
type OnDemandDocumentDeserializeOptions
2121
} from './on_demand/document';
2222

23-
// eslint-disable-next-line no-restricted-syntax
24-
const enum BSONElementOffset {
25-
type = 0,
26-
nameOffset = 1,
27-
nameLength = 2,
28-
offset = 3,
29-
length = 4
30-
}
23+
const BSONElementOffset = {
24+
type: 0,
25+
nameOffset: 1,
26+
nameLength: 2,
27+
offset: 3,
28+
length: 4
29+
} as const;
30+
3131
/**
3232
* Accepts a BSON payload and checks for na "ok: 0" element.
3333
* This utility is intended to prevent calling response class constructors

src/connection_string.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,8 @@ function setOption(
605605
if (values[0] == null) {
606606
break;
607607
}
608+
// The value should always be a string here, but since the array is typed as unknown
609+
// there still needs to be an explicit cast.
608610
// eslint-disable-next-line @typescript-eslint/no-base-to-string
609611
mongoOptions[name] = String(values[0]);
610612
break;

src/cursor/abstract_cursor.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,11 +1213,13 @@ configureResourceManagement(AbstractCursor.prototype);
12131213
* All timeout behavior is exactly the same as the wrapped timeout context's.
12141214
*/
12151215
export class CursorTimeoutContext extends TimeoutContext {
1216-
constructor(
1217-
public timeoutContext: TimeoutContext,
1218-
public owner: symbol | AbstractCursor
1219-
) {
1216+
timeoutContext: TimeoutContext;
1217+
owner: symbol | AbstractCursor;
1218+
1219+
constructor(timeoutContext: TimeoutContext, owner: symbol | AbstractCursor) {
12201220
super();
1221+
this.timeoutContext = timeoutContext;
1222+
this.owner = owner;
12211223
}
12221224
override get serverSelectionTimeout(): Timeout | null {
12231225
return this.timeoutContext.serverSelectionTimeout;

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ export type { TokenCache } from './cmap/auth/mongodb_oidc/token_cache';
288288
export type {
289289
MessageHeader,
290290
OpCompressedRequest,
291+
OpCompressesRequestOptions,
291292
OpMsgOptions,
292293
OpMsgRequest,
293294
OpMsgResponse,

src/operations/distinct.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export class DistinctOperation extends CommandOperation<any[]> {
9696

9797
const result = await super.executeCommand(server, session, cmd, timeoutContext);
9898

99+
// @ts-expect-error: Explain always returns a document
99100
return this.explain ? result : result.values;
100101
}
101102
}

src/operations/rename.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@ export interface RenameOptions extends CommandOperationOptions {
1717

1818
/** @internal */
1919
export class RenameOperation extends CommandOperation<Document> {
20-
constructor(
21-
public collection: Collection,
22-
public newName: string,
23-
public override options: RenameOptions
24-
) {
20+
collection: Collection;
21+
newName: string;
22+
override options: RenameOptions;
23+
24+
constructor(collection: Collection, newName: string, options: RenameOptions) {
2525
super(collection, options);
26+
this.collection = collection;
27+
this.newName = newName;
28+
this.options = options;
2629
this.ns = new MongoDBNamespace('admin', '$cmd');
2730
}
2831

0 commit comments

Comments
 (0)