From 874300e1ba9ff36b496eb8053b16d8af36050fbe Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 26 Oct 2026 12:16:54 -0700 Subject: [PATCH] Only pre-size the printer buffer when printing a whole file Write grew the writer by the full source file length for every call, including when printing a single type node for typeToString or the type baselines. Each resulting string then pinned a buffer the size of the file; for largeControlFlowGraph.ts the types baseline retained over 3GB this way, which exhausts the 4GB wasm address space. --- tsc/internal/printer/printer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsc/internal/printer/printer.go b/tsc/internal/printer/printer.go index a27452d51472d..46bb47c25ebad 100644 --- a/tsc/internal/printer/printer.go +++ b/tsc/internal/printer/printer.go @@ -5095,7 +5095,7 @@ func (p *Printer) Write(node *ast.Node, sourceFile *ast.SourceFile, writer EmitT } p.writer = writer p.writer.Clear() - if sourceFile != nil { + if sourceFile != nil && node == sourceFile.AsNode() { if grower, ok := p.writer.(interface{ Grow(n int) }); ok { grower.Grow(len(sourceFile.Text())) }