Skip to content

test: fail CI when the type-level parser gets more expensive - #222

Merged
tiagolauer merged 1 commit into
fix/pin-typescript-5from
feat/type-instantiation-budget
Jul 28, 2026
Merged

test: fail CI when the type-level parser gets more expensive#222
tiagolauer merged 1 commit into
fix/pin-typescript-5from
feat/type-instantiation-budget

Conversation

@tiagolauer

Copy link
Copy Markdown
Owner

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 tsc do three times the work, and nothing in CI would notice. tests/depth.test-d.ts checks correctness, not cost.

npm run test:perf generates a fixture of 100 tables and 32 queries (joins, GROUP BY, CASE, CTEs, UNION, strict mode, 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'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.

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
tiagolauer force-pushed the feat/integration-tests branch 2 times, most recently from 67c7170 to 9957dda Compare July 28, 2026 17:03
@tiagolauer
tiagolauer force-pushed the feat/type-instantiation-budget branch from fe6f421 to f8069f9 Compare July 28, 2026 17:03
Base automatically changed from feat/integration-tests to fix/pin-typescript-5 July 28, 2026 17:08
@tiagolauer
tiagolauer merged commit b597e68 into fix/pin-typescript-5 Jul 28, 2026
9 checks passed
@tiagolauer
tiagolauer deleted the feat/type-instantiation-budget branch July 28, 2026 17:08
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