Add beta CLI --tsgo backend (native-preview shim)#102
Closed
johnsoncodehk wants to merge 10 commits into
Closed
Conversation
Expose ts-go as an optional type backend for plain --project runs, with auto fast-path on multi-file projects, poc-tsgo benchmarks, and lazy-estree TSImportType.options parity so dogfood CI stays green. Co-authored-by: Cursor <cursoragent@cursor.com>
Use tsgo-load hasNativePreview() in the workflow check and add root devDependency so optional peer installs reliably on Linux CI. Co-authored-by: Cursor <cursoragent@cursor.com>
The rule disagrees across Strada vs tsgo checkers on interop assertions in shim sources; split tsslint.config so shim files keep consistent-type-imports only. Co-authored-by: Cursor <cursoragent@cursor.com>
Patch Type predicates per prototype and instance, resolve aliasTypeArguments handles lazily, and fixup nested type arrays so union traversal no longer throws. Co-authored-by: Cursor <cursoragent@cursor.com>
Remove the proto getter that looped with getAliasTypeArguments(), drop handle caches on fixup, and resolve type.symbol eagerly so no-unnecessary-type-assertion no longer stack-overflows. Co-authored-by: Cursor <cursoragent@cursor.com>
Reuse one tsgo subprocess across projects, add TSSLINT_TIME_TSGO RPC profiling, and derive per-file prefetch plans from ESLint rule selectors. Co-authored-by: Cursor <cursoragent@cursor.com>
Route computeGetTypeAtLocation through memo-wrapped checker methods, batch-resolve import/export symbols and contextual types during prepare, and warm index-infos on member-access prefetch. Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve JS-bind misses via getSymbolAtPosition(batch), warm call/new types with getTypeAtLocation(batch), batch getTypeOfSymbol for tsgo symbols, memo getWidenedType, and drop eager getIndexInfosOfType prefetch. Co-authored-by: Cursor <cursoragent@cursor.com>
…p caches Fix the hidden 34k raw-IPC bottleneck: patchTsgoTypeCheckerMethods was routing type.getProperties() / getCallSignatures() / getBaseTypes() etc. through the raw project.checker (no memo), causing 21,951 uncacheable getPropertiesOfType IPC calls alone. Route through the wrapped checker so they hit the existing propertiesOfTypeCache / signaturesOfTypeCache. Also memoize Type/Symbol object methods (getSymbol, getTarget, getTypes, getMembers, getExports) that issue apiRequest on first access, and switch all checker memo tables from WeakMap to per-file Map (cleared in releaseFile) since lint is sequential per file. Full bench: --tsgo 5.7s → 2.2s (1.15× Strada, was 3.0×). Co-authored-by: Cursor <cursoragent@cursor.com>
…p no-sig types - Add shouldPrefetchSymbol() to skip property names, declaration names, labels, and other identifiers the scope manager's _classifyIdentifier never queries via getSymbolAtLocation. Reduces getSymbolsAtPositions batch from ~10k to ~900 positions (90% reduction), 217ms → 22ms. - Increase BATCH_CHUNK to 2048 (one chunk per file for typical sizes). - Add TypeFlags early-return for getCallSignatures/getConstructSignatures on primitive/literal types (skip IPC for types that can't have sigs). - Memoize getShorthandAssignmentValueSymbol via shorthandValueSymbolCache. - Improve JS resolver with memberOf/resolveJsNodeSymbol for qualified-name and property-access member resolution. - Result: --tsgo full bench ~2.1s vs Strada ~2.0s (1.05×, was 1.17×). Co-authored-by: Cursor <cursoragent@cursor.com>
Owner
Author
Performance Update —
|
| Metric | Before | After | Change |
|---|---|---|---|
getSymbolsAtPositions |
217ms | 22ms | −90% |
| Total RPC time | 502ms | 351ms | −30% |
--tsgo full bench (median) |
2,444ms | 2,105ms | −339ms |
--tsgo / Strada ratio |
1.17× | 1.05× |
Also included:
TypeFlagsearly-return forgetCallSignatures/getConstructSignatureson primitive/literal types- Memoized
getShorthandAssignmentValueSymbol - Improved JS resolver with
resolveJsNodeSymbolfor qualified-name/property-access member resolution
Owner
Author
|
Pivoting to an in-process NAPI approach via a separate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--tsgoto@tsslint/cliusing@typescript/native-preview(ts-go) as an optional type backend for plain--projectruns, with a TypeScript API shim (tsgo-backend, facade, JS symbol resolver).--projectentries (tsgo-api-pool);--tsgo-fastopt-in eager-prepares all files at setup.PrefetchPlanfrom ESLint rule listeners and batch-warm types/symbols/contextual types before the sync rule loop.project.checker.*methods AND Type/Symbol object methods (getProperties,getCallSignatures,getSymbol,getTarget,getTypes, etc.) — the latter was the key bottleneck (21,951 raw IPC calls → 444 via memo).Mapcaches (cleared after each lint) instead of WeakMap, since lint is sequential.TSSLINT_TIME_TSGO=1RPC profiling with fullapiRequestinstrumentation.Performance (darwin arm64, Node 24, 3-run median)
--tsgoProfile (
TSSLINT_TIME_TSGO=1, compat-eslint): 6,080 total IPC / 512ms (was 34,023 / 3,670ms); 55,173 memo hits.Dogfood parity
pnpm run lint:tsgovs Strada: 84 passed with known gap on shim sources / tsgo checker divergence.Test plan
pnpm run buildnode packages/cli/test/tsgo-backend.test.jspnpm run lint:tsgo(compat-eslint tsconfig)node packages/poc-tsgo/bench.js --scenario=full --runs=3TSSLINT_TIME_TSGO=1 packages/cli/bin/tsslint.js --force --project packages/compat-eslint/tsconfig.json --tsgotestworkflow on Linux