Skip to content

chore: cover test files in default tsconfig#58

Merged
ungoldman merged 1 commit into
mainfrom
ng-tsconfig-editor-coverage
Jun 14, 2026
Merged

chore: cover test files in default tsconfig#58
ungoldman merged 1 commit into
mainfrom
ng-tsconfig-editor-coverage

Conversation

@ungoldman

Copy link
Copy Markdown
Owner

What this does

Makes the auto-discovered tsconfig.json cover both src and test, so the VS Code TS language server type-checks test files correctly.

The editor walks up from a test file and resolves the default-named tsconfig.json. That was the build config (include: ["src"]), so test files fell outside the include and landed in an inferred project with no @types/node and wrong module settings, producing spurious errors on test files (e.g. Cannot find name 'node:assert/strict'). npm run typecheck was clean only because it explicitly passed -p tsconfig.test.json, which the editor never auto-discovers.

This flips which config is the default: tsconfig.json becomes the editor/typecheck config covering src and test, and a new tsconfig.build.json emits dist from src only. The published package is byte-identical.

Changes

  • tsconfig.json is now standalone (no extends): include: ["src", "test"], noEmit, rootDir: ".", types: ["node"]. Inlines the compiler options the test config used to inherit; emit-only options moved to the build config.
  • New tsconfig.build.json: extends: "./tsconfig.json", include: ["src"], overrides noEmit: false, rootDir: "src", outDir: "dist", declaration: true. Emits exactly what the old tsconfig.json did.
  • Delete tsconfig.test.json (folded into tsconfig.json).
  • package.json scripts: build -> tsc -p tsconfig.build.json; typecheck -> tsc.

Verification

  • npm run build -> same four dist files as before (index/factory, .js + .d.ts), all byte-identical, no test files emitted.
  • npm run typecheck -> passes; tsc -p tsconfig.json --listFilesOnly now includes test/index.test.ts.
  • npm test -> 13 passing.
  • npm run test:pack -> runtime import + type resolution ok.

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.
@ungoldman ungoldman merged commit b1f667d into main Jun 14, 2026
3 checks passed
@ungoldman ungoldman deleted the ng-tsconfig-editor-coverage branch June 14, 2026 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant