Our type checker reads 2,980 files to check 495 of ours, and the Stripe SDK's types are 1.7 times the size of our whole app
The repository behind pub-trivia.app type checks cleanly. tsc --noEmit exits 0, and I have been saying "the types are fine" for months without ever asking what the compiler is reading when it says so. This week the depen
The repository behind pub-trivia.app type checks cleanly. tsc --noEmit exits 0, and I have been saying "the types are fine" for months without ever asking what the compiler is reading when it says so. This week the dependency bump landed TypeScript 6.0.3 alongside Next 16.4, which gave me a reason to open it up.
Two flags do all the work: --extendedDiagnostics, which prints the cost, and --listFilesOnly, which prints the inputs. Everything below comes from running them on the app's root tsconfig.json, on a laptop, with Node 24.
The headline numbers
Files: 2,980
Lines of TypeScript: 68,262
Lines of Library: 59,129
Lines of Definitions: 458,018
Lines of JavaScript: 0
Identifiers: 624,683
Types: 140,418
Instantiations: 536,203
Memory used: 895 MB
Parse time: 0.71 s
Check time: 3.98 s
Total time: 5.86 s
Our own code is 68,262 lines. The definitions the compiler reads on the way to understanding that code are 458,018. That is a ratio of 6.7 to 1, and it is the number that shapes everything else here: the type checker spends its life reading other people's declarations.
2,980 files, 495 of them ours
I filtered the file list into two buckets: paths inside the repository and outside node_modules, and everything else. Ours is 495 files, or 16.6 per cent of what the compiler opens. Broken down by top level directory:
app 218
components 126
utils 47
ws-server 32
lib 27
__tests__ 26
.next 7 (generated route types)
everything else 12
Two things stand out. First, ws-server is in the list. The root tsconfig.json includes **/*.ts, so the web app's type check also reads the standalone server package's 32 files. That package has its own tsconfig.json and its own tsc build, which finishes in 1.2 seconds and reads a much smaller program. Nothing is wrong here, but it does mean a type error in that package can fail the root check, and the same file gets checked twice under two different sets of options.
Second, .next/types contributes seven generated files. The include list names .next/types/**/*.ts and .next/dev/types/**/*.ts, and on a fresh clone with no build both directories are empty. The config is written for a state that only exists after next dev or next build has run.
Who owns the other 2,485 files
I measured the line count of every file the compiler lists and grouped by package. These are the biggest:
package files lines
stripe 228 115,389
typescript (libs) 89 59,040
@types/node 82 52,449
next 358 41,421
drizzle-orm 600 37,562
lucide-react 1 32,373
csstype 1 24,113
@sentry/core 259 13,506
lightningcss 3 10,506
ioredis 21 9,928
The Stripe SDK's declarations are 115,389 lines, which is 1.7 times everything we wrote. The SDK ships one declaration per API resource and per parameter object, and we touch a handful of them: a checkout session, a subscription, a webhook event. The compiler reads all of them, because TypeScript follows imports to a package's entry point and the entry point re-exports the world.
lucide-react is the opposite shape: one file of 32,373 lines, a type declaration for every icon in the set. next.config.mjs has optimizePackageImports for it, which helps the bundler, and does nothing for the type checker, which reads the whole declaration regardless of how many icons we import.
drizzle-orm is 600 files in 37,562 lines, a different pattern again: lots of small files, which is where parse time goes.
I counted 113 distinct packages contributing files. The top ten above add up to about 396,000 lines, out of 517,000 for the compiler's library and definition lines together.
Warm is 2.4 seconds, cold is 6.5
tsconfig.json sets incremental: true, and a tsbuildinfo file is written next to it. It is 847,593 bytes, and .gitignore covers *.tsbuildinfo, so it is never committed. I timed three runs each way:
without incremental: 6.42 s 6.58 s 6.52 s
with incremental: 6.61 s 2.44 s 2.46 s
The first incremental run pays the full price and writes the file. The next two take 2.4 seconds, which is 63 per cent less, with nothing changed. The caveat in that figure is the last three words. A warm run with no edits is the best case, and the real number for an edit-and-check loop sits between 2.4 and 6.5 depending on how far the change ripples.
The two methods agree where they should: both exit 0, and both read the same 2,980 files. Incremental mode saves the checking, not the reading. The reading is what the next section is about.
The flag that does nothing
allowJs: true is in our config. The diagnostics say Lines of JavaScript: 0. There is no JavaScript in the program, so the flag has no effect on it.
I would have guessed this was a leftover from the template that created the project, and I think it is, but I cannot prove it from the tree. The practical consequence of removing it would be that a stray .js file added later stops being type checked, which is mostly an argument for deleting it and discovering that the build breaks.
Equally, target: "ES2017" is quite conservative for a project whose lib is esnext and whose server runs on Node 24. The compiler does not emit anything here (noEmit: true), so the target only changes which syntax the checker will accept without an error, and I would expect nothing to change if it moved. I did not change it, because I did not measure it, and that is the honest summary of this paragraph.
What I would do about the 2,980
Nothing, mostly. 6.5 seconds cold and 2.4 warm for a 68,000 line application is not a problem, and skipLibCheck: true is already on, which is the flag that stops the compiler from checking those 458,000 definition lines for internal errors. It still has to parse them, and the 0.71 second parse time is that cost.
The one change I would consider is splitting the include so that the web app's check does not walk into ws-server, which already has its own build. That would cut 32 files from a program of 2,980 and save very little time. The reason to do it is the duplicate check, not the speed.
Run it on your own repo
You need two commands, and a few lines of scripting to group the output by package:
npx tsc --noEmit --extendedDiagnostics --incremental false
npx tsc --noEmit --listFilesOnly
The first number to look at is the ratio of Lines of TypeScript to Lines of Definitions. Ours is 1 to 6.7. If yours is much lower, you probably have a dependency with a small footprint and a lot of your own code, and if it is much higher, one package is probably dominating, and --listFilesOnly will say which.
If you want to see what all those lines are type checking, the app is live: the homepage has a demo you can play, the tools page holds the free utilities that run in your browser, and pricing shows the checkout the Stripe types are there for. The free tier needs no card.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.