tsgo never terminates on a single three.js TSL method call (works in 5.9.3 and 6.0.3)
Steps to reproduce
Three lines, two dependencies, no framework, no bundler.
mkdir repro && cd repro
npm init -y && npm pkg set type=module
npm i [email protected] @types/[email protected]
repro.ts
import { vec3 } from "three/tsl"
export const v = vec3(1, 2, 3).mul(2)
tsconfig.json
{
"compilerOptions": {
"strict": true,
"noEmit": true,
"module": "ESNext",
"moduleResolution": "bundler",
"skipLibCheck": true
},
"include": ["repro.ts"]
}
npx tsgo --noEmit -p tsconfig.json
Behavior with [email protected]
Completes in 0.33s / 0.32s (two runs), exit 0, no errors. The expression infers to Node<"vec3"> — confirmed by adding export const w: string = v, which correctly reports TS2322: Type 'Node<"vec3">' is not assignable to type 'string'.
[email protected] is identical: 0.36s / 0.33s, exit 0.
Behavior with tsgo
Never terminates. Killed at 60s in the measurements below.
Against a larger real project the same thing was still running after ~6 minutes of wall time, having consumed ~11m46s of CPU time, peaking at 769% CPU and 8.6 GB RSS (51.8% of system memory), with no diagnostic output.
Reproduced on both 7.0.2 and 7.1.0-dev.20260802.1 (latest dev at time of filing).
Isolation
The trigger is a single method call on a TSL node. Removing .mul(2) — keeping the same import and the same vec3(...) call — makes tsgo the fastest of the three:
repro.ts body |
5.9.3 | 6.0.3 | 7.0.2 |
|---|---|---|---|
export const v = vec3(1, 2, 3).mul(2) |
0.36s ✅ | 0.33s ✅ | hangs (killed at 60s) |
export const v = vec3(1, 2, 3) |
0.31s ✅ | — | 0.07s ✅ |
export const t = typeof vec3 (import only) |
0.28s ✅ | — | 0.07s ✅ |
So it is not the size of @types/three, not module resolution, and not the import itself — --traceResolution output is identical between the passing and hanging cases, and both resolve to @types/[email protected]'s src/nodes/tsl/TSLCore.d.ts.
Also ruled out by direct experiment in this same clean repro: tsconfig options (types, lib, isolatedModules, and a full real-world option set all behave the same), the presence of @webgpu/types, and the presence of a bundler (vite) in node_modules.
Scale is not the issue either — one .mul() is enough. A file with 40 chained calls behaves no differently from one with a single call.
Why this may matter beyond one library
.mul() is not an unusual style — it is the only way to express arithmetic in three.js's node shading language, used by its WebGPU renderer. There is no alternative spelling, and the official WebGPU examples use it throughout. Any TypeScript project on that renderer will hit this on its first arithmetic expression.
Possibly related
- microsoft/TypeScript#63783 — unbounded memory consumption with recursive conditional types (matches the 8.6 GB observation)
- microsoft/TypeScript#63845 — recursive conditional + mapped type regression, native-only, "Stable [email protected]: OK"
Side observation (already tracked as microsoft/TypeScript#63856)
While reducing this, timeout 180 had no effect — the process ignores SIGTERM and requires SIGKILL. Mentioning it here only because it compounds this bug's impact: a CI job or editor-adjacent process that appears to have been cancelled is in fact still running and still allocating.
Environment
tsgo: 7.0.2 and 7.1.0-dev.20260802.1
tsc: 6.0.3 and 5.9.3 (both passing baselines)
three: 0.185.1
@types/three: 0.185.0
OS: macOS 27.0 (26A5388g)
arch: arm64 (Apple Silicon)
node: v26.5.0
I'm guessing the problem is here, where a conditional type is used where a lookup type would be massively better https://github.com/DefinitelyTyped/DefinitelyTyped/blob/0e741bfcf3c6104a22811f639cc004abb759bec9/types/three/src/nodes/tsl/TSLCore.d.ts#L1554-L1593
Looks related to (if not a duplicate of) microsoft/typescript-go#4528.
Yep. Sent a DT PR
Confirming this same root cause at real-world scale, and confirming the @types/[email protected] fix resolves it completely — posting in case it's useful evidence for anyone still hitting this.
Setup: [email protected], @types/[email protected] (pre-fix), @react-three/[email protected], @react-three/[email protected], macOS arm64. A ~460-line internal barrel module re-exports ~90 named symbols from ~45 sibling .ts/.tsx files (camera framing, lighting, labels, post-processing wrappers around R3F/three — a typical "scene toolkit" package). One of those siblings imports the TSL postprocessing display nodes from three/examples/jsm/tsl/display/* (BloomNode, DepthOfFieldNode, GTAONode, DenoiseNode, TRAANode, SMAANode, FXAANode, SSRNode, SSSNode, MotionBlur) — the same Node<TNodeType> pattern as the repro here.
Bisecting the barrel's export statements: importing a single name from the barrel is enough to reproduce. Removing just the one re-export line that (transitively) pulls in the TSL display-node chain takes it from EXPLODES back to OK — everything else held constant:
| compiler | with @types/[email protected] |
with @types/[email protected] |
|---|---|---|
[email protected] |
OK — 4s / ~600MB | OK — 4s / ~600MB |
[email protected] (stable) |
killed at 6GB cap, 46s, still climbing (~130MB/s) | OK — ~2s / ~17MB |
[email protected] (nightly) |
killed at 6GB cap, 45–77s, still climbing | OK — ~2s / ~17MB |
Same result at the full barrel scope (all ~90 re-exports, ~1150 total files in the program once three's own type surface is pulled in): bounded (~17MB/2s) with 0.185.2, unbounded with 0.185.0.
So: fully confirmed fixed by the @types/[email protected] Node<TNodeType> refactor — thank you for tracking this down. Leaving this note mainly because the trigger isn't limited to the minimal vec3(...).mul(2) repro; it's equally hit by importing the TSL postprocessing display nodes (three/examples/jsm/tsl/display/*), which is a common path for anyone doing WebGPU post-fx (bloom/AO/TAA/SSR/etc.) through three.js — and it only takes one such import anywhere in a project's dependency graph to take the whole tsc --noEmit from seconds to an OOM kill. Anyone still seeing this should check they're on @types/[email protected]+.
Also noting for the record (already covered in microsoft/typescript-go#4612, just reconfirming it applies here too): GOMEMLIMIT was not honored during the runaway allocation and there's no default heap ceiling on tsgo, so on an unpatched @types/three this fails as a multi-GB OOM/kill rather than a bounded error the way tsc would degrade.