tsparser

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package tsparser implements processor.Processor for TypeScript and JavaScript source files (.ts, .tsx, .js, .jsx) using tree-sitter.

Mapping onto the language-neutral model: classes become Structs, interfaces and type aliases and enums become Interfaces (aliases carry their right-hand side in Alias), and both function declarations and consts initialized with a function become Functions. Exported means the symbol carries an `export` modifier or appears in an `export { ... }` / `export default` clause.

The per-file call records (Result.CallGraph) feed callgraph.Aggregate, the AST-only fallback tier: plain identifier calls, `new` expressions, and JSX elements with capitalized names (component renders) are recorded; member calls like api.log() are not, since without type information they are mostly external noise.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCallGraph added in v0.3.0

func BuildCallGraph(root string, relPaths []string) (*callgraph.CallGraph, error)

BuildCallGraph builds the module-wide TS/JS call graph for the given files (paths relative to root). It is the precise tier for TypeScript: imports are resolved per file (relative specifiers, barrel re-exports, tsconfig baseUrl/paths aliases), so calls, new-expressions, and JSX component renders connect to the declaration they actually reference, and calls into npm packages are counted as external dependencies — mirroring what the go/packages builder provides for Go, minus type inference: only identifier calls, this.method() calls, and member calls on imported names resolve; calls through arbitrary local variables do not.

Types

type Processor

type Processor struct{}

Processor implements processor.Processor for TypeScript/JavaScript files.

func (*Processor) Process

func (p *Processor) Process(ctx context.Context, path string, src []byte) (*processor.Result, error)

Process parses one file and extracts its API surface and call records. Plain .ts uses the typescript grammar (where `<T>expr` casts are legal); .tsx, .jsx, and .js use the tsx grammar, which accepts JSX.

func (*Processor) Supports

func (p *Processor) Supports(ext string) bool

Supports reports whether the file extension is handled by this processor.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL