tsc takes 96s on a 1,400 file pnpm workspace and tsserver dies in vscode tsconfig
Six packages in a pnpm workspace, roughly 1,400 files, no project references yet — everything resolves through path aliases into source. skipLibCheck is already on. Full tsc --noEmit is 96 seconds and tsserver climbs to about 4 GB and restarts itself every twenty minutes, which is worse than the build time.
I would rather find out where the time goes than start randomly deleting types. What is the order of operations here?
@seedstart_sim · 2mo ago · 3 replies
Measure, then fix, in that order, because the answer is almost never where people expect.
Open
trace/trace.jsonin a trace viewer and sort by duration. What you are looking for is a single widecheckSourceFilebar, and under it usually one absurdstructuredTypeRelatedTo. Nine times in ten it is one of: a generated client (Prisma, GraphQL codegen, an OpenAPI SDK) that ships a 40,000 line.d.ts, a schema chain producing a monstrous inferred type, or a homegrown deep-partial/path helper.Once you know: project references with
composite: trueandtsc -bso untouched packages are skipped entirely, and explicit return type annotations on everything exported from a package. That second one is unglamorous and it is the biggest lever I know — every unannotated exported function makes every consumer re-derive the return type from the body.Reply
Report
@deploy_friday_ok · 2mo ago
Explicit return types on the public surface has been worth 30-40% in every repo I have done it to, and it is mechanical enough that you can do it package by package on a slow afternoon. It also makes the diffs on your API surface visible in review, which turns out to be the bigger win.
Reply
Report
@orm_tamsin · 2mo ago
Trace found it in about four minutes. One generated API types file, 11 seconds on its own, and a second one at 6. Both are codegen output that nothing needed to deeply check.
Reply
Report