luaut-parser 4.0.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -41,7 +41,7 @@ interface OperatorToken extends BaseToken {
41
41
  type: "Operator";
42
42
  value: typeof Operators[number];
43
43
  }
44
- declare const Punctuators: readonly ["::", "(", ")", "{", "}", "[", "]", ";", ":", ",", ".", "?", "->", "&", "|", "@"];
44
+ declare const Punctuators: readonly ["::", "(", ")", "{", "}", "[", "]", ";", ":", ",", ".", "?", "=>", "->", "&", "|", "@"];
45
45
  interface PunctuatorToken extends BaseToken {
46
46
  type: "Punctuator";
47
47
  value: typeof Punctuators[number];
@@ -181,14 +181,16 @@ interface ImportStatement extends BaseNode {
181
181
  /** `export const x = 1`, `export let y = 2`, `export function f() end` */
182
182
  interface ExportStatement extends BaseNode {
183
183
  type: "ExportStatement";
184
- declaration: VariableDeclaration | FunctionDeclaration;
184
+ declaration: VariableDeclaration | FunctionDeclaration | ClassDeclaration;
185
185
  }
186
186
  /** `export default <expr>` — mirrors JS default export / dynamic import()'s
187
187
  * `{ default: ... }` shape. Distinct from ExportStatement because the
188
188
  * right-hand side is any expression, not necessarily a declaration. */
189
189
  interface ExportDefaultStatement extends BaseNode {
190
190
  type: "ExportDefaultStatement";
191
- declaration: Expression;
191
+ /** `export default class Name ... end` keeps its name: it declares the
192
+ * class here as well as exporting it, the way TypeScript's does. */
193
+ declaration: Expression | ClassDeclaration;
192
194
  }
193
195
  interface ExportSpecifier extends BaseNode {
194
196
  type: "ExportSpecifier";
@@ -210,7 +212,7 @@ interface ExportAllStatement extends BaseNode {
210
212
  type: "ExportAllStatement";
211
213
  source: StringLiteral;
212
214
  }
213
- type Statement = VariableDeclaration | FunctionDeclaration | FunctionDeclarationStatement | AssignmentStatement | CompoundAssignmentStatement | CallStatement | DoStatement | WhileStatement | RepeatStatement | IfStatement | NumericForStatement | GenericForStatement | ReturnStatement | BreakStatement | ContinueStatement | TypeAliasStatement | ExportTypeAliasStatement | ImportStatement | ExportStatement | ExportDefaultStatement | ExportNamedStatement | ExportAllStatement | DeclareStatement | DeclareClassStatement | ErrorStatement;
215
+ type Statement = VariableDeclaration | FunctionDeclaration | FunctionDeclarationStatement | ClassDeclaration | AssignmentStatement | CompoundAssignmentStatement | CallStatement | DoStatement | WhileStatement | RepeatStatement | IfStatement | NumericForStatement | GenericForStatement | ReturnStatement | BreakStatement | ContinueStatement | TypeAliasStatement | ExportTypeAliasStatement | ImportStatement | ExportStatement | ExportDefaultStatement | ExportNamedStatement | ExportAllStatement | DeclareStatement | DeclareClassStatement | ErrorStatement;
214
216
  /** `declare game: DataModel` / `declare function require(m: string): unknown`
215
217
  * — an ambient value/function declaration for a definitions file (`.d.luaut`).
216
218
  * Contributes a global type; emits no runtime code. */
@@ -336,6 +338,94 @@ interface FunctionName extends BaseNode {
336
338
  path: Identifier[];
337
339
  method?: Identifier;
338
340
  }
341
+ /** `class Name extends Base ... end` — luaut's one runtime class form.
342
+ *
343
+ * It is sugar, and the shape it stands for is the ordinary Lua one: the
344
+ * class is a single table holding the methods and the statics, and an
345
+ * instance is a table whose metatable points at it. An instance therefore
346
+ * references *the class*, not a copy and not a prototype chain of its own —
347
+ * one class, one place its behaviour lives.
348
+ *
349
+ * The declaration contributes both a type (the instance type, nominal, as
350
+ * `declare class` does) and a value (the class table, with `new` and the
351
+ * statics on it). */
352
+ interface ClassDeclaration extends BaseNode {
353
+ type: "ClassDeclaration";
354
+ name: Identifier;
355
+ /** `class Box<T>` — the instance type is then generic, and `Box<number>`
356
+ * instantiates it. */
357
+ typeParams: GenericTypeParameter[];
358
+ /** `extends Base` / `extends Box<number>` — another class declared in
359
+ * this file or imported, with its own arguments filled in. */
360
+ superclass?: Identifier;
361
+ /** The arguments `extends Box<number>` was written with. */
362
+ superArguments?: TypeNode[];
363
+ members: ClassMember[];
364
+ }
365
+ /** `class ... end` written where a value goes: `const Counter = class ... end`,
366
+ * `export default class ... end`. The name is optional and, when written, is
367
+ * visible only inside the class — as in JavaScript. An expression has no name
368
+ * to instantiate, so it takes no type parameters. */
369
+ interface ClassExpression extends BaseNode {
370
+ type: "ClassExpression";
371
+ name?: Identifier;
372
+ superclass?: Identifier;
373
+ superArguments?: TypeNode[];
374
+ members: ClassMember[];
375
+ }
376
+ type ClassMember = ClassField | ClassMethod | ClassAccessor | ClassConstructor;
377
+ /** The two ways a class is written. Everything after parsing treats them
378
+ * alike: only the name and the type parameters differ. */
379
+ type ClassLike = ClassDeclaration | ClassExpression;
380
+ /** `x: number` / `x = 1` / `static count = 0`. An instance field is assigned
381
+ * when the instance is built, before the constructor body runs; a `static`
382
+ * one is assigned on the class table, once. */
383
+ interface ClassField extends BaseNode {
384
+ type: "ClassField";
385
+ name: Identifier;
386
+ isStatic: boolean;
387
+ typeAnnotation?: TypeNode;
388
+ init?: Expression;
389
+ }
390
+ /** `function name(...) ... end` inside a class body — `this` is bound in it.
391
+ * A `static` one is a plain function on the class table, with no `this`. */
392
+ interface ClassMethod extends BaseNode {
393
+ type: "ClassMethod";
394
+ name: Identifier;
395
+ isStatic: boolean;
396
+ func: FunctionBody;
397
+ /** TS-style overload signatures preceding the implementation. */
398
+ signatures?: FunctionSignature[];
399
+ }
400
+ /** `get name(): T ... end` / `set name(v: T) ... end` — read and written as a
401
+ * property, run as a function. */
402
+ interface ClassAccessor extends BaseNode {
403
+ type: "ClassAccessor";
404
+ kind: "get" | "set";
405
+ name: Identifier;
406
+ isStatic: boolean;
407
+ func: FunctionBody;
408
+ }
409
+ /** `constructor(...) ... end` — runs on a fresh instance. A class that
410
+ * extends another must call `super(...)` before touching `this`. */
411
+ interface ClassConstructor extends BaseNode {
412
+ type: "ClassConstructor";
413
+ func: FunctionBody;
414
+ }
415
+ /** `new Name(args)` — builds an instance. Lowers to the class's own
416
+ * `Name.new(args)`, which is also callable by hand. */
417
+ interface NewExpression extends BaseNode {
418
+ type: "NewExpression";
419
+ callee: Expression;
420
+ arguments: Expression[];
421
+ typeArguments?: (TypeNode | TypePackNode)[];
422
+ }
423
+ /** `super` — only inside a class that extends another: `super(...)` in the
424
+ * constructor runs the base's on this instance, and `super.method(...)` in a
425
+ * method calls the base's version of it. */
426
+ interface SuperExpression extends BaseNode {
427
+ type: "SuperExpression";
428
+ }
339
429
  interface AssignmentStatement extends BaseNode {
340
430
  type: "AssignmentStatement";
341
431
  targets: (Expression | ObjectPattern | ArrayPattern)[];
@@ -349,7 +439,7 @@ interface CompoundAssignmentStatement extends BaseNode {
349
439
  }
350
440
  interface CallStatement extends BaseNode {
351
441
  type: "CallStatement";
352
- expression: CallExpression | MethodCallExpression;
442
+ expression: CallExpression | MethodCallExpression | NewExpression;
353
443
  }
354
444
  interface DoStatement extends BaseNode {
355
445
  type: "DoStatement";
@@ -422,7 +512,7 @@ interface GenericTypeParameter extends BaseNode {
422
512
  constraint?: TypeNode;
423
513
  default?: TypeNode | TypePackNode;
424
514
  }
425
- type Expression = Identifier | NilLiteral | BooleanLiteral | NumberLiteral | StringLiteral | InterpolatedStringExpression | VarargExpression | FunctionExpression | TableExpression | ArrayExpression | BinaryExpression | UnaryExpression | MemberExpression | IndexExpression | CallExpression | MethodCallExpression | ParenthesizedExpression | TypeAssertionExpression | SatisfiesExpression | AsConstExpression | IfElseExpression | ErrorExpression;
515
+ type Expression = Identifier | NilLiteral | BooleanLiteral | NumberLiteral | StringLiteral | InterpolatedStringExpression | VarargExpression | FunctionExpression | TableExpression | ArrayExpression | BinaryExpression | UnaryExpression | MemberExpression | IndexExpression | CallExpression | MethodCallExpression | NewExpression | SuperExpression | ClassExpression | SpreadElement | ParenthesizedExpression | TypeAssertionExpression | SatisfiesExpression | AsConstExpression | IfElseExpression | ErrorExpression;
426
516
  /** An expression that could not be parsed. Only produced in recovery mode
427
517
  * (`parseWithRecovery`), where a broken initializer, condition, field value or
428
518
  * argument keeps its place in the tree; its span covers the skipped tokens
@@ -474,6 +564,11 @@ interface VarargExpression extends BaseNode {
474
564
  }
475
565
  interface FunctionParameter extends BaseNode {
476
566
  type: "FunctionParameter";
567
+ /** `...rest: T[]` — every argument from this position on, as an array,
568
+ * the way JavaScript's rest parameter collects them. It is always last,
569
+ * and the function is a vararg function: `...` still means Lua's pack
570
+ * (`const a, b = ...`), and this is the array of it. */
571
+ rest?: boolean;
477
572
  /** `name?: T` — the argument may be omitted, and its type admits `nil`. */
478
573
  optional?: boolean;
479
574
  /** the parameter name, or `""` when `pattern` is set */
@@ -534,7 +629,15 @@ interface ArrayExpression extends BaseNode {
534
629
  type: "ArrayExpression";
535
630
  elements: (Expression | SpreadElement)[];
536
631
  }
537
- /** `...expr` inside an array literal. */
632
+ /** `...expr` the values of an array, one after another, where a list of
633
+ * values is written: inside an array literal (`[...xs, 1]`) and in a call's
634
+ * arguments (`f(a, ...rest)`). It is not a value of its own, and the parser
635
+ * only produces one in those two places.
636
+ *
637
+ * Lua spreads with `table.unpack`, which only yields every value when it is
638
+ * written last; anywhere else the compiler builds the whole list first. Bare
639
+ * `...` is unaffected — that is the vararg pack, and `f(...)` passes it on
640
+ * as it always did. */
538
641
  interface SpreadElement extends BaseNode {
539
642
  type: "SpreadElement";
540
643
  argument: Expression;
@@ -574,6 +677,15 @@ interface CallExpression extends BaseNode {
574
677
  /** `f?.(...)` — see `MemberExpression.optional`. The call does not happen,
575
678
  * and the arguments are not evaluated, when `callee` is nil. */
576
679
  optional?: boolean;
680
+ /** The `(` opened on a line after the callee ended:
681
+ *
682
+ * const value = map[key]
683
+ * ("text"):upper()
684
+ *
685
+ * is one statement — a call of `map[key]` — because a line break does
686
+ * not end a statement, in Lua or in JavaScript. Flagged here so the
687
+ * analyzer can say so; Lua 5.1 calls it "ambiguous syntax". */
688
+ argumentsOnNewLine?: boolean;
577
689
  }
578
690
  interface MethodCallExpression extends BaseNode {
579
691
  type: "MethodCallExpression";
@@ -767,6 +879,8 @@ interface TupleTypeNode extends BaseNode {
767
879
  }
768
880
  interface FunctionTypeParameter extends BaseNode {
769
881
  type: "FunctionTypeParameter";
882
+ /** `(...rest: T[]) -> R` — see `FunctionParameter.rest`. */
883
+ rest?: boolean;
770
884
  /** `name?: T` — the argument may be omitted, and its type admits `nil`. */
771
885
  optional?: boolean;
772
886
  name?: string;
@@ -827,7 +941,10 @@ interface ParserOptions {
827
941
  }
828
942
  declare function parse(source: string): Program;
829
943
  declare function parseTokens(tokens: Token[]): Program;
830
- declare function parseExpressionFromSource(raw: string): Expression;
944
+ /** `inClass` carries the enclosing class in. A template's `${...}` is parsed
945
+ * on its own, so without it a `super` written inside one in a class method
946
+ * would read as an ordinary name. */
947
+ declare function parseExpressionFromSource(raw: string, inClass?: boolean): Expression;
831
948
  interface RecoverResult {
832
949
  program: Program;
833
950
  errors: ParseError[];
@@ -874,7 +991,7 @@ interface Binding {
874
991
  isConst?: boolean;
875
992
  /** Set when the binding comes from something other than `const` / `let`,
876
993
  * which is also what an error about reassigning it names. */
877
- declaredBy?: "import" | "namespace" | "function" | "type";
994
+ declaredBy?: "import" | "namespace" | "function" | "type" | "class";
878
995
  }
879
996
  interface ScopeDiagnostic {
880
997
  /** the offending node (redeclaration site, or assignment target) */
@@ -1007,6 +1124,13 @@ interface ClassInfo {
1007
1124
  superclass?: string;
1008
1125
  /** The class itself, then each class it extends, nearest first. */
1009
1126
  ancestors: readonly string[];
1127
+ /** For a generic class, the arguments each level of the chain was made
1128
+ * with, by class name — its own and every class it extends. `Box<number>`
1129
+ * holds `{ Box: [number] }`, and a `class Ints extends Box<number>` holds
1130
+ * the same entry under `Box`, which is what tells it apart from a
1131
+ * `Box<string>`. A class with no type parameters anywhere carries
1132
+ * nothing, and costs nothing. */
1133
+ typeArguments?: ReadonlyMap<string, readonly Type[]>;
1010
1134
  }
1011
1135
  declare function isClassType(t: Type): t is ObjectType & {
1012
1136
  class: ClassInfo;
@@ -1164,8 +1288,6 @@ declare function tuple(elements: Type[], isPack?: boolean): TupleType;
1164
1288
  declare function objectType(entries: Iterable<[string, ObjectProperty]>, indexer?: ObjectType["indexer"], frozen?: boolean): ObjectType;
1165
1289
  declare function fn(params: FunctionParam[], returns: Type, varargs?: Type, typeParams?: string[], predicate?: TypePredicate): FunctionType;
1166
1290
  declare function substitute(t: Type, subst: Map<string, Type>): Type;
1167
- /** Infer generic bindings by structurally matching a (possibly generic)
1168
- * `param` type against a concrete `arg` type. Accumulates into `out`. */
1169
1291
  declare function unify(param: Type, arg: Type, vars: Set<string>, out: Map<string, Type>): void;
1170
1292
  declare function union(types: Type[]): Type;
1171
1293
  declare function intersection(types: Type[]): Type;
@@ -1178,6 +1300,7 @@ declare function optional(t: Type): Type;
1178
1300
  * into arrays/tuples/objects/unions. */
1179
1301
  declare function widen(t: Type): Type;
1180
1302
  declare function setAliasExpander(fn: ((t: GenericRefType) => Type) | undefined): void;
1303
+ declare function setDeferredBound(fn: ((t: Type) => Type | undefined) | undefined): void;
1181
1304
  declare function isAssignable(rawA: Type, rawB: Type): boolean;
1182
1305
  declare function equalTypes(a: Type, b: Type): boolean;
1183
1306
  /** Keep the parts of `t` compatible with `filter` — TypeScript's
@@ -1223,7 +1346,7 @@ interface TypeDiagnostic {
1223
1346
  /** Usually an expression or statement; a type where the type is wrong
1224
1347
  * (`declare class A extends NotAClass`), or a block where nothing in it
1225
1348
  * is to blame (a function that never returns). Only its span is read. */
1226
- node: Expression | Statement | TypeNode | Block;
1349
+ node: Expression | Statement | TypeNode | Block | ClassMember;
1227
1350
  message: string;
1228
1351
  }
1229
1352
  interface TypeAnalysis {
@@ -1407,14 +1530,14 @@ declare function resolveTypeLibraries(config: LuautConfig, host?: ProjectHost):
1407
1530
  * and asks a library about everything else.
1408
1531
  *
1409
1532
  * These types are declarations only: nothing here runs, and the parser never
1410
- * loads a lowering module. They live here so a library can be written in
1411
- * TypeScript against the same contract the compiler implements, without
1412
- * depending on the compiler.
1413
- *
1414
- * // lowering.ts, in a type library
1415
- * import type { LoweringPlugin } from "luaut-parser"
1533
+ * loads a lowering module. They live here so a library can be checked against
1534
+ * the same contract the compiler implements, without depending on the
1535
+ * compiler in TypeScript, or by JSDoc in the JavaScript it ships:
1416
1536
  *
1417
- * const plugin: LoweringPlugin = {
1537
+ * // lowering.mjs, in a type library
1538
+ * // @ts-check
1539
+ * /** @type {import("luaut-parser").LoweringPlugin} *\/
1540
+ * const plugin = {
1418
1541
  * runtime: { array: "local __NAME__ = {}\n..." },
1419
1542
  * methodCall({ method, receiver, use }) {
1420
1543
  * if (receiver?.kind === "array" && method === "filter") {
@@ -1507,4 +1630,4 @@ declare const luautparser: {
1507
1630
  readonly analyzeTypes: typeof analyzeTypes;
1508
1631
  };
1509
1632
 
1510
- export { type AnalyzeTypesOptions, type AnyType, type ArrayExpression, type ArrayPattern, type ArrayPatternElement, type ArrayType, type ArrayTypeNode, type AsConstExpression, type AssignmentStatement, type BaseNode, type BaseToken, type BinaryExpression, BinaryOperators, type Binding, type BindingId, type BindingKind, type BindingTarget, type Block, type BooleanLiteral, type BreakStatement, CONFIG_FILE_NAMES, type CallExpression, type CallStatement, type ClassInfo, type CompoundAssignmentStatement, type ConditionalType, type ConditionalTypeNode, type ConfigLookup, type ConfigProblem, type ContinueStatement, type DeclareClassStatement, type DeclareStatement, type DifferenceType, type DifferenceTypeNode, type Directive, type DirectiveKind, type DirectiveOutcome, type Directives, type DoStatement, type EOFToken, type ErrorExpression, type ErrorStatement, type ExportAllStatement, type ExportDefaultStatement, type ExportNamedStatement, type ExportSpecifier, type ExportStatement, type ExportTypeAliasStatement, type ExportedType, type Expression, type FunctionBody, type FunctionDeclaration, type FunctionDeclarationStatement, type FunctionExpression, type FunctionName, type FunctionParam, type FunctionParameter, type FunctionSignature, type FunctionType, type FunctionTypeNode, type FunctionTypeParameter, type GenericForStatement, type GenericRefType, type GenericTypeParameter, type Identifier, type IdentifierPattern, type IdentifierToken, type IfClause, type IfElseExpression, type IfStatement, type ImportSpecifier, type ImportStatement, type IndexExpression, type IndexedAccessType, type IndexedAccessTypeNode, type InferType, type InferTypeNode, type InterpolatedStringExpression, type InterpolatedStringPart, type InterpolatedStringPart_Expression, type InterpolatedStringPart_String, type InterpolatedStringToken, type IntersectionType, type IntersectionTypeNode, type KeyofType, type KeyofTypeNode, type KeywordToken, Keywords, LexError, type LiteralToken, type LiteralType, type LoweringModule, type LoweringPlugin, type LuautConfig, type MappedType, type MappedTypeNode, type MemberExpression, type MethodCall, type MethodCallExpression, type MethodLowering, type ModuleExports, type NeverType, type NilLiteral, type Node, type NumberLiteral, type NumericForStatement, type ObjectPattern, type ObjectPatternProperty, type ObjectProperty, type ObjectType, type OperatorToken, Operators, PRELUDE_SOURCE, type ParenthesizedExpression, type ParenthesizedTypeNode, ParseError, type ParserOptions, type PrimitiveName, type PrimitiveType, type Program, type ProjectHost, type PunctuatorToken, Punctuators, type RecoverResult, type RepeatStatement, type ReturnStatement, type SatisfiesExpression, type ScopeAnalysis, type ScopeDiagnostic, type SourceComment, type SourceMapNode, type SourceMapOptions, type SourceMapTypes, type SpreadElement, type Statement, type StringLiteral, type TableExpression, type TableField, type TableTypeNode, type TableTypeProperty, type TemplateLiteralType, type TemplateLiteralTypeNode, type Token, type TokenizeOptions, type TupleType, type TupleTypeNode, type Type, type TypeAliasStatement, type TypeAnalysis, type TypeAssertionExpression, type TypeDiagnostic, type TypeLibraries, type TypeLiteralBoolean, type TypeLiteralNumber, type TypeLiteralString, type TypeNode, type TypePackNode, type TypeParamType, type TypePredicate, type TypePredicateNode, type TypeReference, type TypedIdentifier, type TypeofTypeNode, UNUSED_EXPECT_ERROR, type UnaryExpression, UnaryOperators, type UnionType, type UnionTypeNode, type UnknownType, type VarargExpression, type VariableDeclaration, type VariadicTypeNode, type WhileStatement, analyzeScopes, analyzeTypes, anyType, applyDirectives, arrayOf, booleanType, bufferType, containsTypeParam, luautparser as default, difference, directivesOf, equalTypes, falsyType, findConfig, fn, formatType, getBinding, intersection, isAssignable, isClassType, isGlobal, isPossiblyFalsy, isPossiblyTruthy, isUnassignedGlobal, literal, loadConfig, luautparser, matchInfer, moduleCandidates, moduleExports, narrowExclude, narrowFalsy, narrowTo, narrowTruthy, neverType, nilType, nodeHost, numberType, objectType, optional, overlaps, parse, parseExpressionFromSource, parseTokens, parseWithRecovery, primitive, readDirectives, resolveModulePath, resolveTypeLibraries, setAliasExpander, sourceMapTypes, stringType, stripJsonComments, substitute, templateMatches, threadType, tokenize, tuple, typeParam, unify, union, unknownType, widen };
1633
+ export { type AnalyzeTypesOptions, type AnyType, type ArrayExpression, type ArrayPattern, type ArrayPatternElement, type ArrayType, type ArrayTypeNode, type AsConstExpression, type AssignmentStatement, type BaseNode, type BaseToken, type BinaryExpression, BinaryOperators, type Binding, type BindingId, type BindingKind, type BindingTarget, type Block, type BooleanLiteral, type BreakStatement, CONFIG_FILE_NAMES, type CallExpression, type CallStatement, type ClassAccessor, type ClassConstructor, type ClassDeclaration, type ClassExpression, type ClassField, type ClassInfo, type ClassLike, type ClassMember, type ClassMethod, type CompoundAssignmentStatement, type ConditionalType, type ConditionalTypeNode, type ConfigLookup, type ConfigProblem, type ContinueStatement, type DeclareClassStatement, type DeclareStatement, type DifferenceType, type DifferenceTypeNode, type Directive, type DirectiveKind, type DirectiveOutcome, type Directives, type DoStatement, type EOFToken, type ErrorExpression, type ErrorStatement, type ExportAllStatement, type ExportDefaultStatement, type ExportNamedStatement, type ExportSpecifier, type ExportStatement, type ExportTypeAliasStatement, type ExportedType, type Expression, type FunctionBody, type FunctionDeclaration, type FunctionDeclarationStatement, type FunctionExpression, type FunctionName, type FunctionParam, type FunctionParameter, type FunctionSignature, type FunctionType, type FunctionTypeNode, type FunctionTypeParameter, type GenericForStatement, type GenericRefType, type GenericTypeParameter, type Identifier, type IdentifierPattern, type IdentifierToken, type IfClause, type IfElseExpression, type IfStatement, type ImportSpecifier, type ImportStatement, type IndexExpression, type IndexedAccessType, type IndexedAccessTypeNode, type InferType, type InferTypeNode, type InterpolatedStringExpression, type InterpolatedStringPart, type InterpolatedStringPart_Expression, type InterpolatedStringPart_String, type InterpolatedStringToken, type IntersectionType, type IntersectionTypeNode, type KeyofType, type KeyofTypeNode, type KeywordToken, Keywords, LexError, type LiteralToken, type LiteralType, type LoweringModule, type LoweringPlugin, type LuautConfig, type MappedType, type MappedTypeNode, type MemberExpression, type MethodCall, type MethodCallExpression, type MethodLowering, type ModuleExports, type NeverType, type NewExpression, type NilLiteral, type Node, type NumberLiteral, type NumericForStatement, type ObjectPattern, type ObjectPatternProperty, type ObjectProperty, type ObjectType, type OperatorToken, Operators, PRELUDE_SOURCE, type ParenthesizedExpression, type ParenthesizedTypeNode, ParseError, type ParserOptions, type PrimitiveName, type PrimitiveType, type Program, type ProjectHost, type PunctuatorToken, Punctuators, type RecoverResult, type RepeatStatement, type ReturnStatement, type SatisfiesExpression, type ScopeAnalysis, type ScopeDiagnostic, type SourceComment, type SourceMapNode, type SourceMapOptions, type SourceMapTypes, type SpreadElement, type Statement, type StringLiteral, type SuperExpression, type TableExpression, type TableField, type TableTypeNode, type TableTypeProperty, type TemplateLiteralType, type TemplateLiteralTypeNode, type Token, type TokenizeOptions, type TupleType, type TupleTypeNode, type Type, type TypeAliasStatement, type TypeAnalysis, type TypeAssertionExpression, type TypeDiagnostic, type TypeLibraries, type TypeLiteralBoolean, type TypeLiteralNumber, type TypeLiteralString, type TypeNode, type TypePackNode, type TypeParamType, type TypePredicate, type TypePredicateNode, type TypeReference, type TypedIdentifier, type TypeofTypeNode, UNUSED_EXPECT_ERROR, type UnaryExpression, UnaryOperators, type UnionType, type UnionTypeNode, type UnknownType, type VarargExpression, type VariableDeclaration, type VariadicTypeNode, type WhileStatement, analyzeScopes, analyzeTypes, anyType, applyDirectives, arrayOf, booleanType, bufferType, containsTypeParam, luautparser as default, difference, directivesOf, equalTypes, falsyType, findConfig, fn, formatType, getBinding, intersection, isAssignable, isClassType, isGlobal, isPossiblyFalsy, isPossiblyTruthy, isUnassignedGlobal, literal, loadConfig, luautparser, matchInfer, moduleCandidates, moduleExports, narrowExclude, narrowFalsy, narrowTo, narrowTruthy, neverType, nilType, nodeHost, numberType, objectType, optional, overlaps, parse, parseExpressionFromSource, parseTokens, parseWithRecovery, primitive, readDirectives, resolveModulePath, resolveTypeLibraries, setAliasExpander, setDeferredBound, sourceMapTypes, stringType, stripJsonComments, substitute, templateMatches, threadType, tokenize, tuple, typeParam, unify, union, unknownType, widen };
package/dist/index.d.ts CHANGED
@@ -41,7 +41,7 @@ interface OperatorToken extends BaseToken {
41
41
  type: "Operator";
42
42
  value: typeof Operators[number];
43
43
  }
44
- declare const Punctuators: readonly ["::", "(", ")", "{", "}", "[", "]", ";", ":", ",", ".", "?", "->", "&", "|", "@"];
44
+ declare const Punctuators: readonly ["::", "(", ")", "{", "}", "[", "]", ";", ":", ",", ".", "?", "=>", "->", "&", "|", "@"];
45
45
  interface PunctuatorToken extends BaseToken {
46
46
  type: "Punctuator";
47
47
  value: typeof Punctuators[number];
@@ -181,14 +181,16 @@ interface ImportStatement extends BaseNode {
181
181
  /** `export const x = 1`, `export let y = 2`, `export function f() end` */
182
182
  interface ExportStatement extends BaseNode {
183
183
  type: "ExportStatement";
184
- declaration: VariableDeclaration | FunctionDeclaration;
184
+ declaration: VariableDeclaration | FunctionDeclaration | ClassDeclaration;
185
185
  }
186
186
  /** `export default <expr>` — mirrors JS default export / dynamic import()'s
187
187
  * `{ default: ... }` shape. Distinct from ExportStatement because the
188
188
  * right-hand side is any expression, not necessarily a declaration. */
189
189
  interface ExportDefaultStatement extends BaseNode {
190
190
  type: "ExportDefaultStatement";
191
- declaration: Expression;
191
+ /** `export default class Name ... end` keeps its name: it declares the
192
+ * class here as well as exporting it, the way TypeScript's does. */
193
+ declaration: Expression | ClassDeclaration;
192
194
  }
193
195
  interface ExportSpecifier extends BaseNode {
194
196
  type: "ExportSpecifier";
@@ -210,7 +212,7 @@ interface ExportAllStatement extends BaseNode {
210
212
  type: "ExportAllStatement";
211
213
  source: StringLiteral;
212
214
  }
213
- type Statement = VariableDeclaration | FunctionDeclaration | FunctionDeclarationStatement | AssignmentStatement | CompoundAssignmentStatement | CallStatement | DoStatement | WhileStatement | RepeatStatement | IfStatement | NumericForStatement | GenericForStatement | ReturnStatement | BreakStatement | ContinueStatement | TypeAliasStatement | ExportTypeAliasStatement | ImportStatement | ExportStatement | ExportDefaultStatement | ExportNamedStatement | ExportAllStatement | DeclareStatement | DeclareClassStatement | ErrorStatement;
215
+ type Statement = VariableDeclaration | FunctionDeclaration | FunctionDeclarationStatement | ClassDeclaration | AssignmentStatement | CompoundAssignmentStatement | CallStatement | DoStatement | WhileStatement | RepeatStatement | IfStatement | NumericForStatement | GenericForStatement | ReturnStatement | BreakStatement | ContinueStatement | TypeAliasStatement | ExportTypeAliasStatement | ImportStatement | ExportStatement | ExportDefaultStatement | ExportNamedStatement | ExportAllStatement | DeclareStatement | DeclareClassStatement | ErrorStatement;
214
216
  /** `declare game: DataModel` / `declare function require(m: string): unknown`
215
217
  * — an ambient value/function declaration for a definitions file (`.d.luaut`).
216
218
  * Contributes a global type; emits no runtime code. */
@@ -336,6 +338,94 @@ interface FunctionName extends BaseNode {
336
338
  path: Identifier[];
337
339
  method?: Identifier;
338
340
  }
341
+ /** `class Name extends Base ... end` — luaut's one runtime class form.
342
+ *
343
+ * It is sugar, and the shape it stands for is the ordinary Lua one: the
344
+ * class is a single table holding the methods and the statics, and an
345
+ * instance is a table whose metatable points at it. An instance therefore
346
+ * references *the class*, not a copy and not a prototype chain of its own —
347
+ * one class, one place its behaviour lives.
348
+ *
349
+ * The declaration contributes both a type (the instance type, nominal, as
350
+ * `declare class` does) and a value (the class table, with `new` and the
351
+ * statics on it). */
352
+ interface ClassDeclaration extends BaseNode {
353
+ type: "ClassDeclaration";
354
+ name: Identifier;
355
+ /** `class Box<T>` — the instance type is then generic, and `Box<number>`
356
+ * instantiates it. */
357
+ typeParams: GenericTypeParameter[];
358
+ /** `extends Base` / `extends Box<number>` — another class declared in
359
+ * this file or imported, with its own arguments filled in. */
360
+ superclass?: Identifier;
361
+ /** The arguments `extends Box<number>` was written with. */
362
+ superArguments?: TypeNode[];
363
+ members: ClassMember[];
364
+ }
365
+ /** `class ... end` written where a value goes: `const Counter = class ... end`,
366
+ * `export default class ... end`. The name is optional and, when written, is
367
+ * visible only inside the class — as in JavaScript. An expression has no name
368
+ * to instantiate, so it takes no type parameters. */
369
+ interface ClassExpression extends BaseNode {
370
+ type: "ClassExpression";
371
+ name?: Identifier;
372
+ superclass?: Identifier;
373
+ superArguments?: TypeNode[];
374
+ members: ClassMember[];
375
+ }
376
+ type ClassMember = ClassField | ClassMethod | ClassAccessor | ClassConstructor;
377
+ /** The two ways a class is written. Everything after parsing treats them
378
+ * alike: only the name and the type parameters differ. */
379
+ type ClassLike = ClassDeclaration | ClassExpression;
380
+ /** `x: number` / `x = 1` / `static count = 0`. An instance field is assigned
381
+ * when the instance is built, before the constructor body runs; a `static`
382
+ * one is assigned on the class table, once. */
383
+ interface ClassField extends BaseNode {
384
+ type: "ClassField";
385
+ name: Identifier;
386
+ isStatic: boolean;
387
+ typeAnnotation?: TypeNode;
388
+ init?: Expression;
389
+ }
390
+ /** `function name(...) ... end` inside a class body — `this` is bound in it.
391
+ * A `static` one is a plain function on the class table, with no `this`. */
392
+ interface ClassMethod extends BaseNode {
393
+ type: "ClassMethod";
394
+ name: Identifier;
395
+ isStatic: boolean;
396
+ func: FunctionBody;
397
+ /** TS-style overload signatures preceding the implementation. */
398
+ signatures?: FunctionSignature[];
399
+ }
400
+ /** `get name(): T ... end` / `set name(v: T) ... end` — read and written as a
401
+ * property, run as a function. */
402
+ interface ClassAccessor extends BaseNode {
403
+ type: "ClassAccessor";
404
+ kind: "get" | "set";
405
+ name: Identifier;
406
+ isStatic: boolean;
407
+ func: FunctionBody;
408
+ }
409
+ /** `constructor(...) ... end` — runs on a fresh instance. A class that
410
+ * extends another must call `super(...)` before touching `this`. */
411
+ interface ClassConstructor extends BaseNode {
412
+ type: "ClassConstructor";
413
+ func: FunctionBody;
414
+ }
415
+ /** `new Name(args)` — builds an instance. Lowers to the class's own
416
+ * `Name.new(args)`, which is also callable by hand. */
417
+ interface NewExpression extends BaseNode {
418
+ type: "NewExpression";
419
+ callee: Expression;
420
+ arguments: Expression[];
421
+ typeArguments?: (TypeNode | TypePackNode)[];
422
+ }
423
+ /** `super` — only inside a class that extends another: `super(...)` in the
424
+ * constructor runs the base's on this instance, and `super.method(...)` in a
425
+ * method calls the base's version of it. */
426
+ interface SuperExpression extends BaseNode {
427
+ type: "SuperExpression";
428
+ }
339
429
  interface AssignmentStatement extends BaseNode {
340
430
  type: "AssignmentStatement";
341
431
  targets: (Expression | ObjectPattern | ArrayPattern)[];
@@ -349,7 +439,7 @@ interface CompoundAssignmentStatement extends BaseNode {
349
439
  }
350
440
  interface CallStatement extends BaseNode {
351
441
  type: "CallStatement";
352
- expression: CallExpression | MethodCallExpression;
442
+ expression: CallExpression | MethodCallExpression | NewExpression;
353
443
  }
354
444
  interface DoStatement extends BaseNode {
355
445
  type: "DoStatement";
@@ -422,7 +512,7 @@ interface GenericTypeParameter extends BaseNode {
422
512
  constraint?: TypeNode;
423
513
  default?: TypeNode | TypePackNode;
424
514
  }
425
- type Expression = Identifier | NilLiteral | BooleanLiteral | NumberLiteral | StringLiteral | InterpolatedStringExpression | VarargExpression | FunctionExpression | TableExpression | ArrayExpression | BinaryExpression | UnaryExpression | MemberExpression | IndexExpression | CallExpression | MethodCallExpression | ParenthesizedExpression | TypeAssertionExpression | SatisfiesExpression | AsConstExpression | IfElseExpression | ErrorExpression;
515
+ type Expression = Identifier | NilLiteral | BooleanLiteral | NumberLiteral | StringLiteral | InterpolatedStringExpression | VarargExpression | FunctionExpression | TableExpression | ArrayExpression | BinaryExpression | UnaryExpression | MemberExpression | IndexExpression | CallExpression | MethodCallExpression | NewExpression | SuperExpression | ClassExpression | SpreadElement | ParenthesizedExpression | TypeAssertionExpression | SatisfiesExpression | AsConstExpression | IfElseExpression | ErrorExpression;
426
516
  /** An expression that could not be parsed. Only produced in recovery mode
427
517
  * (`parseWithRecovery`), where a broken initializer, condition, field value or
428
518
  * argument keeps its place in the tree; its span covers the skipped tokens
@@ -474,6 +564,11 @@ interface VarargExpression extends BaseNode {
474
564
  }
475
565
  interface FunctionParameter extends BaseNode {
476
566
  type: "FunctionParameter";
567
+ /** `...rest: T[]` — every argument from this position on, as an array,
568
+ * the way JavaScript's rest parameter collects them. It is always last,
569
+ * and the function is a vararg function: `...` still means Lua's pack
570
+ * (`const a, b = ...`), and this is the array of it. */
571
+ rest?: boolean;
477
572
  /** `name?: T` — the argument may be omitted, and its type admits `nil`. */
478
573
  optional?: boolean;
479
574
  /** the parameter name, or `""` when `pattern` is set */
@@ -534,7 +629,15 @@ interface ArrayExpression extends BaseNode {
534
629
  type: "ArrayExpression";
535
630
  elements: (Expression | SpreadElement)[];
536
631
  }
537
- /** `...expr` inside an array literal. */
632
+ /** `...expr` the values of an array, one after another, where a list of
633
+ * values is written: inside an array literal (`[...xs, 1]`) and in a call's
634
+ * arguments (`f(a, ...rest)`). It is not a value of its own, and the parser
635
+ * only produces one in those two places.
636
+ *
637
+ * Lua spreads with `table.unpack`, which only yields every value when it is
638
+ * written last; anywhere else the compiler builds the whole list first. Bare
639
+ * `...` is unaffected — that is the vararg pack, and `f(...)` passes it on
640
+ * as it always did. */
538
641
  interface SpreadElement extends BaseNode {
539
642
  type: "SpreadElement";
540
643
  argument: Expression;
@@ -574,6 +677,15 @@ interface CallExpression extends BaseNode {
574
677
  /** `f?.(...)` — see `MemberExpression.optional`. The call does not happen,
575
678
  * and the arguments are not evaluated, when `callee` is nil. */
576
679
  optional?: boolean;
680
+ /** The `(` opened on a line after the callee ended:
681
+ *
682
+ * const value = map[key]
683
+ * ("text"):upper()
684
+ *
685
+ * is one statement — a call of `map[key]` — because a line break does
686
+ * not end a statement, in Lua or in JavaScript. Flagged here so the
687
+ * analyzer can say so; Lua 5.1 calls it "ambiguous syntax". */
688
+ argumentsOnNewLine?: boolean;
577
689
  }
578
690
  interface MethodCallExpression extends BaseNode {
579
691
  type: "MethodCallExpression";
@@ -767,6 +879,8 @@ interface TupleTypeNode extends BaseNode {
767
879
  }
768
880
  interface FunctionTypeParameter extends BaseNode {
769
881
  type: "FunctionTypeParameter";
882
+ /** `(...rest: T[]) -> R` — see `FunctionParameter.rest`. */
883
+ rest?: boolean;
770
884
  /** `name?: T` — the argument may be omitted, and its type admits `nil`. */
771
885
  optional?: boolean;
772
886
  name?: string;
@@ -827,7 +941,10 @@ interface ParserOptions {
827
941
  }
828
942
  declare function parse(source: string): Program;
829
943
  declare function parseTokens(tokens: Token[]): Program;
830
- declare function parseExpressionFromSource(raw: string): Expression;
944
+ /** `inClass` carries the enclosing class in. A template's `${...}` is parsed
945
+ * on its own, so without it a `super` written inside one in a class method
946
+ * would read as an ordinary name. */
947
+ declare function parseExpressionFromSource(raw: string, inClass?: boolean): Expression;
831
948
  interface RecoverResult {
832
949
  program: Program;
833
950
  errors: ParseError[];
@@ -874,7 +991,7 @@ interface Binding {
874
991
  isConst?: boolean;
875
992
  /** Set when the binding comes from something other than `const` / `let`,
876
993
  * which is also what an error about reassigning it names. */
877
- declaredBy?: "import" | "namespace" | "function" | "type";
994
+ declaredBy?: "import" | "namespace" | "function" | "type" | "class";
878
995
  }
879
996
  interface ScopeDiagnostic {
880
997
  /** the offending node (redeclaration site, or assignment target) */
@@ -1007,6 +1124,13 @@ interface ClassInfo {
1007
1124
  superclass?: string;
1008
1125
  /** The class itself, then each class it extends, nearest first. */
1009
1126
  ancestors: readonly string[];
1127
+ /** For a generic class, the arguments each level of the chain was made
1128
+ * with, by class name — its own and every class it extends. `Box<number>`
1129
+ * holds `{ Box: [number] }`, and a `class Ints extends Box<number>` holds
1130
+ * the same entry under `Box`, which is what tells it apart from a
1131
+ * `Box<string>`. A class with no type parameters anywhere carries
1132
+ * nothing, and costs nothing. */
1133
+ typeArguments?: ReadonlyMap<string, readonly Type[]>;
1010
1134
  }
1011
1135
  declare function isClassType(t: Type): t is ObjectType & {
1012
1136
  class: ClassInfo;
@@ -1164,8 +1288,6 @@ declare function tuple(elements: Type[], isPack?: boolean): TupleType;
1164
1288
  declare function objectType(entries: Iterable<[string, ObjectProperty]>, indexer?: ObjectType["indexer"], frozen?: boolean): ObjectType;
1165
1289
  declare function fn(params: FunctionParam[], returns: Type, varargs?: Type, typeParams?: string[], predicate?: TypePredicate): FunctionType;
1166
1290
  declare function substitute(t: Type, subst: Map<string, Type>): Type;
1167
- /** Infer generic bindings by structurally matching a (possibly generic)
1168
- * `param` type against a concrete `arg` type. Accumulates into `out`. */
1169
1291
  declare function unify(param: Type, arg: Type, vars: Set<string>, out: Map<string, Type>): void;
1170
1292
  declare function union(types: Type[]): Type;
1171
1293
  declare function intersection(types: Type[]): Type;
@@ -1178,6 +1300,7 @@ declare function optional(t: Type): Type;
1178
1300
  * into arrays/tuples/objects/unions. */
1179
1301
  declare function widen(t: Type): Type;
1180
1302
  declare function setAliasExpander(fn: ((t: GenericRefType) => Type) | undefined): void;
1303
+ declare function setDeferredBound(fn: ((t: Type) => Type | undefined) | undefined): void;
1181
1304
  declare function isAssignable(rawA: Type, rawB: Type): boolean;
1182
1305
  declare function equalTypes(a: Type, b: Type): boolean;
1183
1306
  /** Keep the parts of `t` compatible with `filter` — TypeScript's
@@ -1223,7 +1346,7 @@ interface TypeDiagnostic {
1223
1346
  /** Usually an expression or statement; a type where the type is wrong
1224
1347
  * (`declare class A extends NotAClass`), or a block where nothing in it
1225
1348
  * is to blame (a function that never returns). Only its span is read. */
1226
- node: Expression | Statement | TypeNode | Block;
1349
+ node: Expression | Statement | TypeNode | Block | ClassMember;
1227
1350
  message: string;
1228
1351
  }
1229
1352
  interface TypeAnalysis {
@@ -1407,14 +1530,14 @@ declare function resolveTypeLibraries(config: LuautConfig, host?: ProjectHost):
1407
1530
  * and asks a library about everything else.
1408
1531
  *
1409
1532
  * These types are declarations only: nothing here runs, and the parser never
1410
- * loads a lowering module. They live here so a library can be written in
1411
- * TypeScript against the same contract the compiler implements, without
1412
- * depending on the compiler.
1413
- *
1414
- * // lowering.ts, in a type library
1415
- * import type { LoweringPlugin } from "luaut-parser"
1533
+ * loads a lowering module. They live here so a library can be checked against
1534
+ * the same contract the compiler implements, without depending on the
1535
+ * compiler in TypeScript, or by JSDoc in the JavaScript it ships:
1416
1536
  *
1417
- * const plugin: LoweringPlugin = {
1537
+ * // lowering.mjs, in a type library
1538
+ * // @ts-check
1539
+ * /** @type {import("luaut-parser").LoweringPlugin} *\/
1540
+ * const plugin = {
1418
1541
  * runtime: { array: "local __NAME__ = {}\n..." },
1419
1542
  * methodCall({ method, receiver, use }) {
1420
1543
  * if (receiver?.kind === "array" && method === "filter") {
@@ -1507,4 +1630,4 @@ declare const luautparser: {
1507
1630
  readonly analyzeTypes: typeof analyzeTypes;
1508
1631
  };
1509
1632
 
1510
- export { type AnalyzeTypesOptions, type AnyType, type ArrayExpression, type ArrayPattern, type ArrayPatternElement, type ArrayType, type ArrayTypeNode, type AsConstExpression, type AssignmentStatement, type BaseNode, type BaseToken, type BinaryExpression, BinaryOperators, type Binding, type BindingId, type BindingKind, type BindingTarget, type Block, type BooleanLiteral, type BreakStatement, CONFIG_FILE_NAMES, type CallExpression, type CallStatement, type ClassInfo, type CompoundAssignmentStatement, type ConditionalType, type ConditionalTypeNode, type ConfigLookup, type ConfigProblem, type ContinueStatement, type DeclareClassStatement, type DeclareStatement, type DifferenceType, type DifferenceTypeNode, type Directive, type DirectiveKind, type DirectiveOutcome, type Directives, type DoStatement, type EOFToken, type ErrorExpression, type ErrorStatement, type ExportAllStatement, type ExportDefaultStatement, type ExportNamedStatement, type ExportSpecifier, type ExportStatement, type ExportTypeAliasStatement, type ExportedType, type Expression, type FunctionBody, type FunctionDeclaration, type FunctionDeclarationStatement, type FunctionExpression, type FunctionName, type FunctionParam, type FunctionParameter, type FunctionSignature, type FunctionType, type FunctionTypeNode, type FunctionTypeParameter, type GenericForStatement, type GenericRefType, type GenericTypeParameter, type Identifier, type IdentifierPattern, type IdentifierToken, type IfClause, type IfElseExpression, type IfStatement, type ImportSpecifier, type ImportStatement, type IndexExpression, type IndexedAccessType, type IndexedAccessTypeNode, type InferType, type InferTypeNode, type InterpolatedStringExpression, type InterpolatedStringPart, type InterpolatedStringPart_Expression, type InterpolatedStringPart_String, type InterpolatedStringToken, type IntersectionType, type IntersectionTypeNode, type KeyofType, type KeyofTypeNode, type KeywordToken, Keywords, LexError, type LiteralToken, type LiteralType, type LoweringModule, type LoweringPlugin, type LuautConfig, type MappedType, type MappedTypeNode, type MemberExpression, type MethodCall, type MethodCallExpression, type MethodLowering, type ModuleExports, type NeverType, type NilLiteral, type Node, type NumberLiteral, type NumericForStatement, type ObjectPattern, type ObjectPatternProperty, type ObjectProperty, type ObjectType, type OperatorToken, Operators, PRELUDE_SOURCE, type ParenthesizedExpression, type ParenthesizedTypeNode, ParseError, type ParserOptions, type PrimitiveName, type PrimitiveType, type Program, type ProjectHost, type PunctuatorToken, Punctuators, type RecoverResult, type RepeatStatement, type ReturnStatement, type SatisfiesExpression, type ScopeAnalysis, type ScopeDiagnostic, type SourceComment, type SourceMapNode, type SourceMapOptions, type SourceMapTypes, type SpreadElement, type Statement, type StringLiteral, type TableExpression, type TableField, type TableTypeNode, type TableTypeProperty, type TemplateLiteralType, type TemplateLiteralTypeNode, type Token, type TokenizeOptions, type TupleType, type TupleTypeNode, type Type, type TypeAliasStatement, type TypeAnalysis, type TypeAssertionExpression, type TypeDiagnostic, type TypeLibraries, type TypeLiteralBoolean, type TypeLiteralNumber, type TypeLiteralString, type TypeNode, type TypePackNode, type TypeParamType, type TypePredicate, type TypePredicateNode, type TypeReference, type TypedIdentifier, type TypeofTypeNode, UNUSED_EXPECT_ERROR, type UnaryExpression, UnaryOperators, type UnionType, type UnionTypeNode, type UnknownType, type VarargExpression, type VariableDeclaration, type VariadicTypeNode, type WhileStatement, analyzeScopes, analyzeTypes, anyType, applyDirectives, arrayOf, booleanType, bufferType, containsTypeParam, luautparser as default, difference, directivesOf, equalTypes, falsyType, findConfig, fn, formatType, getBinding, intersection, isAssignable, isClassType, isGlobal, isPossiblyFalsy, isPossiblyTruthy, isUnassignedGlobal, literal, loadConfig, luautparser, matchInfer, moduleCandidates, moduleExports, narrowExclude, narrowFalsy, narrowTo, narrowTruthy, neverType, nilType, nodeHost, numberType, objectType, optional, overlaps, parse, parseExpressionFromSource, parseTokens, parseWithRecovery, primitive, readDirectives, resolveModulePath, resolveTypeLibraries, setAliasExpander, sourceMapTypes, stringType, stripJsonComments, substitute, templateMatches, threadType, tokenize, tuple, typeParam, unify, union, unknownType, widen };
1633
+ export { type AnalyzeTypesOptions, type AnyType, type ArrayExpression, type ArrayPattern, type ArrayPatternElement, type ArrayType, type ArrayTypeNode, type AsConstExpression, type AssignmentStatement, type BaseNode, type BaseToken, type BinaryExpression, BinaryOperators, type Binding, type BindingId, type BindingKind, type BindingTarget, type Block, type BooleanLiteral, type BreakStatement, CONFIG_FILE_NAMES, type CallExpression, type CallStatement, type ClassAccessor, type ClassConstructor, type ClassDeclaration, type ClassExpression, type ClassField, type ClassInfo, type ClassLike, type ClassMember, type ClassMethod, type CompoundAssignmentStatement, type ConditionalType, type ConditionalTypeNode, type ConfigLookup, type ConfigProblem, type ContinueStatement, type DeclareClassStatement, type DeclareStatement, type DifferenceType, type DifferenceTypeNode, type Directive, type DirectiveKind, type DirectiveOutcome, type Directives, type DoStatement, type EOFToken, type ErrorExpression, type ErrorStatement, type ExportAllStatement, type ExportDefaultStatement, type ExportNamedStatement, type ExportSpecifier, type ExportStatement, type ExportTypeAliasStatement, type ExportedType, type Expression, type FunctionBody, type FunctionDeclaration, type FunctionDeclarationStatement, type FunctionExpression, type FunctionName, type FunctionParam, type FunctionParameter, type FunctionSignature, type FunctionType, type FunctionTypeNode, type FunctionTypeParameter, type GenericForStatement, type GenericRefType, type GenericTypeParameter, type Identifier, type IdentifierPattern, type IdentifierToken, type IfClause, type IfElseExpression, type IfStatement, type ImportSpecifier, type ImportStatement, type IndexExpression, type IndexedAccessType, type IndexedAccessTypeNode, type InferType, type InferTypeNode, type InterpolatedStringExpression, type InterpolatedStringPart, type InterpolatedStringPart_Expression, type InterpolatedStringPart_String, type InterpolatedStringToken, type IntersectionType, type IntersectionTypeNode, type KeyofType, type KeyofTypeNode, type KeywordToken, Keywords, LexError, type LiteralToken, type LiteralType, type LoweringModule, type LoweringPlugin, type LuautConfig, type MappedType, type MappedTypeNode, type MemberExpression, type MethodCall, type MethodCallExpression, type MethodLowering, type ModuleExports, type NeverType, type NewExpression, type NilLiteral, type Node, type NumberLiteral, type NumericForStatement, type ObjectPattern, type ObjectPatternProperty, type ObjectProperty, type ObjectType, type OperatorToken, Operators, PRELUDE_SOURCE, type ParenthesizedExpression, type ParenthesizedTypeNode, ParseError, type ParserOptions, type PrimitiveName, type PrimitiveType, type Program, type ProjectHost, type PunctuatorToken, Punctuators, type RecoverResult, type RepeatStatement, type ReturnStatement, type SatisfiesExpression, type ScopeAnalysis, type ScopeDiagnostic, type SourceComment, type SourceMapNode, type SourceMapOptions, type SourceMapTypes, type SpreadElement, type Statement, type StringLiteral, type SuperExpression, type TableExpression, type TableField, type TableTypeNode, type TableTypeProperty, type TemplateLiteralType, type TemplateLiteralTypeNode, type Token, type TokenizeOptions, type TupleType, type TupleTypeNode, type Type, type TypeAliasStatement, type TypeAnalysis, type TypeAssertionExpression, type TypeDiagnostic, type TypeLibraries, type TypeLiteralBoolean, type TypeLiteralNumber, type TypeLiteralString, type TypeNode, type TypePackNode, type TypeParamType, type TypePredicate, type TypePredicateNode, type TypeReference, type TypedIdentifier, type TypeofTypeNode, UNUSED_EXPECT_ERROR, type UnaryExpression, UnaryOperators, type UnionType, type UnionTypeNode, type UnknownType, type VarargExpression, type VariableDeclaration, type VariadicTypeNode, type WhileStatement, analyzeScopes, analyzeTypes, anyType, applyDirectives, arrayOf, booleanType, bufferType, containsTypeParam, luautparser as default, difference, directivesOf, equalTypes, falsyType, findConfig, fn, formatType, getBinding, intersection, isAssignable, isClassType, isGlobal, isPossiblyFalsy, isPossiblyTruthy, isUnassignedGlobal, literal, loadConfig, luautparser, matchInfer, moduleCandidates, moduleExports, narrowExclude, narrowFalsy, narrowTo, narrowTruthy, neverType, nilType, nodeHost, numberType, objectType, optional, overlaps, parse, parseExpressionFromSource, parseTokens, parseWithRecovery, primitive, readDirectives, resolveModulePath, resolveTypeLibraries, setAliasExpander, setDeferredBound, sourceMapTypes, stringType, stripJsonComments, substitute, templateMatches, threadType, tokenize, tuple, typeParam, unify, union, unknownType, widen };