diff --git a/configs/tsconfig-mongosh/package.json b/configs/tsconfig-mongosh/package.json index 10ea57aeb..4b3440b2b 100644 --- a/configs/tsconfig-mongosh/package.json +++ b/configs/tsconfig-mongosh/package.json @@ -5,8 +5,7 @@ "description": "Shared Mongosh Typescript configuration", "license": "SSPL", "files": [ - "tsconfig.common.json", - "tsconfig.test.json" + "tsconfig.common.json" ], "peerDependencies": { "typescript": "^5.3.3" diff --git a/configs/tsconfig-mongosh/tsconfig.test.json b/configs/tsconfig-mongosh/tsconfig.test.json deleted file mode 100644 index 0045835f9..000000000 --- a/configs/tsconfig-mongosh/tsconfig.test.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compilerOptions": { - "esModuleInterop": true, - "downlevelIteration": true, - "strict": false, - "noUnusedLocals": false, - "noUnusedParameters": false, - "target": "es2018", - "lib": ["es2019"], - "module": "commonjs", - "moduleResolution": "node" - } -} diff --git a/packages/node-runtime-worker-thread/package.json b/packages/node-runtime-worker-thread/package.json index 676522539..23863a126 100644 --- a/packages/node-runtime-worker-thread/package.json +++ b/packages/node-runtime-worker-thread/package.json @@ -17,7 +17,7 @@ "node": ">=14.15.1" }, "scripts": { - "test": "cross-env TS_NODE_PROJECT=./tsconfig.test.json mocha -r \"../../scripts/import-expansions.js\" -r \"./tests/register-worker.js \" --timeout 15000 -r ts-node/register \"./src/**/*.spec.ts\"", + "test": "mocha -r \"../../scripts/import-expansions.js\" -r \"./tests/register-worker.js \" --timeout 15000 -r ts-node/register \"./src/**/*.spec.ts\"", "pretest-ci": "node ../../scripts/run-if-package-requested.js npm run webpack-build -- --no-stats --no-devtool", "test-ci": "node ../../scripts/run-if-package-requested.js npm test", "test-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test", diff --git a/packages/node-runtime-worker-thread/src/index.spec.ts b/packages/node-runtime-worker-thread/src/index.spec.ts index bd0fd7446..a1aa5e909 100644 --- a/packages/node-runtime-worker-thread/src/index.spec.ts +++ b/packages/node-runtime-worker-thread/src/index.spec.ts @@ -48,7 +48,7 @@ describe('WorkerRuntime', function () { nodb: true, }); - let err: Error; + let err!: Error; try { await runtime.evaluate('throw new TypeError("Oh no, types!")'); @@ -219,7 +219,7 @@ describe('WorkerRuntime', function () { const runtime = new WorkerRuntime('mongodb://nodb/', dummyOptions, { nodb: true, }); - let err: Error; + let err!: Error; try { await Promise.all([ runtime.evaluate('while(true){}'), @@ -246,7 +246,7 @@ describe('WorkerRuntime', function () { await runtime.waitForRuntimeToBeReady(); - let err: Error; + let err!: Error; try { await Promise.all([ @@ -329,7 +329,7 @@ describe('WorkerRuntime', function () { await runtime.waitForRuntimeToBeReady(); - let err: Error; + let err!: Error; try { await Promise.all([ diff --git a/packages/node-runtime-worker-thread/src/lock.spec.ts b/packages/node-runtime-worker-thread/src/lock.spec.ts index 35ead53df..dde21e9f8 100644 --- a/packages/node-runtime-worker-thread/src/lock.spec.ts +++ b/packages/node-runtime-worker-thread/src/lock.spec.ts @@ -25,7 +25,7 @@ describe('Lock', function () { // eslint-disable-next-line @typescript-eslint/no-floating-promises lock.lock(); - let err: Error; + let err!: Error; try { // eslint-disable-next-line @typescript-eslint/no-floating-promises diff --git a/packages/node-runtime-worker-thread/src/rpc.spec.ts b/packages/node-runtime-worker-thread/src/rpc.spec.ts index ac7880299..e94e765b1 100644 --- a/packages/node-runtime-worker-thread/src/rpc.spec.ts +++ b/packages/node-runtime-worker-thread/src/rpc.spec.ts @@ -27,7 +27,7 @@ describe('rpc', function () { woof(...args: any[]): string; neverResolves(...args: any[]): void; }>; - let exposed: Exposed | null; + let exposed: Exposed; // adding `| null` breaks TS type inference afterEach(function () { if (messageBus) { @@ -36,12 +36,12 @@ describe('rpc', function () { if (caller) { caller[cancel](); - caller = null; + caller = null as any; } if (exposed) { exposed[close](); - exposed = null; + exposed = null as any; } }); @@ -74,7 +74,7 @@ describe('rpc', function () { messageBus ); - let err: Error; + let err!: Error; try { // eslint-disable-next-line @typescript-eslint/await-thenable @@ -136,7 +136,7 @@ describe('rpc', function () { messageBus = createMockRpcMesageBus(); caller = createCaller(['meow'], messageBus); - messageBus.addEventListener('message', (data) => { + messageBus.addEventListener('message', (data: unknown) => { expect(data).to.have.property('func', 'meow'); done(); }); @@ -150,7 +150,7 @@ describe('rpc', function () { it('stops all in-flight evaluations', async function () { messageBus = createMockRpcMesageBus(); caller = createCaller(['neverResolves'], messageBus); - let err: Error; + let err!: Error; try { await Promise.all([ caller.neverResolves(), diff --git a/packages/node-runtime-worker-thread/src/rpc.ts b/packages/node-runtime-worker-thread/src/rpc.ts index 53bf50a56..3672c9fd8 100644 --- a/packages/node-runtime-worker-thread/src/rpc.ts +++ b/packages/node-runtime-worker-thread/src/rpc.ts @@ -50,7 +50,10 @@ export type Exposed = { [k in keyof T]: T[k] & { close(): void } } & { [close]: () => void; }; -export function exposeAll(obj: O, messageBus: RPCMessageBus): Exposed { +export function exposeAll( + obj: O, + messageBus: RPCMessageBus +): Exposed { Object.entries(obj as Record).forEach(([key, val]) => { const { close } = expose( key, diff --git a/packages/node-runtime-worker-thread/src/worker-runtime.spec.ts b/packages/node-runtime-worker-thread/src/worker-runtime.spec.ts index 41dc7a361..b10991482 100644 --- a/packages/node-runtime-worker-thread/src/worker-runtime.spec.ts +++ b/packages/node-runtime-worker-thread/src/worker-runtime.spec.ts @@ -63,14 +63,14 @@ describe('worker-runtime', function () { if (caller) { caller[cancel](); - caller = null; + caller = null as any; } }); it('should throw if worker is not initialized yet', async function () { const { evaluate } = caller; - let err: Error; + let err!: Error; try { await evaluate('1 + 1'); @@ -161,18 +161,18 @@ describe('worker-runtime', function () { describe('shell-api results', function () { const testServer = startSharedTestServer(); const db = `test-db-${Date.now().toString(16)}`; - let exposed: Exposed | null; + let exposed: Exposed; // adding `| null` breaks TS type inference afterEach(function () { if (exposed) { exposed[close](); - exposed = null; + exposed = null as any; } }); type CommandTestRecord = | [string | string[], string] - | [string | string[], string, any]; + | [string | string[], string | null, any]; const showCommand: CommandTestRecord[] = [ [ @@ -323,11 +323,11 @@ describe('worker-runtime', function () { .forEach((testCase) => { const [commands, resultType, printable] = testCase; - let command: string | undefined; + let command: string; let prepare: undefined | string[]; if (Array.isArray(commands)) { - command = commands.pop(); + command = commands.pop()!; prepare = commands; } else { command = commands; @@ -376,7 +376,7 @@ describe('worker-runtime', function () { await init('mongodb://nodb/', dummyOptions, { nodb: true }); - let err: Error; + let err!: Error; try { await evaluate('throw new TypeError("Oh no, types!")'); } catch (e: any) { @@ -396,7 +396,7 @@ describe('worker-runtime', function () { await init('mongodb://nodb/', dummyOptions, { nodb: true }); - let err: Error; + let err!: Error; try { await evaluate( 'throw Object.assign(new TypeError("Oh no, types!"), { errInfo: { message: "wrong type :S" } })' @@ -430,7 +430,7 @@ describe('worker-runtime', function () { const { init, evaluate } = caller; await init('mongodb://nodb/', dummyOptions, { nodb: true }); - let err: Error; + let err!: Error; try { await Promise.all([ @@ -665,7 +665,7 @@ describe('worker-runtime', function () { await init('mongodb://nodb/', dummyOptions, { nodb: true }); - let err: Error; + let err!: Error; try { await Promise.all([ @@ -695,7 +695,7 @@ describe('worker-runtime', function () { await init('mongodb://nodb/', dummyOptions, { nodb: true }); - let err: Error; + let err!: Error; try { await Promise.all([ diff --git a/packages/node-runtime-worker-thread/tsconfig.test.json b/packages/node-runtime-worker-thread/tsconfig.test.json deleted file mode 100644 index 3676cf085..000000000 --- a/packages/node-runtime-worker-thread/tsconfig.test.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "@mongodb-js/tsconfig-mongosh/tsconfig.test.json", - "ts-node": { - "files": true - }, - "compilerOptions": { - "outDir": "./lib", - "allowJs": false - }, - "files": ["./src/index.d.ts"] -}