@eryx/luau/ast Module

Type stubs for the Luau AST shape produced by src/modules/luau/native.cpp.

API Reference

Types

Position

A 1-based source position in the original input.

type Position = { line: number, column: number }
line: number

The 1-based source line number.

column: number

The 1-based source column number.

Location

A 1-based, half-open source span in the original input.

type Location = { beginline: number, begincolumn: number, endline: number, endcolumn: number }
beginline: number

The 1-based line where the span begins.

begincolumn: number

The 1-based column where the span begins.

endline: number

The 1-based line where the span ends.

endcolumn: number

The 1-based column where the span ends.

CstToken<Text>

A concrete syntax token captured from the CST.

type CstToken<Text> = { type: "token", text: Text, location: Location, leadingText: string, trailingText: string }
type: "token"

Identifies this table as a concrete syntax token.

text: Text

The exact source text of the token, including raw literal spelling such as 0x10.

location: Location

The span of the token itself, excluding leading and trailing trivia.

leadingText: string

Trivia immediately before this token, such as whitespace and comments.

trailingText: string

Trivia immediately after this token, such as whitespace and comments.

AstNode<Category, Type>

Shared fields present on every serialized AST node.

type AstNode<Category, Type> = { category: Category, type: Type, location: Location }
category: Category

The broad AST family this node belongs to.

type: Type

The specific node kind within the category.

location: Location

The source span covered by the AST node.

AstStatNode<Type>

Shared fields present on every statement node.

type AstStatNode<Type> = AstNode<"stat", Type> & { hasSemicolon: boolean, semicolonToken: CstToken<";">? }
Implements: AstNode
hasSemicolon: boolean

True when the statement was terminated by an explicit semicolon.

semicolonToken: CstToken<";">?

The trailing semicolon token after this statement, when one was present.

AstExprNode<Type>

Shared fields present on every expression node.

type AstExprNode<Type> = AstNode<"expr", Type>
Implements: AstNode

AstTypeNode<Type>

Shared fields present on every type node.

type AstTypeNode<Type> = AstNode<"type", Type>
Implements: AstNode

AstTypePackNode<Type>

Shared fields present on every type-pack node.

type AstTypePackNode<Type> = AstNode<"typePack", Type>
Implements: AstNode

AstGenericNode<Type>

Shared fields present on every generic declaration node.

type AstGenericNode<Type> = AstNode<"generic", Type>
Implements: AstNode

AstAttrNode<Type>

Shared fields present on every attribute node.

type AstAttrNode<Type> = AstNode<"attr", Type>
Implements: AstNode

TableAccess

The read/write access qualifier for table and extern type entries.

type TableAccess = "Read" | "Write" | "ReadWrite"

AstLocal

A local binding referenced by declarations and local expressions.

type AstLocal = AstNode<"", "local"> & { name: string, nameToken: CstToken<string>?, location: Location, shadows: AstLocal?, functionDepth: number, loopDepth: number, isConst: boolean, isExported: boolean, annotation: AstType? }
Implements: AstNode
name: string

The local variable name.

nameToken: CstToken<string>?

The identifier token that introduced or referenced this local.

location: Location

The source span of the local identifier.

shadows: AstLocal?

The local declaration shadowed by this local, if one exists.

functionDepth: number

The function nesting depth where the local is declared.

loopDepth: number

The loop nesting depth where the local is declared.

isConst: boolean

True when the local is const.

isExported: boolean

True when this local came from an exported declaration.

annotation: AstType?

The type annotation attached to the local declaration.

TypeOrPack

A type argument item that can be either a type, a type pack, or an absent placeholder.

type TypeOrPack = { kind: "Type", value: AstType } | { kind: "TypePack", value: AstTypePack } | { kind: "None" }

TypeList

A list of types with an optional trailing type pack.

type TypeList = { types: { AstType }, tail: AstTypePack? }
types: { AstType }

Positional type entries.

The trailing type pack, when the list ends with one.

ArgumentName

The optional source name for a function parameter type.

type ArgumentName = { name: string, location: Location }
name: string

The parameter name text.

location: Location

The source span of the parameter name.

TableIndexer

A table indexer type, such as {[K]: V}.

type TableIndexer = { indexType: AstType, resultType: AstType, location: Location, access: TableAccess, accessLocation: Location? }
indexType: AstType

The type used as the index key.

resultType: AstType

The type produced by the indexer.

location: Location

The full source span of the indexer entry.

access: TableAccess

The optional read/write access mode.

accessLocation: Location?

The source span of the access qualifier, when present.

AstAttr

A function or declaration attribute such as @native or @deprecated.

type AstAttr = AstAttrNode<"attribute"> & { attrType: "Checked" | "Native" | "Deprecated" | "DebugNoinline" | "Unknown", name: string, nameToken: CstToken<string>, args: { AstExpr }, deprecatedInfo: { deprecated: boolean, use: string?, reason: string? }? }
Implements: AstAttrNode
attrType: "Checked" | "Native" | "Deprecated" | "DebugNoinline" | "Unknown"

The normalized attribute kind.

name: string

The attribute name without the @ prefix.

nameToken: CstToken<string>

The attribute name token after @.

args: { AstExpr }

Attribute argument expressions inside the argument list.

deprecatedInfo: { deprecated: boolean, use: string?, reason: string? }?

Parsed @deprecated payload, when available.

AstGenericType

A named generic type parameter.

type AstGenericType = AstGenericNode<"type"> & { name: string, nameToken: CstToken<string>, default: AstType?, defaultEqualsToken: CstToken<"=">? }
Implements: AstGenericNode
name: string

The generic parameter name.

nameToken: CstToken<string>

The generic parameter identifier token.

default: AstType?

The default type after =, when present.

defaultEqualsToken: CstToken<"=">?

The = token before the default type.

AstGenericTypePack

A named generic type-pack parameter.

type AstGenericTypePack = AstGenericNode<"typePack"> & { name: string, nameToken: CstToken<string>, ellipsisToken: CstToken<"...">?, default: AstTypePack?, defaultEqualsToken: CstToken<"=">? }
Implements: AstGenericNode
name: string

The generic pack parameter name.

nameToken: CstToken<string>

The generic pack identifier token.

ellipsisToken: CstToken<"...">?

The ... token that marks this generic as a type pack.

default: AstTypePack?

The default type pack after =, when present.

defaultEqualsToken: CstToken<"=">?

The = token before the default type pack.

AstExprGroup

A parenthesized expression.

type AstExprGroup = AstExprNode<"group"> & { openParenToken: CstToken<"(">, expr: AstExpr, closeParenToken: CstToken<")"> }
Implements: AstExprNode
openParenToken: CstToken<"(">

The opening ( token.

expr: AstExpr

The expression inside the parentheses.

closeParenToken: CstToken<")">

The closing ) token.

AstExprConstantNil

The nil literal expression.

type AstExprConstantNil = AstExprNode<"constantNil"> & { token: CstToken<"nil"> }
Implements: AstExprNode
token: CstToken<"nil">

The nil keyword token.

AstExprConstantBool

A boolean literal expression.

type AstExprConstantBool = AstExprNode<"constantBool"> & { value: boolean, token: CstToken<"true" | "false"> }
Implements: AstExprNode
value: boolean

The parsed boolean value.

token: CstToken<"true" | "false">

The true or false keyword token.

AstExprConstantNumber

A floating point number literal expression.

type AstExprConstantNumber = AstExprNode<"constantNumber"> & { value: number, token: CstToken<string> }
Implements: AstExprNode
value: number

The parsed numeric value.

token: CstToken<string>

The exact number literal token, preserving raw spelling.

AstExprConstantInteger

An integer literal expression.

type AstExprConstantInteger = AstExprNode<"constantInteger"> & { value: number, token: CstToken<string> }
Implements: AstExprNode
value: number

The parsed integer value.

token: CstToken<string>

The exact integer literal token, preserving raw spelling.

AstExprConstantString

A string literal expression.

type AstExprConstantString = AstExprNode<"constantString"> & { value: string, quoteStyle: "simple" | "single" | "raw" | "unquoted" | "unknown", isQuoted: boolean, token: CstToken<string> }
Implements: AstExprNode
value: string

The decoded string value.

quoteStyle: "simple" | "single" | "raw" | "unquoted" | "unknown"

The serializer's description of the source quote style.

isQuoted: boolean

True when the literal was written with quotes in source.

token: CstToken<string>

The exact string literal token, preserving raw spelling.

AstExprLocal

A reference to a local binding.

type AstExprLocal = AstExprNode<"local"> & { local: AstLocal, upvalue: boolean, nameToken: CstToken<string> }
Implements: AstExprNode
local: AstLocal

The local binding object being referenced.

upvalue: boolean

True when the referenced local is captured from an outer function.

nameToken: CstToken<string>

The identifier token at this reference site.

AstExprGlobal

A reference to a global binding.

type AstExprGlobal = AstExprNode<"global"> & { name: string, nameToken: CstToken<string> }
Implements: AstExprNode
name: string

The global name.

nameToken: CstToken<string>

The global identifier token.

AstExprVarargs

A vararg expression.

type AstExprVarargs = AstExprNode<"varargs"> & { token: CstToken<"..."> }
Implements: AstExprNode
token: CstToken<"...">

The ... token.

AstExprCall

A function or method call expression.

type AstExprCall = AstExprNode<"call"> & { [string]: any }
Implements: AstExprNode
func: AstExpr

The expression being called.

typeArguments: { TypeOrPack }

Explicit type arguments passed with <<...>>.

args: { AstExpr }

Runtime argument expressions.

self: boolean

True when this is a method-style self call.

argLocation: Location

The source span covering the argument syntax.

leftArrow1Token: CstToken<"<">?

The first < token in an explicit << type argument list.

leftArrow2Token: CstToken<"<">?

The second < token in an explicit << type argument list.

rightArrow1Token: CstToken<">">?

The first > token in an explicit >> type argument list.

rightArrow2Token: CstToken<">">?

The second > token in an explicit >> type argument list.

openParenToken: CstToken<"(">?

The opening ( token for parenthesized call arguments.

closeParenToken: CstToken<")">?

The closing ) token for parenthesized call arguments.

AstExprIndexName

A field or method-name indexing expression, such as a.b or a:b.

type AstExprIndexName = AstExprNode<"indexName"> & { expr: AstExpr, index: string, indexLocation: Location, opPosition: Position, opToken: CstToken<"." | ":">, indexToken: CstToken<string> }
Implements: AstExprNode
expr: AstExpr

The table or object expression being indexed.

index: string

The field or method name.

indexLocation: Location

The source span of the field or method name.

opPosition: Position

The source position of the . or : operator.

opToken: CstToken<"." | ":">

The . or : token.

indexToken: CstToken<string>

The identifier token after the . or : operator.

AstExprIndexExpr

A bracket indexing expression, such as a[b].

type AstExprIndexExpr = AstExprNode<"indexExpr"> & { expr: AstExpr, index: AstExpr, openBracketToken: CstToken<"[">, closeBracketToken: CstToken<"]"> }
Implements: AstExprNode
expr: AstExpr

The table or object expression being indexed.

index: AstExpr

The expression inside the brackets.

openBracketToken: CstToken<"[">

The opening [ token.

closeBracketToken: CstToken<"]">

The closing ] token.

AstExprFunction

A function expression.

type AstExprFunction = AstExprNode<"function"> & { [string]: any }
Implements: AstExprNode
attributes: { AstAttr }

Attributes applied to the function.

generics: { AstGenericType }

Generic type parameters.

genericPacks: { AstGenericTypePack }

Generic type-pack parameters.

self: AstLocal?

The implicit self local for method functions.

args: { AstLocal }

Function parameter locals.

returnAnnotation: AstTypePack?

The annotated return type pack.

vararg: boolean

True when the function accepts varargs.

varargLocation: Location

The source span of the vararg marker.

varargAnnotation: AstTypePack?

The annotated vararg type pack.

The function body block.

functionDepth: number

The function nesting depth.

debugname: string

The debug name inferred by the parser.

argLocation: Location?

The source span of the parameter list.

functionKeywordToken: CstToken<"function">?

The function keyword token for full function expressions and declarations.

openGenericsToken: CstToken<"<">?

The opening < token for generic parameters.

closeGenericsToken: CstToken<">">?

The closing > token for generic parameters.

openParenToken: CstToken<"(">?

The opening ( token for the parameter list.

closeParenToken: CstToken<")">?

The closing ) token for the parameter list.

varargToken: CstToken<"...">?

The ... token for vararg parameters.

returnColonToken: CstToken<":">?

The : token before the return annotation.

endKeywordToken: CstToken<"end">

The end keyword token closing the function body.

AstExprTableItem

An item inside a table constructor.

type AstExprTableItem = { kind: "list" | "record" | "general", key: AstExpr?, value: AstExpr }
kind: "list" | "record" | "general"

The table item form: array item, name record, or bracketed key record.

key: AstExpr?

The key expression for keyed entries.

value: AstExpr

The value expression stored in the table.

AstExprTable

A table constructor expression.

type AstExprTable = AstExprNode<"table"> & { [string]: any }
Implements: AstExprNode
items: { AstExprTableItem }

Table entries in source order.

openBraceToken: CstToken<"{">

The opening { token.

closeBraceToken: CstToken<"}">

The closing } token.

AstExprUnary

A unary operator expression.

type AstExprUnary = AstExprNode<"unary"> & { op: string, expr: AstExpr, opToken: CstToken<string> }
Implements: AstExprNode
op: string

The normalized unary operator name.

expr: AstExpr

The operand expression.

opToken: CstToken<string>

The unary operator token, such as not, -, or #.

AstExprBinary

A binary operator expression.

type AstExprBinary = AstExprNode<"binary"> & { op: string, left: AstExpr, right: AstExpr, opToken: CstToken<string> }
Implements: AstExprNode
op: string

The normalized binary operator name.

left: AstExpr

The left operand.

right: AstExpr

The right operand.

opToken: CstToken<string>

The binary operator token, such as +, and, or ==.

AstExprTypeAssertion

A type assertion expression.

type AstExprTypeAssertion = AstExprNode<"typeAssertion"> & { expr: AstExpr, annotation: AstType, opToken: CstToken<"::"> }
Implements: AstExprNode
expr: AstExpr

The expression being asserted.

annotation: AstType

The asserted type annotation.

opToken: CstToken<"::">

The :: token.

AstExprIfElse

An if expression.

type AstExprIfElse = AstExprNode<"ifElse"> & { condition: AstExpr, thenExpr: AstExpr?, elseExpr: AstExpr?, ifKeywordToken: CstToken<"if" | "elseif">?, thenKeywordToken: CstToken<"then">?, elseKeywordToken: CstToken<"else" | "elseif">? }
Implements: AstExprNode
condition: AstExpr

The condition expression.

thenExpr: AstExpr?

The expression after then.

elseExpr: AstExpr?

The expression after else.

ifKeywordToken: CstToken<"if" | "elseif">?

The if token, or elseif token for chained branches represented as nested nodes.

thenKeywordToken: CstToken<"then">?

The then keyword token.

elseKeywordToken: CstToken<"else" | "elseif">?

The else or elseif keyword token.

AstExprInterpString

An interpolated string expression.

type AstExprInterpString = AstExprNode<"interpString"> & { [string]: any }
Implements: AstExprNode
strings: { string }

Literal string segments between interpolation holes.

expressions: { AstExpr }

Expressions inside interpolation holes.

AstExprInstantiate

An expression with explicit type instantiation.

type AstExprInstantiate = AstExprNode<"instantiate"> & { [string]: any }
Implements: AstExprNode
expr: AstExpr

The expression being instantiated.

typeArguments: { TypeOrPack }

The explicit type and type-pack arguments.

leftArrow1Token: CstToken<"<">

The first < token in the opening <<.

leftArrow2Token: CstToken<"<">

The second < token in the opening <<.

rightArrow1Token: CstToken<">">

The first > token in the closing >>.

rightArrow2Token: CstToken<">">

The second > token in the closing >>.

AstExprError

An expression placeholder produced for parse errors.

type AstExprError = AstExprNode<"error"> & { expressions: { AstExpr }, messageIndex: number, spanToken: CstToken<string> }
Implements: AstExprNode
expressions: { AstExpr }

Child expressions retained by the parser around the error.

messageIndex: number

Index into the parser error list for the associated diagnostic.

spanToken: CstToken<string>

The concrete source span token synthesized for the error range.

AstStatBlock

A statement block.

type AstStatBlock = AstStatNode<"block"> & { body: { AstStat }, eofToken: CstToken<"">? }
Implements: AstStatNode
body: { AstStat }

Statements in the block.

eofToken: CstToken<"">?

The zero-width end-of-file token for the root block, when emitted.

AstStatIf

An if statement.

type AstStatIf = AstStatNode<"if"> & { condition: AstExpr, thenBody: AstStatBlock, elseBody: AstStatBlock?, thenLocation: Location?, elseLocation: Location?, ifKeywordToken: CstToken<"if">?, thenKeywordToken: CstToken<"then">?, elseKeywordToken: CstToken<"else" | "elseif">?, endKeywordToken: CstToken<"end"> }
Implements: AstStatNode
condition: AstExpr

The condition expression.

thenBody: AstStatBlock

The block executed when the condition is truthy.

elseBody: AstStatBlock?

The else or elseif block.

thenLocation: Location?

The source span of the then keyword.

elseLocation: Location?

The source span of the else keyword.

ifKeywordToken: CstToken<"if">?

The if keyword token. Nested elseif nodes omit this because their parent owns the elseif token.

thenKeywordToken: CstToken<"then">?

The then keyword token.

elseKeywordToken: CstToken<"else" | "elseif">?

The else or elseif keyword token.

endKeywordToken: CstToken<"end">

The end keyword token closing the statement.

AstStatWhile

A while loop statement.

type AstStatWhile = AstStatNode<"while"> & { condition: AstExpr, body: AstStatBlock, doLocation: Location?, whileKeywordToken: CstToken<"while">, doKeywordToken: CstToken<"do">?, endKeywordToken: CstToken<"end"> }
Implements: AstStatNode
condition: AstExpr

The loop condition expression.

The loop body block.

doLocation: Location?

The source span of the do keyword.

whileKeywordToken: CstToken<"while">

The while keyword token.

doKeywordToken: CstToken<"do">?

The do keyword token.

endKeywordToken: CstToken<"end">

The end keyword token closing the loop.

AstStatRepeat

A repeat-until loop statement.

type AstStatRepeat = AstStatNode<"repeat"> & { body: AstStatBlock, condition: AstExpr, repeatKeywordToken: CstToken<"repeat">, untilKeywordToken: CstToken<"until"> }
Implements: AstStatNode

The repeated body block.

condition: AstExpr

The condition expression after until.

repeatKeywordToken: CstToken<"repeat">

The repeat keyword token.

untilKeywordToken: CstToken<"until">

The until keyword token.

AstStatBreak

A break statement.

type AstStatBreak = AstStatNode<"break"> & { breakKeywordToken: CstToken<"break"> }
Implements: AstStatNode
breakKeywordToken: CstToken<"break">

The break keyword token.

AstStatContinue

A continue statement.

type AstStatContinue = AstStatNode<"continue"> & { continueKeywordToken: CstToken<"continue"> }
Implements: AstStatNode
continueKeywordToken: CstToken<"continue">

The continue keyword token.

AstStatReturn

A return statement.

type AstStatReturn = AstStatNode<"return"> & { [string]: any }
Implements: AstStatNode
list: { AstExpr }

Returned expression list.

returnKeywordToken: CstToken<"return">

The return keyword token.

AstStatExpr

A statement that consists of a single expression.

type AstStatExpr = AstStatNode<"expr"> & { expr: AstExpr }
Implements: AstStatNode
expr: AstExpr

The expression being used as a statement.

AstStatLocal

A local variable declaration statement.

type AstStatLocal = AstStatNode<"local"> & { [string]: any }
Implements: AstStatNode
vars: { AstLocal }

Declared local bindings.

values: { AstExpr }

Initializer expressions after =.

isConst: boolean

True when the declaration uses const.

equalsSignLocation: Location?

The source span of the = token.

localKeywordToken: CstToken<"local" | "const">

The local or const declaration keyword token.

equalsToken: CstToken<"=">?

The = token before initializer expressions.

AstStatFor

A numeric for loop statement.

type AstStatFor = AstStatNode<"for"> & { var: AstLocal, from: AstExpr, to: AstExpr, step: AstExpr?, body: AstStatBlock, doLocation: Location?, forKeywordToken: CstToken<"for">, equalsToken: CstToken<"=">, endCommaToken: CstToken<",">, stepCommaToken: CstToken<",">?, doKeywordToken: CstToken<"do">?, endKeywordToken: CstToken<"end"> }
Implements: AstStatNode

The loop variable local.

from: AstExpr

The initial value expression.

The limit value expression.

step: AstExpr?

The optional step expression.

The loop body block.

doLocation: Location?

The source span of the do keyword.

forKeywordToken: CstToken<"for">

The for keyword token.

equalsToken: CstToken<"=">

The = token after the loop variable.

endCommaToken: CstToken<",">

The comma token between the initial and limit expressions.

stepCommaToken: CstToken<",">?

The comma token before the step expression.

doKeywordToken: CstToken<"do">?

The do keyword token.

endKeywordToken: CstToken<"end">

The end keyword token closing the loop.

AstStatForIn

A generic for-in loop statement.

type AstStatForIn = AstStatNode<"forIn"> & { [string]: any }
Implements: AstStatNode
vars: { AstLocal }

Loop variable locals.

values: { AstExpr }

Iterator expressions after in.

The loop body block.

inLocation: Location?

The source span of the in keyword.

doLocation: Location?

The source span of the do keyword.

forKeywordToken: CstToken<"for">

The for keyword token.

inKeywordToken: CstToken<"in">?

The in keyword token.

doKeywordToken: CstToken<"do">?

The do keyword token.

endKeywordToken: CstToken<"end">

The end keyword token closing the loop.

AstStatAssign

An assignment statement.

type AstStatAssign = AstStatNode<"assign"> & { [string]: any }
Implements: AstStatNode
vars: { AstExpr }

Assignment target expressions.

values: { AstExpr }

Value expressions.

equalsToken: CstToken<"=">

The = token between targets and values.

AstStatCompoundAssign

A compound assignment statement.

type AstStatCompoundAssign = AstStatNode<"compoundAssign"> & { op: string, var: AstExpr, value: AstExpr, opToken: CstToken<string> }
Implements: AstStatNode
op: string

The normalized compound operator name.

var: AstExpr

The assignment target expression.

value: AstExpr

The value expression.

opToken: CstToken<string>

The compound assignment operator token, such as += or ..=.

AstStatFunction

A global or table function declaration statement.

type AstStatFunction = AstStatNode<"function"> & { name: AstExpr, func: AstExprFunction, functionKeywordToken: CstToken<"function"> }
Implements: AstStatNode
name: AstExpr

The function name expression.

The function body expression node.

functionKeywordToken: CstToken<"function">

The function keyword token that starts the declaration.

AstStatLocalFunction

A local function declaration statement.

type AstStatLocalFunction = AstStatNode<"localFunction"> & { name: AstLocal, func: AstExprFunction, isConst: boolean, localKeywordToken: CstToken<"local">, functionKeywordToken: CstToken<"function">, nameToken: CstToken<string> }
Implements: AstStatNode
name: AstLocal

The declared local function binding.

The function body expression node.

isConst: boolean

True when the local function declaration is const.

localKeywordToken: CstToken<"local">

The local keyword token.

functionKeywordToken: CstToken<"function">

The function keyword token.

nameToken: CstToken<string>

The local function name identifier token.

AstStatTypeAlias

A type alias declaration statement.

type AstStatTypeAlias = AstStatNode<"typeAlias"> & { name: string, nameLocation: Location, generics: { AstGenericType }, genericPacks: { AstGenericTypePack }, aliasedType: AstType, exported: boolean, exportKeywordToken: CstToken<"export">?, typeKeywordToken: CstToken<"type">, nameToken: CstToken<string>, equalsToken: CstToken<"="> }
Implements: AstStatNode
name: string

The alias name.

nameLocation: Location

The source span of the alias name.

generics: { AstGenericType }

Generic type parameters.

genericPacks: { AstGenericTypePack }

Generic type-pack parameters.

aliasedType: AstType

The aliased type.

exported: boolean

True when this is an exported type alias.

exportKeywordToken: CstToken<"export">?

The export keyword token.

typeKeywordToken: CstToken<"type">

The type keyword token.

nameToken: CstToken<string>

The alias name identifier token.

equalsToken: CstToken<"=">

The = token before the aliased type.

AstStatTypeFunction

A type function declaration statement.

type AstStatTypeFunction = AstStatNode<"typeFunction"> & { name: string, nameLocation: Location, body: AstExprFunction?, exported: boolean, hasErrors: boolean, exportKeywordToken: CstToken<"export">?, typeKeywordToken: CstToken<"type">, functionKeywordToken: CstToken<"function">, nameToken: CstToken<string> }
Implements: AstStatNode
name: string

The type function name.

nameLocation: Location

The source span of the type function name.

The function body, when the parser produced one.

exported: boolean

True when this is an exported type function.

hasErrors: boolean

True when the parser reported errors inside this declaration.

exportKeywordToken: CstToken<"export">?

The export keyword token.

typeKeywordToken: CstToken<"type">

The type keyword token.

functionKeywordToken: CstToken<"function">

The function keyword token.

nameToken: CstToken<string>

The type function name identifier token.

AstClassMember

A member entry in a class declaration.

type AstClassMember = { kind: "property", qualifierLocation: Location?, name: string, nameLocation: Location, typeColonLocation: Location?, type: AstType? } | { kind: "method", qualifierLocation: Location?, keywordLocation: Location, name: string, nameLocation: Location, function: AstExprFunction }

AstStatClass

A class declaration statement.

type AstStatClass = AstStatNode<"class"> & { [string]: any }
Implements: AstStatNode
name: AstLocal

The class local binding.

members: { AstClassMember }

Class property and method members.

exported: boolean

True when this is an exported class declaration.

exportKeywordToken: CstToken<"export">?

The export keyword token.

classKeywordToken: CstToken<"class">?

The class keyword token.

nameToken: CstToken<string>

The class name identifier token.

endKeywordToken: CstToken<"end">

The end keyword token closing the class declaration.

AstStatDeclareGlobal

A declare global statement.

type AstStatDeclareGlobal = AstStatNode<"declareGlobal"> & { name: string, nameLocation: Location, declaredType: AstType, declareKeywordToken: CstToken<"declare">, nameToken: CstToken<string>, colonToken: CstToken<":">? }
Implements: AstStatNode
name: string

The declared global name.

nameLocation: Location

The source span of the global name.

declaredType: AstType

The declared global type.

declareKeywordToken: CstToken<"declare">

The declare keyword token.

nameToken: CstToken<string>

The global name identifier token.

colonToken: CstToken<":">?

The : token before the declared type.

AstStatDeclareFunction

A declare function statement.

type AstStatDeclareFunction = AstStatNode<"declareFunction"> & { attributes: { AstAttr }, name: string, nameLocation: Location, generics: { AstGenericType }, genericPacks: { AstGenericTypePack }, params: TypeList, paramNames: { ArgumentName }, vararg: boolean, varargLocation: Location, returnTypes: AstTypePack?, declareKeywordToken: CstToken<"declare">, functionKeywordToken: CstToken<"function">?, nameToken: CstToken<string> }
Implements: AstStatNode
attributes: { AstAttr }

Attributes applied to the declaration.

name: string

The declared function name.

nameLocation: Location

The source span of the declared function name.

generics: { AstGenericType }

Generic type parameters.

genericPacks: { AstGenericTypePack }

Generic type-pack parameters.

params: TypeList

Parameter types.

paramNames: { ArgumentName }

Optional parameter names.

vararg: boolean

True when the declaration accepts varargs.

varargLocation: Location

The source span of the vararg marker.

returnTypes: AstTypePack?

Return type pack.

declareKeywordToken: CstToken<"declare">

The declare keyword token.

functionKeywordToken: CstToken<"function">?

The function keyword token.

nameToken: CstToken<string>

The function name identifier token.

DeclaredExternTypeProperty

A property inside a declared extern type.

type DeclaredExternTypeProperty = { name: string, nameLocation: Location, type: AstType?, isMethod: boolean, access: TableAccess, location: Location }
name: string

The extern property name.

nameLocation: Location

The source span of the property name.

type: AstType?

The property type.

isMethod: boolean

True when the property is declared as a method.

access: TableAccess

The optional read/write access mode.

location: Location

The full source span of the property declaration.

AstStatDeclareExternType

A declare extern type statement.

type AstStatDeclareExternType = AstStatNode<"declareExternType"> & { name: string, superName: string?, props: { DeclaredExternTypeProperty }, indexer: TableIndexer?, declareKeywordToken: CstToken<"declare">, endKeywordToken: CstToken<"end"> }
Implements: AstStatNode
name: string

The declared extern type name.

superName: string?

The optional supertype name.

Declared properties.

indexer: TableIndexer?

Optional indexer declaration.

declareKeywordToken: CstToken<"declare">

The declare keyword token.

endKeywordToken: CstToken<"end">

The end keyword token closing the extern type.

AstStatError

A statement placeholder produced for parse errors.

type AstStatError = AstStatNode<"error"> & { expressions: { AstExpr }, statements: { AstStat }, messageIndex: number, spanToken: CstToken<string> }
Implements: AstStatNode
expressions: { AstExpr }

Child expressions retained by the parser around the error.

statements: { AstStat }

Child statements retained by the parser around the error.

messageIndex: number

Index into the parser error list for the associated diagnostic.

spanToken: CstToken<string>

The concrete source span token synthesized for the error range.

AstTypeReference

A named type reference, optionally with a prefix and type arguments.

type AstTypeReference = AstTypeNode<"reference"> & { [string]: any }
Implements: AstTypeNode
hasParameterList: boolean

True when source explicitly included a parameter list.

name: string

The referenced type name.

nameLocation: Location

The source span of the referenced type name.

prefix: string?

The optional prefix before a dot.

prefixLocation: Location?

The source span of the optional prefix.

parameters: { TypeOrPack }?

Type and type-pack arguments inside <...>.

prefixToken: CstToken<string>?

The prefix identifier token before the dot.

prefixDotToken: CstToken<".">?

The . token between prefix and name.

nameToken: CstToken<string>

The referenced type name identifier token.

openParametersToken: CstToken<"<">?

The opening < token for type parameters.

closeParametersToken: CstToken<">">?

The closing > token for type parameters.

AstTypeTableProp

A named property inside a table type.

type AstTypeTableProp = { name: string, type: AstType, location: Location, access: TableAccess, accessLocation: Location? }
name: string

The property name.

type: AstType

The property type.

location: Location

The full source span of the property entry.

access: TableAccess

The optional read/write access mode.

accessLocation: Location?

The source span of the access qualifier, when present.

AstTypeTable

A table type.

type AstTypeTable = AstTypeNode<"table"> & { [string]: any }
Implements: AstTypeNode
props: { AstTypeTableProp }

Named property entries.

indexer: TableIndexer?

Optional indexer entry.

openBraceToken: CstToken<"{">

The opening { token.

closeBraceToken: CstToken<"}">

The closing } token.

AstTypeFunction

A function type.

type AstTypeFunction = AstTypeNode<"function"> & { [string]: any }
Implements: AstTypeNode
attributes: { AstAttr }

Attributes applied to the function type.

generics: { AstGenericType }

Generic type parameters.

genericPacks: { AstGenericTypePack }

Generic type-pack parameters.

argTypes: TypeList

Argument type list.

argNames: { ArgumentName? }

Optional argument names paired with argument types.

returnTypes: AstTypePack?

Return type pack after ->.

openGenericsToken: CstToken<"<">?

The opening < token for generic parameters.

closeGenericsToken: CstToken<">">?

The closing > token for generic parameters.

openArgsToken: CstToken<"(">?

The opening ( token for argument types.

closeArgsToken: CstToken<")">?

The closing ) token for argument types.

returnArrowToken: CstToken<"->">?

The -> token before return types.

AstTypeTypeof

A typeof type expression.

type AstTypeTypeof = AstTypeNode<"typeof"> & { expr: AstExpr, typeofKeywordToken: CstToken<"typeof">, openParenToken: CstToken<"(">?, closeParenToken: CstToken<")">? }
Implements: AstTypeNode
expr: AstExpr

The expression inside typeof(...).

typeofKeywordToken: CstToken<"typeof">

The typeof keyword token.

openParenToken: CstToken<"(">?

The opening ( token.

closeParenToken: CstToken<")">?

The closing ) token.

AstTypeOptional

An optional type, such as T?.

type AstTypeOptional = AstTypeNode<"optional"> & { token: CstToken<"?"> }
Implements: AstTypeNode
token: CstToken<"?">

The ? token after the base type.

AstTypeUnion

A union type.

type AstTypeUnion = AstTypeNode<"union"> & { [string]: any }
Implements: AstTypeNode
types: { AstType }

Type branches in the union.

leadingSeparatorToken: CstToken<"|">?

A leading | token when the union starts with one.

AstTypeIntersection

An intersection type.

type AstTypeIntersection = AstTypeNode<"intersection"> & { [string]: any }
Implements: AstTypeNode
types: { AstType }

Type branches in the intersection.

leadingSeparatorToken: CstToken<"&">?

A leading & token when the intersection starts with one.

AstTypeError

A type placeholder produced for parse errors.

type AstTypeError = AstTypeNode<"error"> & { types: { AstType }, isMissing: boolean, messageIndex: number, spanToken: CstToken<string> }
Implements: AstTypeNode
types: { AstType }

Child types retained by the parser around the error.

isMissing: boolean

True when the type node represents a missing type.

messageIndex: number

Index into the parser error list for the associated diagnostic.

spanToken: CstToken<string>

The concrete source span token synthesized for the error range.

AstTypeSingletonBool

A singleton boolean type.

type AstTypeSingletonBool = AstTypeNode<"singletonBool"> & { value: boolean, token: CstToken<"true" | "false"> }
Implements: AstTypeNode
value: boolean

The parsed boolean value.

token: CstToken<"true" | "false">

The true or false token.

AstTypeSingletonString

A singleton string type.

type AstTypeSingletonString = AstTypeNode<"singletonString"> & { value: string, token: CstToken<string> }
Implements: AstTypeNode
value: string

The decoded string value.

token: CstToken<string>

The exact string literal token, preserving raw spelling.

AstTypeGroup

A parenthesized type.

type AstTypeGroup = AstTypeNode<"group"> & { innerType: AstType, openParenToken: CstToken<"(">, closeParenToken: CstToken<")"> }
Implements: AstTypeNode
innerType: AstType

The type inside the parentheses.

openParenToken: CstToken<"(">

The opening ( token.

closeParenToken: CstToken<")">

The closing ) token.

AstTypePackExplicit

An explicit type pack.

type AstTypePackExplicit = AstTypePackNode<"explicit"> & { [string]: any }
Implements: AstTypePackNode
typeList: TypeList

The contained type list.

openParenToken: CstToken<"(">?

The opening ( token around the pack.

closeParenToken: CstToken<")">?

The closing ) token around the pack.

AstTypePackVariadic

A variadic type pack.

type AstTypePackVariadic = AstTypePackNode<"variadic"> & { variadicType: AstType, ellipsisToken: CstToken<"..."> }
Implements: AstTypePackNode
variadicType: AstType

The repeated type.

ellipsisToken: CstToken<"...">

The ... token before or after the variadic type, depending on source form.

AstTypePackGeneric

A generic type-pack reference.

type AstTypePackGeneric = AstTypePackNode<"generic"> & { name: string, nameToken: CstToken<string>, ellipsisToken: CstToken<"...">? }
Implements: AstTypePackNode
name: string

The generic pack name.

nameToken: CstToken<string>

The generic pack identifier token.

ellipsisToken: CstToken<"...">?

The ... token associated with the generic pack spelling.

AstTypePackUnknown

An unknown type-pack placeholder.

type AstTypePackUnknown = AstTypePackNode<"unknown"> & { token: CstToken<string> }
Implements: AstTypePackNode
token: CstToken<string>

The token that produced the unknown type pack.

AstTypeUnknown

An unknown type placeholder.

type AstTypeUnknown = AstTypeNode<"unknown"> & { token: CstToken<string> }
Implements: AstTypeNode
token: CstToken<string>

The token that produced the unknown type.

AstExpr

Any expression node emitted by the serializer.

AstStat

Any statement node emitted by the serializer.

AstType

Any type node emitted by the serializer.

AstTypePack

Any type-pack node emitted by the serializer.

AstAny

Any AST payload node emitted by the serializer.