Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LineAndChar ¶
LineAndChar represents a line and character position (1-indexed)
type Location ¶
type Location struct {
Path string `json:"path"`
Start *LineAndChar `json:"start,omitzero"`
End *LineAndChar `json:"end,omitzero"`
}
Location represents a source code location
type TraceRecord ¶
type TraceRecord struct {
ConfigFilePath string `json:"configFilePath,omitzero"`
TracePath string `json:"tracePath,omitzero"`
TypesPath string `json:"typesPath,omitzero"`
}
TraceRecord represents metadata about a single trace file
type TracedType ¶
type TracedType interface {
Id() uint32
FormatFlags() []string
IsConditional() bool
Symbol() *ast.Symbol
AliasSymbol() *ast.Symbol
AliasTypeArguments() []TracedType
// Type-specific data accessors
IntrinsicName() string
UnionTypes() []TracedType
IntersectionTypes() []TracedType
IndexType() TracedType
IndexedAccessObjectType() TracedType
IndexedAccessIndexType() TracedType
ConditionalCheckType() TracedType
ConditionalExtendsType() TracedType
ConditionalTrueType() TracedType
ConditionalFalseType() TracedType
SubstitutionBaseType() TracedType
SubstitutionConstraintType() TracedType
ReferenceTarget() TracedType
ReferenceTypeArguments() []TracedType
ReferenceNode() *ast.Node
ReverseMappedSourceType() TracedType
ReverseMappedMappedType() TracedType
ReverseMappedConstraintType() TracedType
EvolvingArrayElementType() TracedType
EvolvingArrayFinalType() TracedType
IsTuple() bool
Pattern() *ast.Node
RecursionIdentity() any
// Display is an optional string representation of the type
Display() string
}
TracedType is an interface that represents a type that can be traced. This allows the tracing package to work with types from the checker package without creating a circular dependency.
type Tracer ¶
type Tracer interface {
// RecordType records a type for later dumping.
RecordType(t TracedType)
// DumpTypes writes all recorded types to disk.
DumpTypes() error
}
Tracer is an interface for recording types during type checking. Each checker should have its own Tracer instance to avoid sharing types between checkers.
type Tracing ¶
type Tracing struct {
// contains filtered or unexported fields
}
Tracing manages the overall tracing session including all checkers
func StartTracing ¶
func StartTracing(fs vfs.FS, traceDir string, configFilePath string, deterministic bool) (*Tracing, error)
StartTracing creates a new tracing session. When deterministic is true, timestamps use a monotonic counter instead of real wall-clock time, producing stable output for test baselines.
func (*Tracing) Instant ¶
Instant records an instant event in the trace. Safe to call on nil receiver.
func (*Tracing) NewTypeTracer ¶
NewTypeTracer creates a new tracer for a specific checker. The checkerIndex is used to create unique filenames for each checker's output.
func (*Tracing) Push ¶
func (tr *Tracing) Push(phase Phase, name string, args map[string]any, separateBeginAndEnd bool) func()
Push starts a trace event block on the shared trace buffer. Safe to call on nil receiver. Safe to call from multiple goroutines.
When separateBeginAndEnd is true, a "B" (begin) event is written immediately and the returned function writes a matching "E" (end) event. This is used for events that must always appear in the trace (e.g. checkSourceFile, createProgram, emit).
When separateBeginAndEnd is false (the default in TypeScript), the event is only recorded if its duration crosses a 10ms sampling boundary, matching TypeScript's behavior of sampling short-lived events to avoid trace bloat.
Returns a function that should be called (typically deferred) to end the event. Each returned function is self-contained and does not depend on a shared stack, making it safe for concurrent use across goroutines.
func (*Tracing) StopTracing ¶
StopTracing finalizes the tracing session and writes all output files
type TypeDescriptor ¶
type TypeDescriptor struct {
ID uint32 `json:"id"`
IntrinsicName string `json:"intrinsicName,omitzero"`
SymbolName string `json:"symbolName,omitzero"`
RecursionID *int `json:"recursionId,omitzero"`
IsTuple bool `json:"isTuple,omitzero"`
UnionTypes []uint32 `json:"unionTypes,omitzero"`
IntersectionTypes []uint32 `json:"intersectionTypes,omitzero"`
AliasTypeArguments []uint32 `json:"aliasTypeArguments,omitzero"`
KeyofType *uint32 `json:"keyofType,omitzero"`
IndexedAccessObjectType *uint32 `json:"indexedAccessObjectType,omitzero"`
IndexedAccessIndexType *uint32 `json:"indexedAccessIndexType,omitzero"`
ConditionalCheckType *uint32 `json:"conditionalCheckType,omitzero"`
ConditionalExtendsType *uint32 `json:"conditionalExtendsType,omitzero"`
// ConditionalTrueType and ConditionalFalseType are *int32 (not *uint32) because
// unresolved conditional branches are serialized as -1, matching TypeScript's behavior.
ConditionalTrueType *int32 `json:"conditionalTrueType,omitzero"`
ConditionalFalseType *int32 `json:"conditionalFalseType,omitzero"`
SubstitutionBaseType *uint32 `json:"substitutionBaseType,omitzero"`
ConstraintType *uint32 `json:"constraintType,omitzero"`
InstantiatedType *uint32 `json:"instantiatedType,omitzero"`
TypeArguments []uint32 `json:"typeArguments,omitzero"`
ReferenceLocation *Location `json:"referenceLocation,omitzero"`
ReverseMappedSourceType *uint32 `json:"reverseMappedSourceType,omitzero"`
ReverseMappedMappedType *uint32 `json:"reverseMappedMappedType,omitzero"`
ReverseMappedConstraintType *uint32 `json:"reverseMappedConstraintType,omitzero"`
EvolvingArrayElementType *uint32 `json:"evolvingArrayElementType,omitzero"`
EvolvingArrayFinalType *uint32 `json:"evolvingArrayFinalType,omitzero"`
DestructuringPattern *Location `json:"destructuringPattern,omitzero"`
FirstDeclaration *Location `json:"firstDeclaration,omitzero"`
Flags []string `json:"flags"`
Display string `json:"display,omitzero"`
}
TypeDescriptor represents a type in the output JSON