TS 7 migration: port extract.mjs from the classic ts.* API to typescript/unstable/sync
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 重构
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- javascript, typescript
- 领域
- tooling
调研方向
从 src/extract.mjs 以及 unstable/sync 的 Program 和 Checker API 开始,使用 src/resolve.mjs 了解输入路径如何到达程序。为 union、object、literal、array 和 signature 形状构建建议的 classify() proof of concept,然后通过 test/sandbox harness 运行大约五个 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 分钟
- 30 天内合并 PR
- 6
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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 一周以上 新手友好度 22/100
juspay/rescript-bindgen#241 ·
-
难度 5/5 一周以上 新手友好度 25/100
juspay/rescript-bindgen#164 · 2 条评论 ·
-
enhancement
难度 5/5 一周以上 新手友好度 35/100
juspay/rescript-bindgen#160 ·
-
enhancement
难度 5/5 一周以上 新手友好度 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 天内回复