tsextract

package
v1.10.7 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package tsextract is the per-language tree-sitter extraction provider for TypeScript and JavaScript. A single provider serves both languages per CONTEXT.md Claude's Discretion — the syntax overlap is large and TS-only constructs are captured via query alternation rather than two providers.

Provider claims .ts, .tsx, .js, .jsx, .mjs, .cjs. Internally the provider holds two compiled queries (typescript and tsx grammars) and dispatches based on file extension. Pure JS files run through the typescript grammar — TypeScript is a strict syntactic superset of JavaScript so this is safe (TS-only constructs simply don't appear in .js source).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProvider

func NewProvider(grammars *treesitter.GrammarRegistry) extract.Provider

NewProvider compiles the embedded queries against both the typescript and tsx grammars. Panics on missing grammar or query-compile failure.

Types

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider is the concrete TS+JS extraction provider.

func (*Provider) Extensions

func (p *Provider) Extensions() []string

func (*Provider) Extract

func (p *Provider) Extract(ctx context.Context, source []byte, file extract.SourceFile) (*extract.ExtractedFile, error)

Extract parses source bytes using the appropriate grammar (tsx for .tsx / .jsx, typescript otherwise) and returns an ExtractedFile.

func (*Provider) Language

func (p *Provider) Language() string

func (*Provider) Queries

func (p *Provider) Queries() string

func (*Provider) SupportsLSPEnrichment

func (p *Provider) SupportsLSPEnrichment() bool

func (*Provider) TreeSitterLanguage

func (p *Provider) TreeSitterLanguage() *tree_sitter.Language

Jump to

Keyboard shortcuts

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