TS 7 migration: port extract.mjs from the classic ts.* API to typescript/unstable/sync
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Refactoring
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Ruhig
- Tech-Stack
- javascript, typescript
- Bereich
- tooling
Rechercherichtung
Beginne mit src/extract.mjs und den unstable/sync Program- und Checker-APIs und verwende src/resolve.mjs, um zu verstehen, wie Eingabepfade das Programm erreichen. Erstelle den vorgeschlagenen classify()-Proof of Concept für union-, object-, literal-, array- und signature-Shapes und führe dann etwa fünf Golden Cases über den test/sandbox-Harness aus. Erledigt bedeutet, dass die byte-diffed Ausgabe mit den committeten Golden Results übereinstimmt und die API-Mapping-Lücken dokumentiert sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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).
- Vorherrschende Sprache
- ReScript
- Sterne
- 11
- Forks
- 0
- Ø Merge
- 7 Std. 27 Min.
- Gemergte PRs (30 T.)
- 6
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus juspay/rescript-bindgen
-
--subpaths: a shadowed subpath export is dropped. Bind it under a subpath-qualified name (blend V1 deprecated paths)Evtl. vergeben @jagguji hat das vor 2 Tagen übernommen. Offen
Schwierigkeit 3/5 Ein halber Tag Anfängerfreundlichkeit 64/100
juspay/rescript-bindgen#248 ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 22/100
juspay/rescript-bindgen#241 ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
juspay/rescript-bindgen#164 · 2 Kommentare ·
-
enhancement
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
juspay/rescript-bindgen#160 ·
-
enhancement
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
juspay/rescript-bindgen#159 ·
Alle Issues in juspay/rescript-bindgen
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
c1overzz/dsh-bili-scroll#213 ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 82/100
conda/governance#490 ·
Maintainer antworten meist innerhalb von 4 Tagen
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 77/100
jonathanong/no-mistakes#5441 ·
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 2 Tagen