Assigning a wide Node object (process.stdout) to a narrow { write } record fails SC2002 (width-copy rules)

Abierto
#2,949 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@ctate ya está trabajando en esto.

Desde el 5/11/2026.

  • #2957 de @espetro — abierto
  • #3016 de @ctate — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
node.js, typescript
Área
compilers

Línea de trabajo

Start from the SC2002 diagnostic and the record-shape flow check that emits it, then reproduce with the minimal case: const sink: Sink = process.stdout where Sink is { write(s: string): void }. The open question is whether width-copy should accept this direction or whether the subset should document the wrapper adapter as the blessed pattern. Done means a maintainer-chosen behavior, with either a passing test for the accepted case or a docs entry for the adapter.

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

Descripción

Summary

Assigning process.stdout (a WriteStream) to a parameter/interface typed as a minimal { write(str: string): void } record fails with SC2002 "record shape flow outside the width-copy rules". The concrete Node type has many more members than the target record; the subset's record-flow rules refuse the width mismatch rather than copying the needed member.

Actual (scriptc 0.4.7)

interface Sink { write(s: string): void }
const sink: Sink = process.stdout; // SC2002

(Exact repro program available; compiled with scriptc build / compile() so the IR validator runs.)

Expected

Either:

  • structural acceptance when the target record's members are all present on the source type (width-copy in the safe direction), or
  • a documented seam: e.g. wrap the wide Node object in a narrow adapter (const sink: Sink = { write: (s) => process.stdout.write(s) }), if that is the blessed pattern it would help to say so in the subset docs.

Downstream evidence

T3 Code's ACP MCP stdio fast path wants to hand process.stdout to a helper typed as a minimal writer (AcpMcpStdioBridge.ts output: process.stdout). The wrapper workaround is cheap for us, so this is quality-of-life for the subset's ergonomics, not a blocker once we know the blessed shape.

Lenguaje dominante
TypeScript
Estrellas
6.4k
Forks
204
Merge medio
7 h 45 min
PR fusionados (30 d)
845

Preparar el entorno

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.

Más de vercel-labs/scriptc

Todos los issues de vercel-labs/scriptc

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.