TS 7 migration: port extract.mjs from the classic ts.* API to typescript/unstable/sync
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- リファクタリング
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- javascript, typescript
- 領域
- tooling
調査の方向性
src/extract.mjs と unstable/sync の Program および Checker API から始め、src/resolve.mjs を使って入力パスがどのようにプログラムへ到達するかを理解します。union、object、literal、array、signature の各 shape に対して、提案されている classify() の proof of concept を実装し、その後 test/sandbox harness で約 5 件の Golden Cases を実行します。完了の条件は、byte-diff した出力がコミット済みの Golden Results と一致し、API-mapping の不足箇所が文書化されていることです。
索引モデルが issue の本文から書いたものです。
説明
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).
- 主要言語
- ReScript
- スター
- 11
- フォーク
- 0
- 平均マージ
- 7時間 27分
- マージ済み PR(30日)
- 6
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
juspay/rescript-bindgen のほかの issue
-
--subpaths: a shadowed subpath export is dropped. Bind it under a subpath-qualified name (blend V1 deprecated paths)対応中かも @jagguji が 2 日前に担当しました。 オープン
難易度 3/5 半日 初心者へのやさしさ 64/100
juspay/rescript-bindgen#248 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 22/100
juspay/rescript-bindgen#241 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
juspay/rescript-bindgen#164 · コメント 2 件 ·
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
juspay/rescript-bindgen#160 ·
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
juspay/rescript-bindgen#159 ·
juspay/rescript-bindgen の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
c1overzz/dsh-bili-scroll#213 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
conda/governance#490 ·
メンテナーはふだん 4 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
jonathanong/no-mistakes#5441 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 2 日以内に返信