test: fail CI when the type-level parser gets more expensive - #222
Merged
Conversation
The parser is recursive template literal types, so the cost that reaches users is compile time. A passing type test says nothing about it: a change can keep every inference correct while making tsc do three times the work, and nothing in CI would notice. npm run test:perf generates a fixture of 100 tables and 32 queries covering joins, GROUP BY, CASE, CTEs, UNION, strict mode and typed params, type-checks it with tsc --extendedDiagnostics, and fails when the instantiation count goes over budget. Instantiations rather than wall-clock time, because they are deterministic: the same input on the same TypeScript version gives the same number on any machine, which makes a hard threshold possible instead of a flaky one. That is also why this job pins the lockfile's TypeScript instead of running the whole supported matrix. Current baseline is 166512 against a budget of 185000. Raising the budget is expected when a feature genuinely costs more; doing it in the same commit keeps the new baseline in front of a reviewer instead of drifting.
tiagolauer
force-pushed
the
feat/integration-tests
branch
2 times, most recently
from
July 28, 2026 17:03
67c7170 to
9957dda
Compare
tiagolauer
force-pushed
the
feat/type-instantiation-budget
branch
from
July 28, 2026 17:03
fe6f421 to
f8069f9
Compare
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.
Second of four. Stacked on #221.
The parser is recursive template literal types, so the cost that reaches users is compile time — and a passing type test says nothing about it. A change can keep every inference correct while making
tscdo three times the work, and nothing in CI would notice.tests/depth.test-d.tschecks correctness, not cost.npm run test:perfgenerates a fixture of 100 tables and 32 queries (joins,GROUP BY,CASE, CTEs,UNION, strict mode, typed params), type-checks it withtsc --extendedDiagnostics, and fails when the instantiation count goes over budget.Instantiations rather than wall-clock time because they're deterministic: same input, same TypeScript version, same number on any machine. That makes a hard threshold possible instead of a flaky one, and it's why the job pins the lockfile's TypeScript instead of running the whole matrix.
Baseline is 166512 against a budget of 185000. Cost is linear with a fixed overhead — 32 queries measured 166512, 64 measured 237044, so roughly 96k for the schema plus 2.2k per query. I checked the guard actually goes red by dropping the budget to 100k.
Raising the budget when a feature genuinely costs more is expected; doing it in the same commit keeps the new baseline in front of a reviewer.