TS 7 migration: port extract.mjs from the classic ts.* API to typescript/unstable/sync
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- javascript, typescript
- Lĩnh vực
- tooling
Hướng nghiên cứu
Bắt đầu với src/extract.mjs và các API Program và Checker của unstable/sync, sử dụng src/resolve.mjs để hiểu các đường dẫn đầu vào đi tới chương trình như thế nào. Xây dựng proof of concept classify() được đề xuất cho các shape union, object, literal, array và signature, sau đó chạy khoảng năm Golden Cases thông qua test/sandbox harness. Hoàn tất có nghĩa là đầu ra được so sánh byte-diff khớp với các Golden Results đã commit và các khoảng trống trong việc ánh xạ API đã được ghi lại.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Split from #137 (the impossible 7.0.2 drop-in bump) and related to #160 (compiler-version tracking).
Why this exists
The generator reads TypeScript via the classic JS compiler API (ts.createProgram, program.getTypeChecker(), checker.getTypeOfSymbolAtLocation, TypeFlags, SymbolFlags, forEachChild, type.isUnion(), checker.isArrayType(), …) throughout src/extract.mjs (~4,700 lines). TS 7 (native Go rewrite) removed that API — [email protected]'s top-level export is just version.cjs. So 6.x (this repo pins ^6.0.3, #161) is the end of the classic-API line; moving to TS 7+ means porting to the new API.
The good news — the new API exists and maps closely
TS 7 exposes a synchronous programmatic API at typescript/unstable/sync (+ typescript/unstable/ast). Verified surface:
Program—getSourceFile,getSourceFileNames, diagnostics.Checker—getSymbolAtLocation,getTypeOfSymbol,getDeclaredTypeOfSymbol,getTypeAtLocation,getSignaturesOfType,getTypeFromTypeNode,getNonNullableType,getBaseTypeOfLiteralType,getContextualType,getWidenedType,isArrayLikeType,isTypeAssignableTo,resolveName,getResolvedSymbol, …- Standalone type predicates —
isUnionType,isObjectType,isTupleType,isTypeReference,isClassOrInterfaceType,isStringLiteralType,isIntersectionType,isConditionalType,isIndexedAccessType,isTypeParameter, … (replacet.isUnion()/checker.isArrayType()). - Flags —
TypeFlags,SymbolFlags,ObjectFlags,ModifierFlags,SignatureKind,ModuleKind. typescript/unstable/ast—SyntaxKind,forEachChild*,createScanner,getJSDocTags,cast, …
So most of extract.mjs's calls have a near-1:1 target; the port is mechanical for the bulk, with a handful of shape changes (a Checker class vs program.getTypeChecker(); standalone predicates vs methods; Program construction via the API/parseConfigFile/updateSnapshot lifecycle).
The catch — it's unstable/*
That prefix means the TS team may change the API shape across 7.x without a semver-major. Building the released tool on it invites churn. This repo's mitigation is strong, though: the golden suite (105 byte-diffed cases) + benchmark (9 real packages) catch any output drift immediately, so a breaking TS 7.x change surfaces as a red CI, not silent breakage.
When to actually migrate (trigger)
Not now — 6.0.3 works and parses every package we bind. Migrate when any of:
- the API is promoted out of
typescript/unstable/*(frozen), or - a package we must bind ships
.d.tsusing TS-7-only syntax that 6.x can't parse, or - the 6.x line stops getting maintenance/security fixes.
Suggested first step — a POC/spike (before the full port)
Prove feasibility + size the effort on a subset before touching 4,700 lines:
- New
makeProgramonunstable/sync(Program+Checker). - Port the core
classify()path for a handful of shapes (union / object / literal / array / signature). - Run ~5 golden cases through it; diff against committed output.
- Report the API-mapping delta (what's 1:1, what needs rework, any missing capability) — that scopes the full migration.
Anchors
src/extract.mjs— all classic-API usage (the port target).src/resolve.mjs—typesEntryfeeds file paths to the program (largely API-agnostic).test/sandbox+ the golden/benchmark suites — the validation harness (already byte-diffs output, so it doubles as the migration's correctness gate).
- Ngôn ngữ chính
- ReScript
- Star
- 11
- Fork
- 0
- Merge trung bình
- 7 giờ 27 phút
- Pull request đã merge (30 ngày)
- 6
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của juspay/rescript-bindgen
-
--subpaths: a shadowed subpath export is dropped. Bind it under a subpath-qualified name (blend V1 deprecated paths)Có thể đã có người làm @jagguji đã nhận 2 ngày trước. Đang mở
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 64/100
juspay/rescript-bindgen#248 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 22/100
juspay/rescript-bindgen#241 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
juspay/rescript-bindgen#164 · 2 bình luận ·
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
juspay/rescript-bindgen#160 ·
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
juspay/rescript-bindgen#159 ·
Tất cả issue của juspay/rescript-bindgen
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
c1overzz/dsh-bili-scroll#213 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
conda/governance#490 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
jonathanong/no-mistakes#5441 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 2 ngày