Ast Module
The version-5 binary AST returned by `getSourceFile`: one blob per file, from which every node is readable with no further round-trips. All integers here are **little-endian**, unlike the msgpack envelope that carried them.
Types
| Type | Description |
|
A suppression directive mapped from an original file onto a virtual one, in UTF-16 code units. |
|
|
A `/// |
|
|
What a node's |
|
|
A decoded `getSourceFile` response. Cheap to hold: it is the response bytes plus six section offsets read out of the header. |
|
|
One mapping between a virtual file and the original it was extracted from. |
Functions and values
| Function or value |
Description
|
|
A synthetic node representing a list of siblings rather than a syntax node. Outside the schema's numbering, hence not a `SyntaxKind` case.
|
Full Usage:
Ast.ProtocolVersion
Returns: uint32
|
|
Full Usage:
Ast.Root
Returns: int
|
The root SourceFile node.
|
|
|
|
|
Full Usage:
Ast.childAtOrder file index order
Parameters:
SourceFile
index : int
order : int<MeasureProduct<astSlot, MeasureOne>>
Returns: int voption
|
The child occupying declared slot `order`, if present.
|
|
Every child of a node, in order. For a node list these are its elements.
|
|
The six commonData bits of a node's data word, shifted down to bit 0.
What they mean is per kind and is generated: see the accessors in
|
|
The 128-bit content hash, used to tell whether a cached blob is still current.
|
|
|
|
|
|
|
Full Usage:
Ast.diagnosticDirectives file
Parameters:
SourceFile
Returns: DiagnosticDirective array
|
The suppression directives carried over from the file this one was mapped from. Not the `@ts-ignore` and `@ts-expect-error` comments of an ordinary file, which the compiler keeps elsewhere: these are the mapped directives of a virtual file, so an ordinary one has none however many such comments it contains.
|
|
|
|
|
|
|
|
The node's `NodeFlags` - `Const`, `Ambient`, `JavaScriptFile` and the rest of the word the parser set while reading it.
|
Full Usage:
Ast.getString file index
Parameters:
SourceFile
index : uint32<MeasureProduct<stringIndex, MeasureOne>>
Returns: string
|
Reads string `index` from the string table.
|
|
A node has children when the record that follows it names it as parent.
|
|
|
|
The node's kind. `KindNodeList` for a node list, which is not a schema kind.
|
|
The file's `LanguageVariant`, i.e. whether JSX syntax is on.
|
Full Usage:
Ast.libReferenceDirectives file
Parameters:
SourceFile
Returns: FileReference array
|
|
|
|
|
|
|
The text as it was before any transformation, equal to
|
|
|
|
|
|
|
Full Usage:
Ast.rawText file index
Parameters:
SourceFile
index : int
Returns: string voption
|
The unescaped source text of a template literal fragment.
|
|
|
|
|
|
The file's `ScriptKind`: what the compiler decided it was reading.
|
|
The file's whole source text, which the string table is mostly made of.
|
|
The mapping back to the file this one was extracted from, empty when there is none.
|
Full Usage:
Ast.supplementalSourceFileNames file
Parameters:
SourceFile
Returns: string array
|
|
Full Usage:
Ast.templateFlags file index
Parameters:
SourceFile
index : int
Returns: TokenFlags voption
|
The template fragment's `TokenFlags`, which sit past its raw text.
|
|
The node's text, for the kinds that carry one. Identifiers and the like read straight from the string table; literals go through their extended-data record.
|
Full Usage:
Ast.tokenFlags file index
Parameters:
SourceFile
index : int
Returns: TokenFlags voption
|
The literal's `TokenFlags`, for the kinds that record them.
|
Full Usage:
Ast.typeReferenceDirectives file
Parameters:
SourceFile
Returns: FileReference array
|
|
|