From 90b2be65bcbab7c97b265f2dfc90aef2ae8829e6 Mon Sep 17 00:00:00 2001 From: Nate Goldman <427322+ungoldman@users.noreply.github.com> Date: Sun, 14 Jun 2026 16:52:07 -0700 Subject: [PATCH] chore: cover test files in default tsconfig VS Code's TS server walks up from a test file to the default-named tsconfig.json, which was the build config (include: ["src"]). Test files fell outside that include and landed in an inferred project with no @types/node and wrong module settings, so the editor flagged spurious errors on test files (e.g. Cannot find name 'node:assert/strict'). typecheck was clean only because it passed -p tsconfig.test.json, which the editor never auto-discovers. Flip the defaults so the auto-discovered config covers both src and test: - tsconfig.json is now the editor/typecheck config: standalone, include ["src", "test"], noEmit, rootDir ".", types ["node"]. - tsconfig.build.json emits dist from src only (extends tsconfig.json, overrides noEmit/rootDir/outDir/declaration). Replaces the build options that used to live in tsconfig.json. - Drop tsconfig.test.json (folded into tsconfig.json). - build -> tsc -p tsconfig.build.json; typecheck -> tsc. Emitted dist is byte-identical to before. Verified: npm run build (same four dist files, no test files emitted), npm run typecheck (passes, now lists test/index.test.ts), npm test, npm run test:pack. --- package.json | 4 ++-- tsconfig.build.json | 10 ++++++++++ tsconfig.json | 10 +++++----- tsconfig.test.json | 9 --------- 4 files changed, 17 insertions(+), 16 deletions(-) create mode 100644 tsconfig.build.json delete mode 100644 tsconfig.test.json diff --git a/package.json b/package.json index 4d77959..e08a7fa 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "url": "git+https://github.com/ungoldman/hyperaxe.git" }, "scripts": { - "build": "tsc", + "build": "tsc -p tsconfig.build.json", "coverage": "node --test --experimental-test-coverage --import=tsx --test-coverage-exclude='test/**' --test-coverage-lines=100 --test-coverage-branches=100 --test-coverage-functions=100 test/*.test.ts", "format": "biome check --write .", "lint": "biome check .", @@ -63,7 +63,7 @@ "test": "npm run lint && npm run typecheck && npm run build && node --test --import=tsx test/*.test.ts", "test:pack": "bash scripts/test-pack.sh", "test:watch": "node --test --watch --import=tsx test/*.test.ts", - "typecheck": "tsc -p tsconfig.test.json" + "typecheck": "tsc" }, "sideEffects": false, "type": "module", diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000..7f9bdff --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": false, + "rootDir": "src", + "outDir": "dist", + "declaration": true + }, + "include": ["src"] +} diff --git a/tsconfig.json b/tsconfig.json index 9f6e466..c7437b3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,9 +6,7 @@ "allowSyntheticDefaultImports": true, "lib": ["es2022", "dom"], "allowJs": true, - "outDir": "dist", - "rootDir": "src", - "declaration": true, + "rootDir": ".", "strict": true, "esModuleInterop": true, "skipLibCheck": true, @@ -18,7 +16,9 @@ "noFallthroughCasesInSwitch": true, "noImplicitOverride": true, "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true + "resolveJsonModule": true, + "noEmit": true, + "types": ["node"] }, - "include": ["src"] + "include": ["src", "test"] } diff --git a/tsconfig.test.json b/tsconfig.test.json deleted file mode 100644 index badb66a..0000000 --- a/tsconfig.test.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "noEmit": true, - "rootDir": ".", - "types": ["node"] - }, - "include": ["src", "test"] -}