Repository navigation
grammar(ts): vendor tree-sitter-typescript fork v0.25.2; import types follow their module - #43
Merged
Merged
Conversation
… follow their module
Vendors inth3shadows/tree-sitter-typescript v0.25.0 (92d973d, on crates.io as
tree-sitter-typescript-next 0.25.0) in place of ed828ca: both wasm files, the
kernel's vendored C (both parser.c, common/scanner.h, tsx/src/scanner.c), the
regenerated patch (now also tsx/src/scanner.c and tree-sitter.json, so
marionebl 53071c9 + the patch regenerates byte-identical parser.c), and the
hashes in build.rs, the provenance doc and the differential baseline.
The fork nests expressions and types as tsc does (an operator before a generic
call, `as`/`satisfies` precedence, `!`, readonly and constructor types) and
adds `import_type` and `using_declaration`. The four gap fixtures (using in for
heads, import attributes on re-exports) now parse and are ordinary fixtures.
An import type, `import("m").A.B`, now resolves as a path from module m's
exports, like `import * as ns from "m"`; a module outside the project links
nothing. Read by its last name, it linked any namesake: on angular, 58
references in generated .d.ts files reached the language service's mock copy
of @angular/core instead of packages/core, and zone.js's
`typeof import('../zone-spec/proxy').ProxyZoneSpec` linked its own property.
Checks: tsc 0; suite 11142 passed (CODEGRAPH_KERNEL unset, no prebuild);
kernel built from the vendored C: kernel-grammar-parity 30/30;
ts-differential 0 divergent on effect/zod/excalidraw/vscode/fixtures.
Held-out tree accuracy (angular, nest, vite, trpc, shadcn-ui; 13,134 files):
wrong/missed nodes 2,374/848 -> 63/14. Edge diff vs v1.6.3-em.4 on 7 TS repos:
zod, trpc unchanged; the rest explained in the provenance doc.
Known limits (docs/grammars/tree-sitter-typescript.md): some import-type
layouts are read by name alone, and a one-line generated .d.ts with many
import types costs quadratic time.
v0.25.2 (1e68d2a, published as tree-sitter-typescript-next 0.25.2 on crates.io and npm) adds one grammar fix over v0.25.0: a same-line comment after the closing brace of a method, function or arrow expression, or static block belongs to what holds the body, not to the body (fork colbymchenry#115). The rest is packaging. common/scanner.h and tsx/src/scanner.c are unchanged. Updated: both parser.c files and wasm files, the patch (marionebl 53071c9 + patch still regenerates byte-identical parser.c), hashes in build.rs, the provenance doc and the differential baseline. Checks: tsc 0; kernel rebuilt, kernel-grammar-parity 30/30; ts-differential 0 divergent; suite 11420 passed, 3 timing tests failed under load average 41 (alias-chain-length, ui-highlight cost, ui-server-api busiest symbol) and pass when rerun, on this branch and on fork main alike. Held-out tree accuracy (angular, nest, vite, trpc, shadcn-ui; 13,134 files): 63 wrong / 14 missed / 4 error files, the same as v0.25.0. Edge diff vs the deployed v1.6.3-em.5 on 7 TS repos: identical to the v0.25.0 run (zod, trpc unchanged).
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.
What
Vendors tree-sitter-typescript fork v0.25.2 (inth3shadows/tree-sitter-typescript
1e68d2a, published astree-sitter-typescript-next0.25.2 on crates.io and npm) in place ofed828ca. It also makes an import type,import("m").A.B, resolve through module m's exports.The new grammar nests expressions and types as tsc does: an operator before a generic call,
as/satisfiesprecedence,!,readonly, constructor types, and a trailing comment after a body. It also addsimport_typeandusing_declaration. Before this, afor (using r of rs)head turned its whole function into an ERROR, so codegraph recorded no function and no calls for it.How
parser.c,common/scanner.h,tsx/src/scanner.c), the patch and the hashes. marionebl53071c9plusdocs/grammars/tree-sitter-typescript.patchregenerates byte-identicalparser.c; the patch now also carriestsx/src/scanner.candtree-sitter.json.typeQualifier(src/resolution/import-resolver.ts) recognises an import type at the head of a type path and reads it asimport * as ns from "m". A module outside the project links nothing. Before, the name was matched alone and reached any namesake.gap-*fixtures (usinginforheads, import attributes on re-exports) now parse, so they are ordinary fixtures.Measured
__tests__/ts-import-type-reference.test.tshas 8 cases. The 5 original ones failed before the resolver change, and each later case was added from a reviewer's failing probe.kernel-grammar-parity30/30.ts-differential: 0 divergent files on Effect, Zod, Excalidraw, VS Codesrc/and the fixtures.packages, nest, vitepackages, trpc and shadcn-ui at pinned SHAs (13,134 files tsc parses cleanly), wrong/missed nodes went from 2,374/848 oned828cato 63/14. 53 of the 63 are a counting convention (assertswraps atype_predicate).CODEGRAPH_KERNEL=0, same 7 repos). zod and trpc are unchanged. On the others:readonly T[] & {…}.findProviders(using: any): three bogus properties became one method.importare gone.x!.m()calls are now linked..d.tsimport types now reachpackages/core/srcinstead of the language service's mock copy of@angular/core.typeof import('../zone-spec/proxy').ProxyZoneSpecnow reaches the class, not its own property.Review
Dual review (the
/code-reviewskill plus a code-reviewer agent), three rounds on the import-type change; the stop rule was met after round 3. Follow-ups are in #42.Known limits
import(more than 12 lines above the name;.;//comment containing*/, or a//inside a multi-line block comment, between)and...d.tsfile with many import types costs quadratic time.usingdeclarations themselves are not indexed yet (TypeScript: follow-ups from the tree-sitter-typescript v0.25.0 vendor (import types at extraction, using declarations, dead peels) #42).