Repository navigation
perf(typecheck): keep typecheck's incremental state apart from the build's - #39
Merged
Merged
Conversation
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.
Why
A module created from this template should spend as little time as possible on install, build, test, start and reload (ANT-1957, the second wave of the org-wide perf pass).
typecheck(tsc --noEmit) and the compiles ofpnpm buildandpnpm test(tsc --skipLibCheck) shared one incremental state file,dist/.tsbuildinfo. Each run overwrote it with different options. Atypecheckthat ran after a test or a build found the--skipLibCheckstate, so it checked every declaration file again. That happens on everypnpm run checksafter the first and on every pre-push hook after a test.Summary
typechecknow keeps its own state file with--tsBuildInfoFile node_modules/.cache/typecheck/.tsbuildinfo, next to thetsconfig.config.jsoncache already innode_modules/.cache. It checks the same program with the same options, so the diagnostics stay the same. A cached error still fails the next run.tscitself invalidates the file from file hashes and options.pnpm buildandpnpm testkeepdist/.tsbuildinfo.antelopejs-sync --checkaccepts the script.Readability cost: one flag on the
typecheckscript.Workload and numbers
The numbers come from a module created with
ajs module init --template "Module Typescript" --pm pnpmthroughantelopejs-verify, thenpnpm install --frozen-lockfile, from current main. Node 24.22.2, pnpm 10.6.5, on a shared 16-core server.pnpm run checks, repeated, before and after alternatingpnpm typecheckright afterpnpm testA second interleaved run of
checkson a module that already had thenpxfix (#38) gave the same picture: median 3032 ms (2912 to 3480) before, 2209 ms (2143 to 2486) after. The firsttypecheckon a fresh clone still pays the full check, about 1.46 s, as before.Evidence level: confirmed through end-to-end benchmarks. Impact: Medium. It saves about 0.7 to 0.9 s on each
pnpm run checksafter the first, a 22 to 27% cut, and about 0.9 s on each pre-push hook that follows a test or a build.Correctness check: with
export const bad: number = "x";appended tosrc/index.ts, twopnpm typecheckruns in a row both fail withTS2322, and the run after the fix passes.Related issue
ANT-1957.
@antelopejs/tooling-configswritestypecheck: "tsc --noEmit"as its default script, so other templates that also build with--skipLibChecklikely pay the same cost. That belongs in tooling-configs, not here.Verification
pnpm run checks:Checks: 12 passed, 0 failed.antelopejs-verify journey <run> --plan: every journey passes,tooling/scaffold-lint-rejects(an unused local still failstypecheck) andtooling/scaffold-checksincluded.Checklist
scaffold-lint-rejectsandscaffold-checkscover it.typecheckcommand line.