build(internal): add test compilation check to package builds#5336
Merged
Conversation
Type-check test files during the build via a new `build:tests` script (`tsc --noEmit -p tests/tsconfig.json`) that runs in parallel with the ESM and CJS builds. This catches type errors in test files that were previously only surfaced at runtime. - Add `build:tests` to every package and wire it into `build` - Create the missing `tests/tsconfig.json` for jmespath - Fix pre-existing test type errors in commons and metrics Note: the `tests/tsconfig.json` files keep including `../src/**/*` because the configs inherit `composite: true`, which requires every file in the program to be listed (TS6307). closes #5073
Running `build:tests` in parallel within each package's `build` was unsafe: the test type-check resolves cross-package imports against each dependency's built `lib/`, but the workspace build order builds some dependencies (e.g. `testing`) after their consumers, and the parallel `&` also races a package's own emit build. Instead, keep the per-package `build:tests` script out of the regular `build` (so day-to-day builds stay fast and don't emit tests) and run it as a dedicated `Type check tests` step in the code-quality CI job, after dependencies have been installed and the whole workspace built.
Contributor
|
Can we add the check to the pre-commit hook so we don't have to wait until the CI fails if we forget to run it locally? |
Contributor
Author
Good point - added, but to |
svozza
approved these changes
Jun 12, 2026
|
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.



Summary
Changes
Package builds only compile source code under
src/; test files undertests/were never type-checked, so type errors in tests could go unnoticed until runtime. This PR adds a dedicated test type-checking step so those errors are caught in CI.build:testsscript added to each package (tsc --noEmit -p tests/tsconfig.json).build:testsis intentionally NOT wired into the regularbuild— day-to-day builds stay fast and never emit test files into the published bundle.Type check tests) in thecode-qualitymatrix job, after dependencies are installed and the whole workspace is built (so every package'slib/exists for cross-package import resolution).tests/tsconfig.jsonforjmespath(the only package without one).commons—deepMerge.property.test.ts(invaliddepthSizeonfc.arrayconstraints →size) anddeepMerge.test.ts(typed the result ofdeepMerge({}, source)).metrics—basicFeatures.decorator.test.functionCode.ts(made the decorated handlerasyncso it satisfiesHandlerMethodDecorator).Notes for reviewers
build:testsintobuildin parallel (& npm run build:tests). That is unsafe here: the test type-check resolves cross-package imports against each dependency's builtlib/, but the workspace build order builds some dependencies (e.g.testing) after their consumers, and the parallel&also races a package's own emit build. Running it as a separate CI step after the full build avoids the race entirely.../src/**/*fromtests/tsconfig.json. That cannot be done here: the configs inheritcomposite: true, which makes TypeScript enforce TS6307 ("Projects must list all files or use anincludepattern"). The source glob is kept (including in the newjmespathfile).rootDir: ./src+include: ["./src/**/*"],build:testsuses--noEmit, and it is not part of the regularbuild. Verified no test files land in anylib/output.npm run buildpasses, andnpm run build:tests -w <pkg>passes for every package after a full build.Issue number: closes #5073
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.