diff --git a/configs/tsconfig-mongosh/package.json b/configs/tsconfig-mongosh/package.json index 84a853160..10ea57aeb 100644 --- a/configs/tsconfig-mongosh/package.json +++ b/configs/tsconfig-mongosh/package.json @@ -9,7 +9,7 @@ "tsconfig.test.json" ], "peerDependencies": { - "typescript": "^5.0.4" + "typescript": "^5.3.3" }, "devDependencies": { "@mongodb-js/prettier-config-devtools": "^1.0.0", diff --git a/configs/tsconfig-mongosh/tsconfig.test.json b/configs/tsconfig-mongosh/tsconfig.test.json index ed4ee41cd..0045835f9 100644 --- a/configs/tsconfig-mongosh/tsconfig.test.json +++ b/configs/tsconfig-mongosh/tsconfig.test.json @@ -3,7 +3,6 @@ "esModuleInterop": true, "downlevelIteration": true, "strict": false, - "experimentalDecorators": true, "noUnusedLocals": false, "noUnusedParameters": false, "target": "es2018", diff --git a/package-lock.json b/package-lock.json index 2acfcdf5a..ecbf0ac61 100644 --- a/package-lock.json +++ b/package-lock.json @@ -66,9 +66,9 @@ "sinon-chai": "^3.5.0", "terser-webpack-plugin": "^4.2.3", "ts-loader": "^8.0.14", - "ts-node": "^10.7.0", + "ts-node": "^10.9.2", "ts-sinon": "^1.2.0", - "typescript": "^5.0.4", + "typescript": "^5.3.3", "webpack": "^5.75.0", "webpack-bundle-analyzer": "^4.7.0", "webpack-cli": "^4.3.1", @@ -117,7 +117,7 @@ "prettier": "^2.7.1" }, "peerDependencies": { - "typescript": "^5.0.4" + "typescript": "^5.3.3" } }, "node_modules/@ampproject/remapping": { @@ -3589,27 +3589,28 @@ "node": ">=0.1.90" } }, - "node_modules/@cspotcode/source-map-consumer": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", - "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", - "dev": true, - "engines": { - "node": ">= 12" - } - }, "node_modules/@cspotcode/source-map-support": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", - "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", "dev": true, "dependencies": { - "@cspotcode/source-map-consumer": "0.8.0" + "@jridgewell/trace-mapping": "0.3.9" }, "engines": { "node": ">=12" } }, + "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@discoveryjs/json-ext": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz", @@ -28985,12 +28986,12 @@ } }, "node_modules/ts-node": { - "version": "10.7.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz", - "integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==", + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", "dev": true, "dependencies": { - "@cspotcode/source-map-support": "0.7.0", + "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", "@tsconfig/node12": "^1.0.7", "@tsconfig/node14": "^1.0.0", @@ -29001,7 +29002,7 @@ "create-require": "^1.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.0", + "v8-compile-cache-lib": "^3.0.1", "yn": "3.1.1" }, "bin": { @@ -29272,9 +29273,9 @@ } }, "node_modules/typescript": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", - "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", + "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", "devOptional": true, "bin": { "tsc": "bin/tsc", @@ -29575,9 +29576,9 @@ "devOptional": true }, "node_modules/v8-compile-cache-lib": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz", - "integrity": "sha512-mpSYqfsFvASnSn5qMiwrr4VKfumbPyONLCOPmsR3A6pTY/r0+tSaVbgPWSAIuzbk3lCTa+FForeTiO+wBQGkjA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", "dev": true }, "node_modules/validate-npm-package-license": { @@ -31251,7 +31252,7 @@ "eslint": "^7.25.0", "handlebars": "^4.7.7", "prettier": "^2.8.8", - "typescript": "^5.0.4" + "typescript": "^5.3.3" }, "engines": { "node": ">=14.15.1" @@ -34437,19 +34438,25 @@ "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==", "dev": true }, - "@cspotcode/source-map-consumer": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", - "integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==", - "dev": true - }, "@cspotcode/source-map-support": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz", - "integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==", + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", "dev": true, "requires": { - "@cspotcode/source-map-consumer": "0.8.0" + "@jridgewell/trace-mapping": "0.3.9" + }, + "dependencies": { + "@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "requires": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + } } }, "@discoveryjs/json-ext": { @@ -38138,7 +38145,7 @@ "eslint": "^7.25.0", "handlebars": "^4.7.7", "prettier": "^2.8.8", - "typescript": "^5.0.4" + "typescript": "^5.3.3" } }, "@mongosh/history": { @@ -54998,12 +55005,12 @@ } }, "ts-node": { - "version": "10.7.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.7.0.tgz", - "integrity": "sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==", + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", "dev": true, "requires": { - "@cspotcode/source-map-support": "0.7.0", + "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", "@tsconfig/node12": "^1.0.7", "@tsconfig/node14": "^1.0.0", @@ -55014,7 +55021,7 @@ "create-require": "^1.1.0", "diff": "^4.0.1", "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.0", + "v8-compile-cache-lib": "^3.0.1", "yn": "3.1.1" }, "dependencies": { @@ -55220,9 +55227,9 @@ } }, "typescript": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", - "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", + "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", "devOptional": true }, "ua-parser-js": { @@ -55426,9 +55433,9 @@ "devOptional": true }, "v8-compile-cache-lib": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.0.tgz", - "integrity": "sha512-mpSYqfsFvASnSn5qMiwrr4VKfumbPyONLCOPmsR3A6pTY/r0+tSaVbgPWSAIuzbk3lCTa+FForeTiO+wBQGkjA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", "dev": true }, "validate-npm-package-license": { diff --git a/package.json b/package.json index f9e95a346..c5200bf07 100644 --- a/package.json +++ b/package.json @@ -113,9 +113,9 @@ "sinon-chai": "^3.5.0", "terser-webpack-plugin": "^4.2.3", "ts-loader": "^8.0.14", - "ts-node": "^10.7.0", + "ts-node": "^10.9.2", "ts-sinon": "^1.2.0", - "typescript": "^5.0.4", + "typescript": "^5.3.3", "webpack": "^5.75.0", "webpack-bundle-analyzer": "^4.7.0", "webpack-cli": "^4.3.1", diff --git a/packages/errors/package.json b/packages/errors/package.json index b8714e0ae..77026835b 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -44,6 +44,6 @@ "eslint": "^7.25.0", "handlebars": "^4.7.7", "prettier": "^2.8.8", - "typescript": "^5.0.4" + "typescript": "^5.3.3" } } diff --git a/packages/i18n/tsconfig.json b/packages/i18n/tsconfig.json index 6a1fb660b..51ef57e2c 100644 --- a/packages/i18n/tsconfig.json +++ b/packages/i18n/tsconfig.json @@ -2,8 +2,7 @@ "extends": "@mongodb-js/tsconfig-mongosh/tsconfig.common.json", "compilerOptions": { "outDir": "./lib", - "allowJs": true, - "experimentalDecorators": true + "allowJs": true }, "include": ["src/**/*"], "exclude": ["./src/**/*.spec.*"] diff --git a/packages/shell-api/src/decorators.ts b/packages/shell-api/src/decorators.ts index 700965cf7..7b13e014a 100644 --- a/packages/shell-api/src/decorators.ts +++ b/packages/shell-api/src/decorators.ts @@ -448,8 +448,12 @@ export const toIgnore = ['constructor', 'help', 'toJSON']; * @param constructor The target class. * @param hasHelp Whether the class has own help information or not. */ -function shellApiClassGeneric(constructor: Function, hasHelp: boolean): void { - const className = constructor.name; +function shellApiClassGeneric( + constructor: T, + hasHelp: boolean, + context: ClassDecoratorContext +): void { + const className = context.name!; const classHelpKeyPrefix = `shell-api.classes.${className}.help`; const classHelp: ClassHelp = { help: `${classHelpKeyPrefix}.description`, @@ -594,16 +598,22 @@ function shellApiClassGeneric(constructor: Function, hasHelp: boolean): void { /** * Marks a class as being a Shell API class including help information. */ -export function shellApiClassDefault(constructor: Function): void { - shellApiClassGeneric(constructor, true); +export function shellApiClassDefault( + constructor: T, + context: ClassDecoratorContext +): void { + return shellApiClassGeneric(constructor, true, context); } /** * Marks a class as being a Shell API class without help information * (e.g. a superclass of other classes). */ -export function shellApiClassNoHelp(constructor: Function): void { - shellApiClassGeneric(constructor, false); +export function shellApiClassNoHelp( + constructor: T, + context: ClassDecoratorContext +): void { + return shellApiClassGeneric(constructor, false, context); } /** @@ -615,11 +625,11 @@ export function shellApiClassNoHelp(constructor: Function): void { * @param orig The function to be wrapped. * @returns The wrapped function. */ -function markImplicitlyAwaited Promise>( - orig: T -): (...args: Parameters) => Promise { - function wrapper(this: any, ...args: any[]) { - const origResult = orig.call(this, ...args); +function markImplicitlyAwaited( + orig: (this: This, ...args: Args) => Promise +): (this: This, ...args: Args) => Promise { + function wrapper(this: This, ...args: Args[]) { + const origResult = orig.call(this, ...(args as any)); return addHiddenDataProperty( origResult, Symbol.for('@@mongosh.syntheticPromise'), @@ -644,13 +654,13 @@ function markImplicitlyAwaited Promise>( * * @param versionArray An array of supported server versions */ -export function serverVersions(versionArray: [string, string]): Function { - return function ( - _target: any, - _propertyKey: string, - descriptor: PropertyDescriptor - ): void { - descriptor.value.serverVersions = versionArray; +export function serverVersions(serverVersions: [string, string]) { + return function ( + value: T, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + context: ClassMethodDecoratorContext + ): T & { serverVersions: [string, string] } { + return Object.assign(value, { serverVersions }); }; } @@ -662,20 +672,18 @@ export function serverVersions(versionArray: [string, string]): Function { * * @param versionArray An array of supported API versions */ -export function apiVersions( - versionArray: [] | [number] | [number, number] -): Function { - return function ( - _target: any, - _propertyKey: string, - descriptor: PropertyDescriptor - ): void { +export function apiVersions(versionArray: [] | [number] | [number, number]) { + return function ( + value: T, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + context: ClassMethodDecoratorContext + ): T & { apiVersions: [number, number] } { if (versionArray.length === 0) { versionArray = [0, 0]; } else if (versionArray.length === 1) { versionArray = [versionArray[0], Infinity]; } - descriptor.value.apiVersions = versionArray; + return Object.assign(value, { apiVersions: versionArray }); }; } @@ -688,12 +696,12 @@ export function apiVersions( * * **Important:** To exclude the method from autocompletion use `@serverVersions`. */ -export function deprecated( - _target: any, - _propertyKey: string, - descriptor: PropertyDescriptor -): void { - descriptor.value.deprecated = true; +export function deprecated( + value: T, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + context: ClassMethodDecoratorContext +): T & { deprecated: true } { + return Object.assign(value, { deprecated: true } as const); } /** @@ -703,13 +711,13 @@ export function deprecated( * * @param topologiesArray The topologies for which the method is available */ -export function topologies(topologiesArray: Topologies[]): Function { - return function ( - _target: any, - _propertyKey: string, - descriptor: PropertyDescriptor - ): void { - descriptor.value.topologies = topologiesArray; +export function topologies(topologies: Topologies[]) { + return function ( + value: T, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + context: ClassMethodDecoratorContext + ): T & { topologies: Topologies[] } { + return Object.assign(value, { topologies }); }; } @@ -721,17 +729,17 @@ export const nonAsyncFunctionsReturningPromises: string[] = []; // For testing. * Note: a test will verify that the `nonAsyncFunctionsReturningPromises` is empty, i.e. **every** * method that is decorated with `@returnsPromise` must be an `async` method. */ -export function returnsPromise( - _target: any, - _propertyKey: string, - descriptor: PropertyDescriptor -): void { - const originalFunction = descriptor.value; - originalFunction.returnsPromise = true; - - async function wrapper(this: any, ...args: any[]) { +export function returnsPromise( + originalFunction: (this: This, ...args: Args) => Promise, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + context: ClassMethodDecoratorContext< + This, + (this: This, ...args: Args) => Promise + > +): ((this: This, ...args: Args) => Promise) & { returnsPromise: true } { + async function wrapper(this: This, ...args: Args[]): Promise { try { - return await originalFunction.call(this, ...args); + return await originalFunction.call(this, ...(args as any)); } finally { if ( typeof setTimeout === 'function' && @@ -747,23 +755,25 @@ export function returnsPromise( wrapper, Object.getOwnPropertyDescriptors(originalFunction) ); - descriptor.value = markImplicitlyAwaited(wrapper); if (originalFunction.constructor.name !== 'AsyncFunction') { nonAsyncFunctionsReturningPromises.push(originalFunction.name); } + return Object.assign(markImplicitlyAwaited(wrapper), { + returnsPromise: true, + } as const); } /** * Marks the deocrated method as executable in the shell in a POSIX-shell-like * fashion, e.g. `show foo` which is translated into a call to `show('foo')`. */ -export function directShellCommand( - _target: any, - _propertyKey: string, - descriptor: PropertyDescriptor -): void { - descriptor.value.isDirectShellCommand = true; +export function directShellCommand( + value: T, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + context: ClassMethodDecoratorContext +): T & { isDirectShellCommand: true } { + return Object.assign(value, { isDirectShellCommand: true } as const); } /** @@ -776,14 +786,14 @@ export function directShellCommand( * @param completer The completer to use for autocomplete */ export function shellCommandCompleter( - completer: ShellCommandCompleter -): Function { - return function ( - _target: any, - _propertyKey: string, - descriptor: PropertyDescriptor - ): void { - descriptor.value.shellCommandCompleter = completer; + shellCommandCompleter: ShellCommandCompleter +) { + return function ( + value: T, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + context: ClassMethodDecoratorContext + ): T & { shellCommandCompleter: ShellCommandCompleter } { + return Object.assign(value, { shellCommandCompleter }); }; } @@ -794,13 +804,13 @@ export function shellCommandCompleter( * * @param type The Shell API return type of the method */ -export function returnType(type: string): Function { - return function ( - _target: any, - _propertyKey: string, - descriptor: PropertyDescriptor - ): void { - descriptor.value.returnType = type; +export function returnType(returnType: string) { + return function ( + value: T, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + context: ClassMethodDecoratorContext + ): T & { returnType: string } { + return Object.assign(value, { returnType }); }; } @@ -810,7 +820,11 @@ export function returnType(type: string): Function { * Calling the constructor will automatically emit a telemetry event but * will **not** print an automatic deprecation warning (see `printDeprecationWarning`). */ -export function classDeprecated(constructor: Function): void { +export function classDeprecated( + constructor: T, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + context: ClassDecoratorContext +): void { constructor.prototype.deprecated = true; } @@ -818,13 +832,13 @@ export function classDeprecated(constructor: Function): void { * Marks the decorated method as only being supported on the given platforms. * @param platformsArray The platforms the method is supported on */ -export function platforms(platformsArray: ReplPlatform[]): Function { - return function ( - _target: any, - _propertyKey: string, - descriptor: PropertyDescriptor - ): void { - descriptor.value.platforms = platformsArray; +export function platforms(platforms: ReplPlatform[]) { + return function ( + value: T, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + context: ClassMethodDecoratorContext + ): T & { platforms: ReplPlatform[] } { + return Object.assign(value, { platforms }); }; } @@ -833,7 +847,11 @@ export function platforms(platformsArray: ReplPlatform[]): Function { * @param platformsArray The platforms the method is supported on */ export function classPlatforms(platformsArray: ReplPlatform[]): Function { - return function (constructor: Function): void { + return function addSourceToResults( + constructor: T, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + context: ClassDecoratorContext + ): void { constructor.prototype.platforms = platformsArray; }; } @@ -842,6 +860,10 @@ export function classPlatforms(platformsArray: ReplPlatform[]): Function { * Marks the decorated class that for all methods in the class additional * source information of the call will be added to the calls returned result. */ -export function addSourceToResults(constructor: Function): void { +export function addSourceToResults( + constructor: T, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + context: ClassDecoratorContext +): void { (constructor as any)[addSourceToResultsSymbol] = true; } diff --git a/packages/shell-api/src/shell-api.ts b/packages/shell-api/src/shell-api.ts index 4eaaf1b64..1f3e63b8b 100644 --- a/packages/shell-api/src/shell-api.ts +++ b/packages/shell-api/src/shell-api.ts @@ -80,6 +80,8 @@ class ShellConfig extends ShellApiClass { return `Setting "${key}" has been changed`; } + // @ts-expect-error TS does not understand that the return type templating + // always interacts well with the decorators @returnsPromise async get( key: K diff --git a/packages/shell-api/tsconfig.json b/packages/shell-api/tsconfig.json index 9b83138fe..1a8f947a3 100644 --- a/packages/shell-api/tsconfig.json +++ b/packages/shell-api/tsconfig.json @@ -1,8 +1,7 @@ { "extends": "@mongodb-js/tsconfig-mongosh/tsconfig.common.json", "compilerOptions": { - "outDir": "./lib", - "experimentalDecorators": true + "outDir": "./lib" }, "include": ["src/**/*"], "exclude": ["./src/**/*.spec.*"] diff --git a/testing/helpers.ts b/testing/helpers.ts index 5b1cf754d..860897701 100644 --- a/testing/helpers.ts +++ b/testing/helpers.ts @@ -54,12 +54,12 @@ export function createRetriableMethod backoffFactor?: number, noiseThreshold: number, } -): (...args: Parameters) => ReturnType { +): T[F] { const totalRetries = options?.totalRetries ?? 12; const initialSleepInterval = options?.initialSleepInterval ?? 1000; const backoffFactor = options?.backoffFactor ?? 1.3; const noiseThreshold = options?.noiseThreshold ?? 0.8; - const func = target[method]; + const func: T[F] = target[method]; if (typeof func !== 'function') { throw new Error(`${method.toString()} is not a method`); @@ -67,7 +67,7 @@ export function createRetriableMethod let timeout = 0; const retriableFunc = async(...args: any) => { - let lastErr; + let lastErr: any; let sleepInterval = initialSleepInterval; for (let i = 0; i < totalRetries; i++) { try {