microsoft / microsoft/TypeScript

Performance regression for declaration emit of an oversized inferred type

Abierto
#63,966 3 comentarios 10 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavΓ­a.

Possible Improvement
Lenguaje dominante
Go
Estrellas
111k
Forks
14.3k
Merge medio
2 d 4 h
PR fusionados (30 d)
132

DescripciΓ³n

πŸ”Ž Search Terms

TS7056 memory, declaration emit OOM, "inferred type of this node exceeds the maximum length", DeepCloneNode serializedTypes, NodeBuilder declaration emit memory, typescript-go TS7056 RSS

πŸ•— Version & Regression Information
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about declaration emit and large inferred types
  • Reproduced on 7.1.0-dev (main, ./built/local/tsc) vs TypeScript 6.0.3 (./node_modules/typescript/bin/tsc). Both report the same TS7056 and emit no .d.ts. The Go compiler uses ~6Γ— the memory and is 5.8x slower.
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ version              β”‚ peak RSS β”‚ wall   β”‚ result           β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 5.9.3                β”‚ 0.51 GB  β”‚ 0.97 s β”‚ TS7056, no .d.ts β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 6.0.3                β”‚ 0.41 GB  β”‚ 0.66 s β”‚ TS7056, no .d.ts β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 7.0.0-dev.20260707.2 β”‚ 2.38 GB  β”‚ 3.68 s β”‚ TS7056, no .d.ts β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 7.0.1-rc             β”‚ 2.25 GB  β”‚ 3.51 s β”‚ TS7056, no .d.ts β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ 7.0.2                β”‚ 2.25 GB  β”‚ 3.49 s β”‚ TS7056, no .d.ts β”‚
  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
  β”‚ main 7.1.0-dev       β”‚ 2.42 GB  β”‚ 3.41 s β”‚ TS7056, no .d.ts β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
⏯ Playground Link

N/A

πŸ’» Code
let x0 = { v: 1 };
let x1 = { a: x0, b: x0, c: x0 };
let x2 = { a: x1, b: x1, c: x1 };
let x3 = { a: x2, b: x2, c: x2 };
let x4 = { a: x3, b: x3, c: x3 };
let x5 = { a: x4, b: x4, c: x4 };
let x6 = { a: x5, b: x5, c: x5 };
let x7 = { a: x6, b: x6, c: x6 };
let x8 = { a: x7, b: x7, c: x7 };
let x9 = { a: x8, b: x8, c: x8 };
let x10 = { a: x9, b: x9, c: x9 };
let x11 = { a: x10, b: x10, c: x10 };
let x12 = { a: x11, b: x11, c: x11 };
let x13 = { a: x12, b: x12, c: x12 };
export const y = x13;
/usr/bin/time -l tsc --declaration repro.ts
πŸ™ Actual behavior

Both compilers:

repro.ts(15,14): error TS7056: The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed.

Measured on macOS with /usr/bin/time -l:

compiler peak RSS wall
Go tsc 7.1.0-dev 2.48 GB 3.5 s
JS tsc 6.0.3 0.41 GB 0.6 s

In a limited environment, or with a larger repro, this will cause the process to OOM.

πŸ™‚ Expected behavior

Go tsc should report the same TS7056 error without using extra memory and being slower.

Additional information about the issue

Disclosure: This memory issue was found with a differential memory harness (Go tsc vs JS tsc 6.0.3) and AI assistance (Kimi K3). Verified by hand against TypeScript 7.1.0-dev (main) and TypeScript 6.0.3.

GuΓ­a de contribuciΓ³n

Abrir la guΓ­a de contribuciΓ³n

Primeros pasos

  1. Lee el issue completo y luego la guΓ­a de contribuciΓ³n del proyecto.
  2. Comenta en el issue que vas a ocuparte β€” evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al nΓΊmero del issue.

LΓ­nea de trabajo

Empieza ejecutando el repro.ts proporcionado con declaration emit y comparando Go tsc con el compilador de JavaScript mediante el comando time mostrado. DespuΓ©s, inspecciona la ruta de declaration emit alrededor de NodeBuilder, serializedTypes y DeepCloneNode. Se considera terminado cuando el compilador de Go sigue informando de TS7056, pero evita el uso adicional de memoria y la ralentizaciΓ³n indicados.

Escrito por el modelo de indexaciΓ³n a partir del texto del issue.

EvaluaciΓ³n

Stack tecnolΓ³gico
go, typescript
Área
compilers, performance
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 dΓ­as
Estado de actividad
Activo
Claridad
Bastante claro
Aptitud para principiantes
48/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.