luaut-parser 2.0.0 → 3.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
@@ -99,11 +99,17 @@ interface ImportStatement extends BaseNode {
99
99
  type: "ImportStatement";
100
100
  /** `import Default from '...'` */
101
101
  defaultImport?: Identifier;
102
+ /** `import * as Module from '...'` — the module's exports as one value. */
103
+ namespaceImport?: Identifier;
104
+ /** `import type { A } from '...'`: every name it brings in is a type and
105
+ * may only be used as one — never as a value. It exists for the type
106
+ * checker alone, and leaves nothing in compiled code. */
107
+ isTypeOnly?: boolean;
102
108
  /** `import { a, b as c } from '...'` */
103
109
  specifiers: ImportSpecifier[];
104
110
  source: StringLiteral;
105
111
  }
106
- /** `export const x = 1`, `export let y = 2`, `export const function f() end` */
112
+ /** `export const x = 1`, `export let y = 2`, `export function f() end` */
107
113
  interface ExportStatement extends BaseNode {
108
114
  type: "ExportStatement";
109
115
  declaration: VariableDeclaration | FunctionDeclaration;
@@ -135,7 +141,7 @@ interface ExportAllStatement extends BaseNode {
135
141
  type: "ExportAllStatement";
136
142
  source: StringLiteral;
137
143
  }
138
- 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 | ErrorStatement;
144
+ 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;
139
145
  /** `declare game: DataModel` / `declare function require(m: string): unknown`
140
146
  * — an ambient value/function declaration for a definitions file (`.d.luaut`).
141
147
  * Contributes a global type; emits no runtime code. */
@@ -147,6 +153,18 @@ interface DeclareStatement extends BaseNode {
147
153
  /** the declared value's type (function form is lowered to a FunctionTypeNode) */
148
154
  valueType: TypeNode;
149
155
  }
156
+ /** `declare class Part extends BasePart { Shape: EnumItem }` — a *nominal*
157
+ * type for a definitions file, the way Roblox's own classes are: a `Part` is
158
+ * an `Instance` because it extends one, not because it has the same members,
159
+ * and no table literal is ever a `Part`. The body lists the members the class
160
+ * adds; it inherits the rest. Declares a type only, no value. */
161
+ interface DeclareClassStatement extends BaseNode {
162
+ type: "DeclareClassStatement";
163
+ name: Identifier;
164
+ /** `extends Base` — another class. */
165
+ superclass?: TypeReference;
166
+ body: TableTypeNode;
167
+ }
150
168
  /** A statement position that could not be parsed. Only produced when parsing
151
169
  * in recovery mode (`parseWithRecovery`); its span covers the skipped tokens
152
170
  * so tools can still map a cursor there. */
@@ -202,17 +220,19 @@ interface ArrayPatternElement extends BaseNode {
202
220
  value: BindingTarget;
203
221
  default?: Expression;
204
222
  }
205
- /** `const function f() ... end` / `let function f() ... end` a named,
206
- * self-referential (recursive) function binding. */
223
+ /** `function f() ... end` declares `f` in the enclosing scope, visible to
224
+ * its own body (so it can recurse). Like TypeScript's function declaration,
225
+ * the name cannot be reassigned. `function a.b() end` and `function T:m() end`
226
+ * assign to a member instead: see `FunctionDeclarationStatement`. */
207
227
  interface FunctionDeclaration extends BaseNode {
208
228
  type: "FunctionDeclaration";
209
- kind: "const" | "let";
210
229
  name: Identifier;
211
230
  func: FunctionBody;
212
231
  attributes?: string[];
213
232
  /** TS-style overload signatures preceding the implementation (`func`). */
214
233
  signatures?: FunctionSignature[];
215
234
  }
235
+ /** `function a.b() end` / `function T:m() end` — defines a member. */
216
236
  interface FunctionDeclarationStatement extends BaseNode {
217
237
  type: "FunctionDeclarationStatement";
218
238
  target: FunctionName;
@@ -746,8 +766,12 @@ interface Binding {
746
766
  * bindings are never given a `declarationNode` from assignment
747
767
  * inference, since they're not really "defined" in this file. */
748
768
  isBuiltin?: boolean;
749
- /** True for a `const` binding reassigning it is an error. */
769
+ /** True for a binding that cannot be reassigned: a `const`, an import, or
770
+ * a function declaration. */
750
771
  isConst?: boolean;
772
+ /** Set when the binding comes from something other than `const` / `let`,
773
+ * which is also what an error about reassigning it names. */
774
+ declaredBy?: "import" | "namespace" | "function" | "type";
751
775
  }
752
776
  interface ScopeDiagnostic {
753
777
  /** the offending node (redeclaration site, or assignment target) */
@@ -762,7 +786,7 @@ interface ScopeDiagnostic {
762
786
  };
763
787
  };
764
788
  message: string;
765
- kind: "redeclare" | "const-assign";
789
+ kind: "redeclare" | "const-assign" | "type-only";
766
790
  }
767
791
  interface ScopeAnalysis {
768
792
  /** Every Identifier that appears in a variable *usage* position (i.e.
@@ -858,7 +882,26 @@ interface ObjectType {
858
882
  /** The alias this object was resolved from — display only, ignored by
859
883
  * `isAssignable` (the type is structural). Dropped on `widen`/`substitute`. */
860
884
  name?: string;
885
+ /** Set on a `declare class` — the type is then *nominal*. See `ClassInfo`. */
886
+ class?: ClassInfo;
887
+ }
888
+ /** What makes an object a class instance. `properties` then holds every
889
+ * member, inherited ones included. Only the class itself and the classes
890
+ * extending it are assignable to it — no table literal, no structurally
891
+ * identical class. Going the other way, a class satisfies a shape naming
892
+ * members it has (`{ Name: string }`) but is not a table: never a
893
+ * `{ [K]: V }` or `{}`, which is what keeps `typeof(part)` from matching the
894
+ * `{ [unknown]: unknown }` overload. */
895
+ interface ClassInfo {
896
+ name: string;
897
+ /** The class it directly extends, if any. */
898
+ superclass?: string;
899
+ /** The class itself, then each class it extends, nearest first. */
900
+ ancestors: readonly string[];
861
901
  }
902
+ declare function isClassType(t: Type): t is ObjectType & {
903
+ class: ClassInfo;
904
+ };
862
905
  interface FunctionParam {
863
906
  name?: string;
864
907
  type: Type;
@@ -1065,7 +1108,9 @@ declare function overlaps(a: Type, b: Type): boolean;
1065
1108
  declare function formatType(t: Type): string;
1066
1109
 
1067
1110
  interface TypeDiagnostic {
1068
- node: Expression | Statement;
1111
+ /** Usually an expression or statement; a type where the type is wrong
1112
+ * (`declare class A extends NotAClass`). */
1113
+ node: Expression | Statement | TypeNode;
1069
1114
  message: string;
1070
1115
  }
1071
1116
  interface TypeAnalysis {
@@ -1099,7 +1144,7 @@ interface ExportedType {
1099
1144
  }
1100
1145
  /** What a module makes available to `import`. See `moduleExports`. */
1101
1146
  interface ModuleExports {
1102
- /** `export const` / `export let` / `export const function` names. */
1147
+ /** `export const` / `export let` / `export function` names. */
1103
1148
  readonly values: ReadonlyMap<string, Type>;
1104
1149
  /** `export type` names. */
1105
1150
  readonly types: ReadonlyMap<string, ExportedType>;
@@ -1217,7 +1262,7 @@ interface SourceMapOptions {
1217
1262
  readonly membersOf?: (className: string) => ReadonlySet<string>;
1218
1263
  }
1219
1264
  interface SourceMapTypes {
1220
- /** The tree's type aliases, and `game` / `workspace` for a place. */
1265
+ /** The tree's classes, and `game` / `workspace` for a place. */
1221
1266
  readonly program: Program;
1222
1267
  /** `declare script: ...` for a file the tree maps, or `undefined`. */
1223
1268
  scriptFor(file: string): Program | undefined;
@@ -1240,4 +1285,4 @@ declare const luautparser: {
1240
1285
  readonly analyzeTypes: typeof analyzeTypes;
1241
1286
  };
1242
1287
 
1243
- 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 CompoundAssignmentStatement, type ConditionalType, type ConditionalTypeNode, type ConfigLookup, type ConfigProblem, type ContinueStatement, type DeclareStatement, type DifferenceType, type DifferenceTypeNode, type DoStatement, type EOFToken, 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 LuautConfig, type MappedType, type MappedTypeNode, type MemberExpression, type MethodCallExpression, type ModuleExports, type NeverType, type NilLiteral, type Node, type NumberLiteral, type NumericForStatement, type ObjectPattern, type ObjectPatternProperty, type ObjectProperty, type ObjectType, type OperatorToken, Operators, 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 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 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, type UnaryExpression, UnaryOperators, type UnionType, type UnionTypeNode, type UnknownType, type VarargExpression, type VariableDeclaration, type VariadicTypeNode, type WhileStatement, analyzeScopes, analyzeTypes, anyType, arrayOf, booleanType, bufferType, containsTypeParam, luautparser as default, difference, equalTypes, falsyType, findConfig, fn, formatType, getBinding, intersection, isAssignable, 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, resolveModulePath, resolveTypeLibraries, setAliasExpander, sourceMapTypes, stringType, stripJsonComments, substitute, templateMatches, threadType, tokenize, tuple, typeParam, unify, union, unknownType, widen };
1288
+ 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 DoStatement, type EOFToken, 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 LuautConfig, type MappedType, type MappedTypeNode, type MemberExpression, type MethodCallExpression, type ModuleExports, type NeverType, type NilLiteral, type Node, type NumberLiteral, type NumericForStatement, type ObjectPattern, type ObjectPatternProperty, type ObjectProperty, type ObjectType, type OperatorToken, Operators, 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 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 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, type UnaryExpression, UnaryOperators, type UnionType, type UnionTypeNode, type UnknownType, type VarargExpression, type VariableDeclaration, type VariadicTypeNode, type WhileStatement, analyzeScopes, analyzeTypes, anyType, arrayOf, booleanType, bufferType, containsTypeParam, luautparser as default, difference, 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, resolveModulePath, resolveTypeLibraries, setAliasExpander, sourceMapTypes, stringType, stripJsonComments, substitute, templateMatches, threadType, tokenize, tuple, typeParam, unify, union, unknownType, widen };
package/dist/index.d.ts CHANGED
@@ -99,11 +99,17 @@ interface ImportStatement extends BaseNode {
99
99
  type: "ImportStatement";
100
100
  /** `import Default from '...'` */
101
101
  defaultImport?: Identifier;
102
+ /** `import * as Module from '...'` — the module's exports as one value. */
103
+ namespaceImport?: Identifier;
104
+ /** `import type { A } from '...'`: every name it brings in is a type and
105
+ * may only be used as one — never as a value. It exists for the type
106
+ * checker alone, and leaves nothing in compiled code. */
107
+ isTypeOnly?: boolean;
102
108
  /** `import { a, b as c } from '...'` */
103
109
  specifiers: ImportSpecifier[];
104
110
  source: StringLiteral;
105
111
  }
106
- /** `export const x = 1`, `export let y = 2`, `export const function f() end` */
112
+ /** `export const x = 1`, `export let y = 2`, `export function f() end` */
107
113
  interface ExportStatement extends BaseNode {
108
114
  type: "ExportStatement";
109
115
  declaration: VariableDeclaration | FunctionDeclaration;
@@ -135,7 +141,7 @@ interface ExportAllStatement extends BaseNode {
135
141
  type: "ExportAllStatement";
136
142
  source: StringLiteral;
137
143
  }
138
- 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 | ErrorStatement;
144
+ 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;
139
145
  /** `declare game: DataModel` / `declare function require(m: string): unknown`
140
146
  * — an ambient value/function declaration for a definitions file (`.d.luaut`).
141
147
  * Contributes a global type; emits no runtime code. */
@@ -147,6 +153,18 @@ interface DeclareStatement extends BaseNode {
147
153
  /** the declared value's type (function form is lowered to a FunctionTypeNode) */
148
154
  valueType: TypeNode;
149
155
  }
156
+ /** `declare class Part extends BasePart { Shape: EnumItem }` — a *nominal*
157
+ * type for a definitions file, the way Roblox's own classes are: a `Part` is
158
+ * an `Instance` because it extends one, not because it has the same members,
159
+ * and no table literal is ever a `Part`. The body lists the members the class
160
+ * adds; it inherits the rest. Declares a type only, no value. */
161
+ interface DeclareClassStatement extends BaseNode {
162
+ type: "DeclareClassStatement";
163
+ name: Identifier;
164
+ /** `extends Base` — another class. */
165
+ superclass?: TypeReference;
166
+ body: TableTypeNode;
167
+ }
150
168
  /** A statement position that could not be parsed. Only produced when parsing
151
169
  * in recovery mode (`parseWithRecovery`); its span covers the skipped tokens
152
170
  * so tools can still map a cursor there. */
@@ -202,17 +220,19 @@ interface ArrayPatternElement extends BaseNode {
202
220
  value: BindingTarget;
203
221
  default?: Expression;
204
222
  }
205
- /** `const function f() ... end` / `let function f() ... end` a named,
206
- * self-referential (recursive) function binding. */
223
+ /** `function f() ... end` declares `f` in the enclosing scope, visible to
224
+ * its own body (so it can recurse). Like TypeScript's function declaration,
225
+ * the name cannot be reassigned. `function a.b() end` and `function T:m() end`
226
+ * assign to a member instead: see `FunctionDeclarationStatement`. */
207
227
  interface FunctionDeclaration extends BaseNode {
208
228
  type: "FunctionDeclaration";
209
- kind: "const" | "let";
210
229
  name: Identifier;
211
230
  func: FunctionBody;
212
231
  attributes?: string[];
213
232
  /** TS-style overload signatures preceding the implementation (`func`). */
214
233
  signatures?: FunctionSignature[];
215
234
  }
235
+ /** `function a.b() end` / `function T:m() end` — defines a member. */
216
236
  interface FunctionDeclarationStatement extends BaseNode {
217
237
  type: "FunctionDeclarationStatement";
218
238
  target: FunctionName;
@@ -746,8 +766,12 @@ interface Binding {
746
766
  * bindings are never given a `declarationNode` from assignment
747
767
  * inference, since they're not really "defined" in this file. */
748
768
  isBuiltin?: boolean;
749
- /** True for a `const` binding reassigning it is an error. */
769
+ /** True for a binding that cannot be reassigned: a `const`, an import, or
770
+ * a function declaration. */
750
771
  isConst?: boolean;
772
+ /** Set when the binding comes from something other than `const` / `let`,
773
+ * which is also what an error about reassigning it names. */
774
+ declaredBy?: "import" | "namespace" | "function" | "type";
751
775
  }
752
776
  interface ScopeDiagnostic {
753
777
  /** the offending node (redeclaration site, or assignment target) */
@@ -762,7 +786,7 @@ interface ScopeDiagnostic {
762
786
  };
763
787
  };
764
788
  message: string;
765
- kind: "redeclare" | "const-assign";
789
+ kind: "redeclare" | "const-assign" | "type-only";
766
790
  }
767
791
  interface ScopeAnalysis {
768
792
  /** Every Identifier that appears in a variable *usage* position (i.e.
@@ -858,7 +882,26 @@ interface ObjectType {
858
882
  /** The alias this object was resolved from — display only, ignored by
859
883
  * `isAssignable` (the type is structural). Dropped on `widen`/`substitute`. */
860
884
  name?: string;
885
+ /** Set on a `declare class` — the type is then *nominal*. See `ClassInfo`. */
886
+ class?: ClassInfo;
887
+ }
888
+ /** What makes an object a class instance. `properties` then holds every
889
+ * member, inherited ones included. Only the class itself and the classes
890
+ * extending it are assignable to it — no table literal, no structurally
891
+ * identical class. Going the other way, a class satisfies a shape naming
892
+ * members it has (`{ Name: string }`) but is not a table: never a
893
+ * `{ [K]: V }` or `{}`, which is what keeps `typeof(part)` from matching the
894
+ * `{ [unknown]: unknown }` overload. */
895
+ interface ClassInfo {
896
+ name: string;
897
+ /** The class it directly extends, if any. */
898
+ superclass?: string;
899
+ /** The class itself, then each class it extends, nearest first. */
900
+ ancestors: readonly string[];
861
901
  }
902
+ declare function isClassType(t: Type): t is ObjectType & {
903
+ class: ClassInfo;
904
+ };
862
905
  interface FunctionParam {
863
906
  name?: string;
864
907
  type: Type;
@@ -1065,7 +1108,9 @@ declare function overlaps(a: Type, b: Type): boolean;
1065
1108
  declare function formatType(t: Type): string;
1066
1109
 
1067
1110
  interface TypeDiagnostic {
1068
- node: Expression | Statement;
1111
+ /** Usually an expression or statement; a type where the type is wrong
1112
+ * (`declare class A extends NotAClass`). */
1113
+ node: Expression | Statement | TypeNode;
1069
1114
  message: string;
1070
1115
  }
1071
1116
  interface TypeAnalysis {
@@ -1099,7 +1144,7 @@ interface ExportedType {
1099
1144
  }
1100
1145
  /** What a module makes available to `import`. See `moduleExports`. */
1101
1146
  interface ModuleExports {
1102
- /** `export const` / `export let` / `export const function` names. */
1147
+ /** `export const` / `export let` / `export function` names. */
1103
1148
  readonly values: ReadonlyMap<string, Type>;
1104
1149
  /** `export type` names. */
1105
1150
  readonly types: ReadonlyMap<string, ExportedType>;
@@ -1217,7 +1262,7 @@ interface SourceMapOptions {
1217
1262
  readonly membersOf?: (className: string) => ReadonlySet<string>;
1218
1263
  }
1219
1264
  interface SourceMapTypes {
1220
- /** The tree's type aliases, and `game` / `workspace` for a place. */
1265
+ /** The tree's classes, and `game` / `workspace` for a place. */
1221
1266
  readonly program: Program;
1222
1267
  /** `declare script: ...` for a file the tree maps, or `undefined`. */
1223
1268
  scriptFor(file: string): Program | undefined;
@@ -1240,4 +1285,4 @@ declare const luautparser: {
1240
1285
  readonly analyzeTypes: typeof analyzeTypes;
1241
1286
  };
1242
1287
 
1243
- 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 CompoundAssignmentStatement, type ConditionalType, type ConditionalTypeNode, type ConfigLookup, type ConfigProblem, type ContinueStatement, type DeclareStatement, type DifferenceType, type DifferenceTypeNode, type DoStatement, type EOFToken, 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 LuautConfig, type MappedType, type MappedTypeNode, type MemberExpression, type MethodCallExpression, type ModuleExports, type NeverType, type NilLiteral, type Node, type NumberLiteral, type NumericForStatement, type ObjectPattern, type ObjectPatternProperty, type ObjectProperty, type ObjectType, type OperatorToken, Operators, 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 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 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, type UnaryExpression, UnaryOperators, type UnionType, type UnionTypeNode, type UnknownType, type VarargExpression, type VariableDeclaration, type VariadicTypeNode, type WhileStatement, analyzeScopes, analyzeTypes, anyType, arrayOf, booleanType, bufferType, containsTypeParam, luautparser as default, difference, equalTypes, falsyType, findConfig, fn, formatType, getBinding, intersection, isAssignable, 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, resolveModulePath, resolveTypeLibraries, setAliasExpander, sourceMapTypes, stringType, stripJsonComments, substitute, templateMatches, threadType, tokenize, tuple, typeParam, unify, union, unknownType, widen };
1288
+ 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 DoStatement, type EOFToken, 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 LuautConfig, type MappedType, type MappedTypeNode, type MemberExpression, type MethodCallExpression, type ModuleExports, type NeverType, type NilLiteral, type Node, type NumberLiteral, type NumericForStatement, type ObjectPattern, type ObjectPatternProperty, type ObjectProperty, type ObjectType, type OperatorToken, Operators, 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 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 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, type UnaryExpression, UnaryOperators, type UnionType, type UnionTypeNode, type UnknownType, type VarargExpression, type VariableDeclaration, type VariadicTypeNode, type WhileStatement, analyzeScopes, analyzeTypes, anyType, arrayOf, booleanType, bufferType, containsTypeParam, luautparser as default, difference, 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, resolveModulePath, resolveTypeLibraries, setAliasExpander, sourceMapTypes, stringType, stripJsonComments, substitute, templateMatches, threadType, tokenize, tuple, typeParam, unify, union, unknownType, widen };