Skip to content

chore: cover test files in default tsconfig#34

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

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

Conversation

@ungoldman

Copy link
Copy Markdown
Owner

Makes the default-named tsconfig.json cover both src and test so the editor's TS language server resolves test files correctly.

The editor walks up from a test file to the default-named tsconfig.json. That was the build config with include: ["src"], so test files dropped into an inferred project with no @types/node and wrong module settings, producing spurious errors (Cannot find name 'node:assert/strict', Property 'dirname' does not exist on type 'ImportMeta'). typecheck was clean only because it explicitly passed -p tsconfig.test.json, which the editor never auto-discovers.

Changes

  • tsconfig.json: now the editor/typecheck config. Standalone, include: ["src", "test"], noEmit: true, rootDir: ".", types: ["node"], allowImportingTsExtensions: true. Inlines the compiler options previously inherited by the test config; drops emit-only options.
  • tsconfig.build.json (new): extends: "./tsconfig.json", include: ["src"], restores emit settings (outDir, rootDir: "src", declaration, noEmit: false, allowImportingTsExtensions: false).
  • tsconfig.test.json: removed (folded into tsconfig.json).
  • package.json: build -> tsc -p tsconfig.build.json; typecheck -> tsc.

Verification

  • npm run build: emits dist/index.d.ts + dist/index.js only, byte-identical to the origin/main build (diff clean against a fresh baseline clone). No test files emitted.
  • npm run typecheck: passes; tsc -p tsconfig.json --listFilesOnly now includes test/index.test.ts.
  • npm test: lint clean, 10 tests pass.

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

Flip which config is default: tsconfig.json now covers src and test
under noEmit (the editor/typecheck config), and tsconfig.build.json
carries the emit settings for the package build. tsconfig.test.json
is removed. Emitted dist is byte-identical to before.
@ungoldman
ungoldman merged commit e8c825f 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