October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

Why `tsc –incremental` Made One TypeScript Hook 3.6× Slower, and the 200 KB Cache Threshold That Fixed It

One author's post-tool TypeScript hook ran 3.6× slower with --incremental on a cold run. Here is where the cost comes from, a portable size guard, and how to measure your own 200 KB-style threshold.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Adding --incremental to a TypeScript check in a post-tool hook made the cold run about 3.6× slower in one author’s project. Their fix was a guard: if the existing .tsbuildinfo file is larger than 204,800 bytes (200 × 1024), the hook skips incremental state and runs a plain tsc --noEmit. That threshold is specific to their closet-os repository, and the result is one author’s report from 2026, not a general TypeScript performance rule. What follows explains where the cost comes from, how to reproduce the measurement on your own project, and how to build a guard that matches your setup.

What the author measured

The author ran a TypeScript type check from a Claude Code post-tool hook, which runs after the assistant edits a file. Their first change was to add --incremental, which made cold runs (runs with no prior build state) about 3.6× slower on the closet-os project. The author attributes the slowdown to the work of generating and reading the .tsbuildinfo state file.

As an Amazon Associate I earn from qualifying purchases.

Three limits apply to this result. The write-up does not publish a full benchmark table, the compiler version used, or the machine specification. It is also a single project, so it shows that the slowdown happened there, not how large it will be elsewhere. The author explicitly recommends measuring your own crossover point rather than copying the 200 KB figure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What .tsbuildinfo is and why it costs time

The incremental compiler option saves project-graph information from a previous compilation so that later builds can find a cheaper way to type-check and emit only what changed. The TypeScript 3.4 release notes describe it in exactly those terms. The saved state lives in a .tsbuildinfo file. The official incremental TSConfig documentation states that these files are not used by your JavaScript at runtime and can be safely deleted, and that tsBuildInfoFile controls where they are written.

Why the first run can be slower

Incremental mode does bookkeeping before it can save any time. The compiler has to record the state it will need later, and that work is paid on the run that creates the file. The TypeScript 4.3 release notes say this directly: incremental and watch modes may require initial bookkeeping and can make an initial build slower in some cases. The same notes describe later changes that defer some calculations and reduce cache size in particular examples. Those changes are version-specific, so the timing profile you see on a current compiler may differ from the one the author measured.

Why the file size matters

A larger .tsbuildinfo generally means more state to write on each save and more to read on each load. That is why the author used file size as a proxy for the point where the overhead stops paying off. Size is a practical signal, not a direct measure of speed. Two projects with the same file size can behave differently if their file counts, type graphs, or edit patterns differ.

Rank #2
TypeScript Programming Language - Software Engineer & Coder T-Shirt
  • TypeScript implements a superset of syntax for strictly typed development, facilitating deep static analysis and enhanced development environment integration. The compiler translates source into standard script formats, ensuring parity across any runtime.
  • TypeScript is ideal for front-end developers, full-stack engineers, and software architects who build large-scale web applications. It serves those looking to improve code excellence, reduce bugs through static checking, and maintain complex projects more.
  • Lightweight, Classic fit, Double-needle sleeve and bottom hem

The guard the author describes

The hook stores build state in a dedicated file under node_modules/.cache, passes its path with --tsBuildInfoFile, and checks the file size before choosing a command. The steps are:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Set the build-info path, for example node_modules/.cache/tsc/tsconfig.tsbuildinfo, so the state file sits outside your source tree.
  2. Read the file’s size in bytes. The author uses stat -f %z, which is the macOS form. On Linux, GNU stat -c %s is the equivalent; a portable option is wc -c, shown below.
  3. If the file is absent or at or below 204,800 bytes, run tsc --noEmit --incremental --tsBuildInfoFile with that path.
  4. If the file is larger than the limit, run plain tsc --noEmit.
  5. Let the hook exit with the status of the type-check command, not of a later logging step.
#!/bin/sh
BUILDINFO=node_modules/.cache/tsc/tsconfig.tsbuildinfo
LIMIT=204800

if [ -f "$BUILDINFO" ] && [ "$(wc -c < "$BUILDINFO" | tr -d ' ')" -gt "$LIMIT" ]; then
  npx tsc --noEmit
else
  npx tsc --noEmit --incremental --tsBuildInfoFile "$BUILDINFO"
fi

This sketch is the author’s approach adapted to a portable size check. Test it on each operating system and shell where the hook runs. One behavior to plan for: once the file exceeds the limit on the fallback path, nothing refreshes it, so the hook stays on plain checks until you delete the file. Deleting it is safe, as the official documentation notes, and it lets the next run create a fresh state file.

Exit codes in pipelines

The author reports a pipeline problem in which the captured status did not reflect the type-check result. In a POSIX shell, a pipeline’s exit status is that of its last command unless set -o pipefail is enabled, which is not part of every shell. If you pipe tsc output to a log file or a formatter, check the status of tsc itself, for example by writing its output to a file first and then testing its exit code.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How to measure your own crossover

Run the four cases below on the same repository, the same compiler version, and the same machine, with the same hook environment. Repeat each timing several times and use the median. Keep a record of the .tsbuildinfo size after each run, measured with wc -c.

Case Command state before the run What to record
Ordinary check No build-info file used; run tsc --noEmit Elapsed time only
Cold incremental Build-info file deleted; run with --incremental --tsBuildInfoFile Elapsed time and resulting file size
Warm incremental, no edits Build-info file from the previous run; no source changes Elapsed time and file size
Warm incremental, one edit Build-info file from the previous run; change one representative source file Elapsed time and file size

Compare the cold incremental time with the ordinary check to see the first-run penalty. Compare the warm cases with the ordinary check to see whether the saved state pays off in your normal workflow. Your crossover is the file size at which the warm time stops beating the ordinary check by enough to justify the cold cost. Set your threshold from that data, not from 200 KB.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Compiler and platform caveats

  • Record the exact TypeScript version with npx tsc --version. The release-note points above describe different versions, and later changes may alter both timing and cache size.
  • Note whether your project uses project references or a custom tsBuildInfoFile path, because either changes what the file contains.
  • Keep the hook’s environment the same as your measurement environment. A hook run from an editor may have a different working directory, PATH, or Node version than your terminal.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.