Documentation
¶
Overview ¶
Package parser is Krate's TSX/JSX parser. It parses ES2024 plus JSX into the ast package's tree and skips TypeScript-only syntax (annotations, generics, interfaces, type aliases, casts), counting each skipped construct in DroppedTypes. TypeScript constructs that carry runtime semantics and cannot be represented (enums, namespaces with values, parameter properties, decorators) are reported as diagnostics instead of being dropped.
Index ¶
Constants ¶
const DecoratorsUnsupported = "decorators are not supported by the Krate parser"
DecoratorsUnsupported marks the error for decorator syntax. Sources reach this parser with decorators already lowered by esbuild (see tsstrip), so it only fires for callers that parse raw text.
Variables ¶
This section is empty.
Functions ¶
func FormatDiagnostics ¶
Types ¶
type Diagnostic ¶
type Diagnostic = diag.Diagnostic
Diagnostic is an alias for the shared compiler diagnostic type.
type Parser ¶
type Parser struct {
Filename string
// contains filtered or unexported fields
}
func New ¶
New creates a parser over a token stream produced by lexer.Tokenize. Whitespace tokens are dropped; layout information the parser needs is carried by Token.NewlineBefore.
func (*Parser) DroppedTypes ¶ added in v0.4.0
DroppedTypes reports how many type-only constructs the parse discarded.
func (*Parser) ParseProgram ¶
ParseProgram parses the whole token stream.