Adds `kebab_parse_code::typescript::TypescriptAstExtractor` (PARSER_VERSION
`code-typescript-v1`), mirroring the Python extractor (P10-1B Task E) and
the Rust scaffold (P10-1A-2). One `Block::Code` per top-level AST semantic
unit (free fn / class / each method / interface / type alias / enum,
recursively per nested class), each carrying `SourceSpan::Code` with the
unit's dotted symbol path prefixed by `module_path_for_tsjs`.
Grammar selection per `tree-sitter-typescript` 0.23: the workspace path's
`.tsx` extension routes to `LANGUAGE_TSX`, everything else to
`LANGUAGE_TYPESCRIPT`. The `export_statement` arm unwraps a `declaration`
field (`function_declaration` / `class_declaration` / `interface_declaration`
/ `type_alias_declaration` / `enum_declaration`) using the OUTER statement's
line range so `export ` is folded in; for `export default function () {}`
and `export default class {}` (where the inner node sits under the `value`
field as `function_expression` / `class` with no `name`), the symbol leaf
is `default`. Bare value exports / re-exports fall into glue.
Glue grouping reuses the Python post-pass: `<module>` only when the entire
group is imports + bare re-exports; demoted to `<top-level>` if the file
produced any real unit.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
12 lines
380 B
TypeScript
12 lines
380 B
TypeScript
// sample.ts
|
|
import { x } from "./other";
|
|
const ANSWER = 42;
|
|
export interface Greet { hello(): string; }
|
|
export type Maybe<T> = T | null;
|
|
export function add(a: number, b: number): number { return a + b; }
|
|
export class Retriever {
|
|
search(q: string): string[] { return []; }
|
|
static create(): Retriever { return new Retriever(); }
|
|
}
|
|
export default function () { return 1; }
|