Skip to content

Commit 27373bc

Browse files
committed
chore(NODE-6939): update typescript to 5.8.3
1 parent de2c955 commit 27373bc

23 files changed

+258
-205
lines changed

package-lock.json

+110-107
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"@aws-sdk/credential-providers": "^3.632.0",
6666
"@iarna/toml": "^2.2.5",
6767
"@istanbuljs/nyc-config-typescript": "^1.0.2",
68-
"@microsoft/api-extractor": "^7.49.2",
68+
"@microsoft/api-extractor": "^7.52.5",
6969
"@microsoft/tsdoc-config": "^0.17.1",
7070
"@mongodb-js/zstd": "^2.0.0",
7171
"@types/chai": "^4.3.17",
@@ -79,8 +79,8 @@
7979
"@types/sinon": "^17.0.3",
8080
"@types/sinon-chai": "^3.2.12",
8181
"@types/whatwg-url": "^11.0.5",
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

+3-5
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

+8-5
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

+32-16
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

+1-1
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

+5-1
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

+20-15
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

+10-10
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

+1
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':

src/constants.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
21
export const SYSTEM_NAMESPACE_COLLECTION = 'system.namespaces';
32
export const SYSTEM_INDEX_COLLECTION = 'system.indexes';
43
export const SYSTEM_PROFILE_COLLECTION = 'system.profile';

src/cursor/abstract_cursor.ts

+6-4
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/operations/aggregate.ts

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { type CollationOptions, CommandOperation, type CommandOperationOptions }
1212
import { Aspect, defineAspects, type Hint } from './operation';
1313

1414
/** @internal */
15-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
1615
export const DB_AGGREGATE_COLLECTION = 1 as const;
1716
const MIN_WIRE_VERSION_$OUT_READ_CONCERN_SUPPORT = 8;
1817

src/operations/distinct.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export class DistinctOperation extends CommandOperation<any[]> {
9696

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

99-
return this.explain ? result : result.values;
99+
return this.explain ? (result as any[]) : result.values;
100100
}
101101
}
102102

src/operations/rename.ts

+8-5
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)