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

Đã đóng
#2,949 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@espetro đang làm issue này rồi.

Từ ngày 4/11/2026.

  • #2957 của @espetro — đang mở
  • #3016 của @ctate — đã merge
  • #3102 của @ctate — đã merge

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
node.js, typescript
Lĩnh vực
compilers

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
6.5k
Fork
212
Merge trung bình
13 giờ 46 phút
Pull request đã merge (30 ngày)
787

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của vercel-labs/scriptc

Tất cả issue của vercel-labs/scriptc

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.