chore: cover test files in default tsconfig#34
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes the default-named
tsconfig.jsoncover bothsrcandtestso 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 withinclude: ["src"], so test files dropped into an inferred project with no@types/nodeand wrong module settings, producing spurious errors (Cannot find name 'node:assert/strict',Property 'dirname' does not exist on type 'ImportMeta').typecheckwas 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 intotsconfig.json).package.json:build->tsc -p tsconfig.build.json;typecheck->tsc.Verification
npm run build: emitsdist/index.d.ts+dist/index.jsonly, byte-identical to theorigin/mainbuild (diff clean against a fresh baseline clone). No test files emitted.npm run typecheck: passes;tsc -p tsconfig.json --listFilesOnlynow includestest/index.test.ts.npm test: lint clean, 10 tests pass.