Correct JavaScript refusal descriptions for mutable bindings and missing properties

Đang mở
#3,354 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

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

Từ ngày 7/11/2026.

  • #3356 của @MathurAditya724 — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
node.js, typescript

Hướng nghiên cứu

Read the refusal descriptions and preflight regression tests for TS2629, TS2630, and TS2739; the issue does not name their file paths. Start by running the existing preflight diagnostics for the four examples in the issue. Done when the descriptions accurately cover ordinary object shape and mutable declaration bindings, distinguish named function expression behavior, preserve diagnostic codes and admission decisions, and the regression tests exercise actual preflight diagnostics.

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

Mô tả

While compiling the full Sentry CLI and its JavaScript dependencies, several refusals describe different JavaScript behavior from the code being rejected. This makes it difficult to tell whether a dependency is invalid or scriptc needs additional lowering support.

This follows up on #3037 and #3039. Those were closed as fixed by #3112, but that PR's merged diff contains the regex change; these three descriptions are still unchanged on current main.

For example, save either example as example.mjs:

class Value {}
Value = class Replacement {};
console.log(Value.name);

Node prints Replacement. scriptc refuses the assignment and says the class binding is read-only and Node throws a TypeError (TS2629). A class declaration has a mutable outer binding; the class's inner binding is a separate immutable binding.

function value() { return 1; }
value = () => 2;
console.log(value());

Node prints 2, including in a module. scriptc's TS2630 hint instead says Node throws a TypeError in strict mode and modules. A function declaration is mutable; a named function expression's inner binding has different assignment behavior.

There is also a misleading TS2739 description:

// @ts-check
/** @type {{ first: string, second: string, third: string }} */
export const value = { first: "one" };

scriptc describes this as a set-like argument missing has and size. This example has no Set operation; it is an ordinary value missing properties required by its target type.

The requested fix is limited to accurate refusal descriptions. It should preserve the diagnostic codes and admission decisions, distinguish mutable declaration bindings from immutable inner bindings, and describe TS2739 without assuming a Set protocol. Regression tests should exercise actual preflight diagnostics rather than just checking the table's source text.

Reproduced with scriptc 0.4.9 built from current main and Node 24.22.1. Four real preflight regression cases fail with the current descriptions: ordinary object shape, function declaration, class declaration, and named function expression. Related earlier work: #3037, #3039, #3112.

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

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.