Skip to content

Commit 6900109

Browse files
committed
chore(NODE-6939): update typescript to 5.8.3
1 parent f57c51b commit 6900109

File tree

23 files changed

+290
-227
lines changed

23 files changed

+290
-227
lines changed

package-lock.json

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@
7979
"@types/sinon": "^17.0.4",
8080
"@types/sinon-chai": "^4.0.0",
8181
"@types/whatwg-url": "^13.0.0",
82-
"@typescript-eslint/eslint-plugin": "8.4.0",
83-
"@typescript-eslint/parser": "8.4.0",
82+
"@typescript-eslint/eslint-plugin": "8.31.1",
83+
"@typescript-eslint/parser": "8.31.1",
8484
"chai": "^4.4.1",
8585
"chai-subset": "^1.6.0",
8686
"chalk": "^4.1.2",
@@ -108,7 +108,7 @@
108108
"source-map-support": "^0.5.21",
109109
"ts-node": "^10.9.2",
110110
"tsd": "^0.31.2",
111-
"typescript": "5.5",
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: 8 additions & 5 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
@@ -275,7 +278,7 @@ export class StateMachine {
275278
// See docs on EMPTY_V
276279
result = EMPTY_V ??= serialize({ v: [] });
277280
}
278-
for await (const key of keys) {
281+
for (const key of keys) {
279282
context.addMongoOperationResponse(serialize(key));
280283
}
281284

src/cmap/commands.ts

Lines changed: 32 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
@@ -730,10 +731,19 @@ const COMPRESSION_DETAILS_SIZE = 9; // originalOpcode + uncompressedSize, compre
730731
* An OP_COMPRESSED request wraps either an OP_QUERY or OP_MSG message.
731732
*/
732733
export class OpCompressedRequest {
734+
private command: WriteProtocolMessageType;
735+
private options: { zLibCompressionLevel: number; agreedCompressor: CompressorName };
736+
733737
constructor(
734-
private command: WriteProtocolMessageType,
735-
private options: { zlibCompressionLevel: number; agreedCompressor: CompressorName }
736-
) {}
738+
command: WriteProtocolMessageType,
739+
options: { zlibCompressionLevel: number; agreedCompressor: CompressorName }
740+
) {
741+
this.command = command;
742+
this.options = {
743+
zLibCompressionLevel: options.zlibCompressionLevel,
744+
agreedCompressor: options.agreedCompressor
745+
};
746+
}
737747

738748
// Return whether a command contains an uncompressible command term
739749
// Will return true if command contains no uncompressible command terms
@@ -752,7 +762,13 @@ export class OpCompressedRequest {
752762
const originalCommandOpCode = concatenatedOriginalCommandBuffer.readInt32LE(12);
753763

754764
// Compress the message body
755-
const compressedMessage = await compress(this.options, messageToBeCompressed);
765+
const compressedMessage = await compress(
766+
{
767+
zlibCompressionLevel: this.options.zLibCompressionLevel,
768+
agreedCompressor: this.options.agreedCompressor
769+
},
770+
messageToBeCompressed
771+
);
756772
// Create the msgHeader of OP_COMPRESSED
757773
const msgHeader = Buffer.alloc(MESSAGE_HEADER_SIZE);
758774
msgHeader.writeInt32LE(

src/cmap/connection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ export class CryptoConnection extends Connection {
864864
ns: MongoDBNamespace,
865865
cmd: Document,
866866
options?: CommandOptions,
867-
responseType?: T | undefined
867+
responseType?: T
868868
): Promise<Document> {
869869
const { autoEncrypter } = this;
870870
if (!autoEncrypter) {

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/on_demand/document.ts

Lines changed: 20 additions & 15 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

@@ -262,7 +267,7 @@ export class OnDemandDocument {
262267
public get<const T extends keyof JSTypeOf>(
263268
name: string | number,
264269
as: T,
265-
required?: boolean | undefined
270+
required?: boolean
266271
): JSTypeOf[T] | null;
267272

268273
/** `required` will make `get` throw if name does not exist or is null/undefined */

src/cmap/wire_protocol/responses.ts

Lines changed: 10 additions & 10 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
@@ -77,7 +77,7 @@ export class MongoDBResponse extends OnDemandDocument {
7777
public override get<const T extends keyof JSTypeOf>(
7878
name: string | number,
7979
as: T,
80-
required?: false | undefined
80+
required?: false
8181
): JSTypeOf[T] | null;
8282
public override get<const T extends keyof JSTypeOf>(
8383
name: string | number,
@@ -87,7 +87,7 @@ export class MongoDBResponse extends OnDemandDocument {
8787
public override get<const T extends keyof JSTypeOf>(
8888
name: string | number,
8989
as: T,
90-
required?: boolean | undefined
90+
required?: boolean
9191
): JSTypeOf[T] | null {
9292
try {
9393
return super.get(name, as, required);

src/connection_string.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@ function setOption(
605605
if (values[0] == null) {
606606
break;
607607
}
608+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
608609
mongoOptions[name] = String(values[0]);
609610
break;
610611
case 'record':

0 commit comments

Comments
 (0)