tscode

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package tscode is the TypeScript/Vue backend for `sf code`. Extraction is line/block-based (there is no good pure-Go TS parser), so it is deliberately approximate but covers what a structural read needs: imports, top-level declarations, interface/type/enum members, and — for Vue SFCs — props, emits, models, the stores and API calls used, and the components rendered.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Summarize

func Summarize(w io.Writer, path, format string, exported, _, brief bool) (map[string]any, error)

Summarize writes the structural summary of the TS/Vue file at path to w. api (PHP's effective-surface flag) is not meaningful for TS/Vue and is ignored. brief requests the signature-only cut — see Brief for exactly what it drops.

Types

type TSFile

type TSFile struct {
	File       string     `json:"file"`
	Lang       string     `json:"lang"`                 // ts | vue
	Component  string     `json:"component,omitempty"`  // .vue only
	Imports    []string   `json:"imports,omitempty"`    // module specifiers
	Props      []string   `json:"props,omitempty"`      // .vue defineProps keys
	Emits      []string   `json:"emits,omitempty"`      // .vue defineEmits keys
	Models     []string   `json:"models,omitempty"`     // .vue defineModel names
	Stores     []string   `json:"stores,omitempty"`     // .vue composables/stores used (useXStore)
	APICalls   []string   `json:"api_calls,omitempty"`  // .vue client.* / axios.* calls
	Components []string   `json:"components,omitempty"` // .vue components used in <template>
	Types      []TSType   `json:"types,omitempty"`      // interface/type/enum with members
	Symbols    []TSSymbol `json:"symbols"`              // const | function | class
}

TSFile is the structural summary of a TypeScript / Vue source file.

func ReadTS

func ReadTS(path string) (*TSFile, error)

ReadTS reads a .ts/.tsx/.vue file into a structural summary.

func (*TSFile) Brief added in v0.6.0

func (f *TSFile) Brief()

Brief collapses field/value-level detail for a signature-only view: interface and type-alias bodies drop their member list — the object-shape equivalent of a Go struct's fields — while enum stays (its Members is already just the bare case names, no more detail than a Go const block's names). Symbols carry no member/signature detail to begin with (tscode is line-based and never captured one), so there's nothing left to cut there.

type TSSymbol

type TSSymbol struct {
	Kind     string `json:"kind"` // const | function | class
	Name     string `json:"name"`
	Exported bool   `json:"exported"`
}

type TSType

type TSType struct {
	Kind     string `json:"kind"` // interface | type | enum
	Name     string `json:"name"`
	Members  string `json:"members,omitempty"` // "id: string; name: string" | "A, B" | union RHS — blank in Brief mode for interface/type
	Exported bool   `json:"exported"`
}

Jump to

Keyboard shortcuts

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