luaut-parser 3.0.0 → 4.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/README.md +173 -11
- package/dist/index.cjs +2007 -293
- package/dist/index.d.cts +234 -12
- package/dist/index.d.ts +234 -12
- package/dist/index.js +2002 -293
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -54,6 +54,10 @@ interface InterpolatedStringPart_String {
|
|
|
54
54
|
interface InterpolatedStringPart_Expression {
|
|
55
55
|
kind: "expression";
|
|
56
56
|
raw: string;
|
|
57
|
+
/** Where `raw` starts in the file, so what is parsed from it can be
|
|
58
|
+
* placed there rather than at the top of an imaginary one. */
|
|
59
|
+
line: number;
|
|
60
|
+
column: number;
|
|
57
61
|
}
|
|
58
62
|
interface InterpolatedStringToken extends BaseToken {
|
|
59
63
|
type: "InterpolatedString";
|
|
@@ -68,7 +72,72 @@ declare class LexError extends Error {
|
|
|
68
72
|
column: number;
|
|
69
73
|
constructor(message: string, line: number, column: number);
|
|
70
74
|
}
|
|
71
|
-
|
|
75
|
+
/** A `--` comment: its text after the dashes (a long comment's content), and
|
|
76
|
+
* where it starts and ends. */
|
|
77
|
+
interface SourceComment {
|
|
78
|
+
text: string;
|
|
79
|
+
line: number;
|
|
80
|
+
column: number;
|
|
81
|
+
endLine: number;
|
|
82
|
+
}
|
|
83
|
+
interface TokenizeOptions {
|
|
84
|
+
/** When given, a malformed token is recorded here instead of thrown, and
|
|
85
|
+
* lexing goes on: an unclosed string or comment ends at the end of its
|
|
86
|
+
* line (a long bracket at the end of the source), and a character that
|
|
87
|
+
* starts no token is skipped. An editor mid-keystroke still gets every
|
|
88
|
+
* other token. */
|
|
89
|
+
errors?: LexError[];
|
|
90
|
+
/** When given, every comment is collected here, in order. */
|
|
91
|
+
comments?: SourceComment[];
|
|
92
|
+
}
|
|
93
|
+
declare function tokenize(source: string, options?: TokenizeOptions): Token[];
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Comments that switch checking off, as TypeScript's `// @ts-...` comments do:
|
|
97
|
+
*
|
|
98
|
+
* --@luaut-nocheck no scope or type errors anywhere in this file
|
|
99
|
+
* --@luaut-ignore none on the next line of code
|
|
100
|
+
* --@luaut-expect-error none on the next line of code, and an error if
|
|
101
|
+
* that line has none to suppress
|
|
102
|
+
*
|
|
103
|
+
* A space after `--` is fine, and so is text after the directive (a reason).
|
|
104
|
+
* `nocheck` counts only in the comments before the first line of code, as in
|
|
105
|
+
* TypeScript. Syntax errors are never suppressed: code that does not parse
|
|
106
|
+
* cannot be compiled either way.
|
|
107
|
+
*/
|
|
108
|
+
type DirectiveKind = "nocheck" | "ignore" | "expect-error";
|
|
109
|
+
interface Directive {
|
|
110
|
+
kind: DirectiveKind;
|
|
111
|
+
/** Where the comment starts. */
|
|
112
|
+
line: number;
|
|
113
|
+
column: number;
|
|
114
|
+
/** `ignore` / `expect-error`: the line whose diagnostics it covers — the
|
|
115
|
+
* next line with code on it. */
|
|
116
|
+
target?: number;
|
|
117
|
+
}
|
|
118
|
+
interface Directives {
|
|
119
|
+
/** The file has `--@luaut-nocheck` before its first line of code. */
|
|
120
|
+
nocheck: boolean;
|
|
121
|
+
/** Every directive, in order — a `nocheck` after the code starts included,
|
|
122
|
+
* so a tool can point out that it does nothing. */
|
|
123
|
+
all: Directive[];
|
|
124
|
+
}
|
|
125
|
+
/** The directives in `comments`, placed against `tokens` (both from one
|
|
126
|
+
* `tokenize` of the file). */
|
|
127
|
+
declare function readDirectives(comments: readonly SourceComment[], tokens: readonly Token[]): Directives;
|
|
128
|
+
/** The directives of `source`, for a caller that parsed it some other way. */
|
|
129
|
+
declare function directivesOf(source: string): Directives;
|
|
130
|
+
interface DirectiveOutcome<T> {
|
|
131
|
+
/** The diagnostics no directive suppresses. */
|
|
132
|
+
kept: T[];
|
|
133
|
+
/** `--@luaut-expect-error` comments with nothing to suppress. Each is an
|
|
134
|
+
* error to report: "Unused '@luaut-expect-error' directive". */
|
|
135
|
+
unusedExpectErrors: Directive[];
|
|
136
|
+
}
|
|
137
|
+
/** Filter scope and type diagnostics — never syntax errors — through the
|
|
138
|
+
* file's directives. `lineOf` gives the line a diagnostic starts on. */
|
|
139
|
+
declare function applyDirectives<T>(directives: Directives, diagnostics: readonly T[], lineOf: (diagnostic: T) => number): DirectiveOutcome<T>;
|
|
140
|
+
declare const UNUSED_EXPECT_ERROR = "Unused '@luaut-expect-error' directive";
|
|
72
141
|
|
|
73
142
|
interface BaseNode {
|
|
74
143
|
line: {
|
|
@@ -226,6 +295,9 @@ interface ArrayPatternElement extends BaseNode {
|
|
|
226
295
|
* assign to a member instead: see `FunctionDeclarationStatement`. */
|
|
227
296
|
interface FunctionDeclaration extends BaseNode {
|
|
228
297
|
type: "FunctionDeclaration";
|
|
298
|
+
/** The name on the line the body is written on, when the declaration is
|
|
299
|
+
* an overload set — `name` is the first signature's. */
|
|
300
|
+
implementationName?: Identifier;
|
|
229
301
|
name: Identifier;
|
|
230
302
|
func: FunctionBody;
|
|
231
303
|
attributes?: string[];
|
|
@@ -247,6 +319,9 @@ interface FunctionDeclarationStatement extends BaseNode {
|
|
|
247
319
|
* followed by the implementation `function f(...) ... end`. */
|
|
248
320
|
interface FunctionSignature extends BaseNode {
|
|
249
321
|
type: "FunctionSignature";
|
|
322
|
+
/** The name this signature was written with — one line of an overload
|
|
323
|
+
* set, each of which a tool can point at on its own. */
|
|
324
|
+
name?: Identifier;
|
|
250
325
|
generics: GenericTypeParameter[];
|
|
251
326
|
params: FunctionParameter[];
|
|
252
327
|
hasVarargs: boolean;
|
|
@@ -347,7 +422,14 @@ interface GenericTypeParameter extends BaseNode {
|
|
|
347
422
|
constraint?: TypeNode;
|
|
348
423
|
default?: TypeNode | TypePackNode;
|
|
349
424
|
}
|
|
350
|
-
type Expression = Identifier | NilLiteral | BooleanLiteral | NumberLiteral | StringLiteral | InterpolatedStringExpression | VarargExpression | FunctionExpression | TableExpression | ArrayExpression | BinaryExpression | UnaryExpression | MemberExpression | IndexExpression | CallExpression | MethodCallExpression | ParenthesizedExpression | TypeAssertionExpression | SatisfiesExpression | AsConstExpression | IfElseExpression;
|
|
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;
|
|
426
|
+
/** An expression that could not be parsed. Only produced in recovery mode
|
|
427
|
+
* (`parseWithRecovery`), where a broken initializer, condition, field value or
|
|
428
|
+
* argument keeps its place in the tree; its span covers the skipped tokens
|
|
429
|
+
* (and is empty when nothing was written). Its type is `any`. */
|
|
430
|
+
interface ErrorExpression extends BaseNode {
|
|
431
|
+
type: "ErrorExpression";
|
|
432
|
+
}
|
|
351
433
|
interface Identifier extends BaseNode {
|
|
352
434
|
type: "Identifier";
|
|
353
435
|
name: string;
|
|
@@ -474,6 +556,9 @@ interface MemberExpression extends BaseNode {
|
|
|
474
556
|
type: "MemberExpression";
|
|
475
557
|
object: Expression;
|
|
476
558
|
property: Identifier;
|
|
559
|
+
/** `object?.property` — when `object` is nil, the whole chain this link
|
|
560
|
+
* belongs to is nil and nothing after it is evaluated. */
|
|
561
|
+
optional?: boolean;
|
|
477
562
|
}
|
|
478
563
|
interface IndexExpression extends BaseNode {
|
|
479
564
|
type: "IndexExpression";
|
|
@@ -484,12 +569,22 @@ interface CallExpression extends BaseNode {
|
|
|
484
569
|
type: "CallExpression";
|
|
485
570
|
callee: Expression;
|
|
486
571
|
arguments: Expression[];
|
|
572
|
+
/** `f<T>(x)` — type arguments written out rather than inferred. */
|
|
573
|
+
typeArguments?: (TypeNode | TypePackNode)[];
|
|
574
|
+
/** `f?.(...)` — see `MemberExpression.optional`. The call does not happen,
|
|
575
|
+
* and the arguments are not evaluated, when `callee` is nil. */
|
|
576
|
+
optional?: boolean;
|
|
487
577
|
}
|
|
488
578
|
interface MethodCallExpression extends BaseNode {
|
|
489
579
|
type: "MethodCallExpression";
|
|
490
580
|
object: Expression;
|
|
491
581
|
method: Identifier;
|
|
492
582
|
arguments: Expression[];
|
|
583
|
+
/** `obj:m<T>(x)` — see `CallExpression.typeArguments`. */
|
|
584
|
+
typeArguments?: (TypeNode | TypePackNode)[];
|
|
585
|
+
/** `object?:method(...)` — see `MemberExpression.optional`. The
|
|
586
|
+
* arguments are not evaluated when `object` is nil. */
|
|
587
|
+
optional?: boolean;
|
|
493
588
|
}
|
|
494
589
|
interface ParenthesizedExpression extends BaseNode {
|
|
495
590
|
type: "ParenthesizedExpression";
|
|
@@ -724,6 +819,11 @@ interface ParserOptions {
|
|
|
724
819
|
* first one. The returned AST has an `ErrorStatement` wherever a statement
|
|
725
820
|
* could not be parsed. */
|
|
726
821
|
recover?: boolean;
|
|
822
|
+
/** Recovery only: read where a block ends from indentation when an `end`
|
|
823
|
+
* is missing — a line indented no deeper than the line that opened the
|
|
824
|
+
* block is past it. Valid code never needs this; `parseWithRecovery`
|
|
825
|
+
* reparses with it when the first pass found an `end` missing. */
|
|
826
|
+
indentation?: boolean;
|
|
727
827
|
}
|
|
728
828
|
declare function parse(source: string): Program;
|
|
729
829
|
declare function parseTokens(tokens: Token[]): Program;
|
|
@@ -731,13 +831,16 @@ declare function parseExpressionFromSource(raw: string): Expression;
|
|
|
731
831
|
interface RecoverResult {
|
|
732
832
|
program: Program;
|
|
733
833
|
errors: ParseError[];
|
|
834
|
+
/** The file's `--@luaut-...` comments; see `applyDirectives`. */
|
|
835
|
+
directives: Directives;
|
|
734
836
|
}
|
|
735
837
|
/**
|
|
736
|
-
* Like `parse`, but never throws on a syntax error: it records every error
|
|
737
|
-
*
|
|
738
|
-
*
|
|
739
|
-
*
|
|
740
|
-
*
|
|
838
|
+
* Like `parse`, but never throws on a syntax error: it records every error and
|
|
839
|
+
* returns a best-effort AST. A broken expression becomes an `ErrorExpression`,
|
|
840
|
+
* a broken field or argument is skipped to the next `,`, a missing `)`, `}`,
|
|
841
|
+
* `then`, `do` or `end` is recorded and read past, and only what none of those
|
|
842
|
+
* cover becomes an `ErrorStatement`. A malformed token (an unclosed string) is
|
|
843
|
+
* an error too, and the rest of the file still lexes.
|
|
741
844
|
*
|
|
742
845
|
* This is the entry point a language server should use for open documents.
|
|
743
846
|
*/
|
|
@@ -786,7 +889,7 @@ interface ScopeDiagnostic {
|
|
|
786
889
|
};
|
|
787
890
|
};
|
|
788
891
|
message: string;
|
|
789
|
-
kind: "redeclare" | "const-assign" | "type-only";
|
|
892
|
+
kind: "redeclare" | "const-assign" | "type-only" | "undeclared" | "use-before-define";
|
|
790
893
|
}
|
|
791
894
|
interface ScopeAnalysis {
|
|
792
895
|
/** Every Identifier that appears in a variable *usage* position (i.e.
|
|
@@ -812,6 +915,12 @@ interface AnalyzeScopesOptions {
|
|
|
812
915
|
* one of these does not count as "defining" it, so `declarationNode`
|
|
813
916
|
* is left unset even though the binding exists up front. */
|
|
814
917
|
builtinGlobals?: readonly string[];
|
|
918
|
+
/** Report each read of a name nothing declares — not a local, not one of
|
|
919
|
+
* `builtinGlobals`, not `declare`d in the file, never assigned as a
|
|
920
|
+
* global: "Cannot find name 'x'", as TypeScript says. Only meaningful
|
|
921
|
+
* when `builtinGlobals` lists everything the file's type libraries
|
|
922
|
+
* declare, so it is off unless asked for. */
|
|
923
|
+
reportUndeclared?: boolean;
|
|
815
924
|
}
|
|
816
925
|
declare function getBinding(analysis: ScopeAnalysis, id: Identifier | IdentifierPattern): Binding | undefined;
|
|
817
926
|
declare function isGlobal(binding: Binding): boolean;
|
|
@@ -927,6 +1036,9 @@ interface FunctionType {
|
|
|
927
1036
|
/** Names of the function's own generic parameters (`function f<T>(...)`).
|
|
928
1037
|
* `params` / `returns` may contain `typeParam` nodes for these. */
|
|
929
1038
|
typeParams?: string[];
|
|
1039
|
+
/** `<T = Instance>` — what a call uses for a parameter it is not given and
|
|
1040
|
+
* cannot infer. */
|
|
1041
|
+
typeParamDefaults?: Record<string, Type>;
|
|
930
1042
|
/** Set when the function was declared with an `x is T` / `asserts x` return. */
|
|
931
1043
|
predicate?: TypePredicate;
|
|
932
1044
|
}
|
|
@@ -1109,8 +1221,9 @@ declare function formatType(t: Type): string;
|
|
|
1109
1221
|
|
|
1110
1222
|
interface TypeDiagnostic {
|
|
1111
1223
|
/** Usually an expression or statement; a type where the type is wrong
|
|
1112
|
-
* (`declare class A extends NotAClass`)
|
|
1113
|
-
|
|
1224
|
+
* (`declare class A extends NotAClass`), or a block where nothing in it
|
|
1225
|
+
* is to blame (a function that never returns). Only its span is read. */
|
|
1226
|
+
node: Expression | Statement | TypeNode | Block;
|
|
1114
1227
|
message: string;
|
|
1115
1228
|
}
|
|
1116
1229
|
interface TypeAnalysis {
|
|
@@ -1172,6 +1285,11 @@ interface AnalyzeTypesOptions {
|
|
|
1172
1285
|
resolveModule?: (specifier: string) => ModuleExports | undefined;
|
|
1173
1286
|
/** Emit assignability diagnostics (default: true). */
|
|
1174
1287
|
diagnostics?: boolean;
|
|
1288
|
+
/** Report each type name nothing declares: "Cannot find name 'Nope'".
|
|
1289
|
+
* Only meaningful when `libs` holds everything the file can name, so it
|
|
1290
|
+
* is off unless asked for — exactly like `analyzeScopes`'s
|
|
1291
|
+
* `reportUndeclared`. */
|
|
1292
|
+
reportUnknownTypes?: boolean;
|
|
1175
1293
|
}
|
|
1176
1294
|
declare function analyzeTypes(program: Program, scopes: ScopeAnalysis, options?: AnalyzeTypesOptions): TypeAnalysis;
|
|
1177
1295
|
/** The exports of an analyzed module, in the shape another module's
|
|
@@ -1180,6 +1298,27 @@ declare function moduleExports(program: Program, scopes: ScopeAnalysis, types: T
|
|
|
1180
1298
|
/** For `export ... from`: the same resolver the module was analyzed with. */
|
|
1181
1299
|
resolveModule?: (specifier: string) => ModuleExports | undefined): ModuleExports;
|
|
1182
1300
|
|
|
1301
|
+
/**
|
|
1302
|
+
* The types that belong to the language itself, available in every file with
|
|
1303
|
+
* or without a type library — as TypeScript's `Partial` and `ReturnType` are.
|
|
1304
|
+
*
|
|
1305
|
+
* They are written in luaut on top of `keyof`, `T[K]`, conditional types with
|
|
1306
|
+
* `infer`, mapped types and set difference; the analyzer knows none of these
|
|
1307
|
+
* names. A type library or the file itself may declare one of them again, and
|
|
1308
|
+
* that declaration wins.
|
|
1309
|
+
*
|
|
1310
|
+
* What a runtime provides — `print`, `string`, `game` — is not here: that is a
|
|
1311
|
+
* type library's job (`@luaut/lua`, `@luaut/roblox`).
|
|
1312
|
+
*
|
|
1313
|
+
* The methods an array and a string answer to — `names:filter(f)`,
|
|
1314
|
+
* `text:trim()` — are a library's too. `propertyType` reads them from types
|
|
1315
|
+
* named `ArrayMethods<T>` and `StringMethods`, whichever library declares
|
|
1316
|
+
* those; the library also says which of them the compiler must emit code for
|
|
1317
|
+
* (`luaut.methods` in its package.json). Nothing about `filter` is written
|
|
1318
|
+
* into the analyzer.
|
|
1319
|
+
*/
|
|
1320
|
+
declare const PRELUDE_SOURCE = "\n-- In Luau only `nil` and `false` are falsy: `0` and `\"\"` are truthy.\n-- These are what truthiness narrowing computes, made available to write down.\ntype Falsy = nil | false\ntype Truthy<T> = T - Falsy\n\n-- `-` is set difference. Over a union it drops members; over a concrete type\n-- it simplifies away; over an opaque type (`unknown`, an unresolved parameter)\n-- it is kept, so `Exclude<unknown, 1>` stays `unknown - 1`.\ntype Exclude<T, U> = T - U\ntype Extract<T, U> = T extends U ? T : never\ntype NonNullable<T> = T - nil\n\ntype ReturnType<T> = T extends (...unknown) -> infer R ? R : never\ntype Parameters<T> = T extends (...infer P) -> unknown ? P : never\n\ntype Partial<T> = { [K in keyof T]?: T[K] }\ntype Required<T> = { [K in keyof T]-?: T[K] }\ntype Readonly<T> = { readonly [K in keyof T]: T[K] }\ntype Mutable<T> = { -readonly [K in keyof T]: T[K] }\n\ntype Pick<T, K> = { [P in K]: T[P] }\ntype Omit<T, K> = Pick<T, Exclude<keyof T, K>>\ntype Record<K, V> = { [P in K]: V }\n";
|
|
1321
|
+
|
|
1183
1322
|
interface ProjectHost {
|
|
1184
1323
|
/** A file's text, or `undefined` when there is no such file. */
|
|
1185
1324
|
readFile(path: string): string | undefined;
|
|
@@ -1194,7 +1333,7 @@ interface LuautConfig {
|
|
|
1194
1333
|
readonly directory: string;
|
|
1195
1334
|
/** The config file's text, for locating problems in it. */
|
|
1196
1335
|
readonly source: string;
|
|
1197
|
-
/** Type libraries to load, in order: `"
|
|
1336
|
+
/** Type libraries to load, in order: `"lua"`, `"@luaut/roblox"`, `"./types"`. */
|
|
1198
1337
|
readonly types: readonly string[];
|
|
1199
1338
|
/** Import path aliases, as in tsconfig: `{ "@shared/*": ["src/shared/*"] }`. */
|
|
1200
1339
|
readonly paths: Readonly<Record<string, readonly string[]>>;
|
|
@@ -1235,10 +1374,93 @@ declare function stripJsonComments(text: string): string;
|
|
|
1235
1374
|
interface TypeLibraries {
|
|
1236
1375
|
/** Definitions files, dependencies before what depends on them. */
|
|
1237
1376
|
readonly files: readonly string[];
|
|
1377
|
+
/** Lowering modules the libraries ship, in the same order. */
|
|
1378
|
+
readonly lowerings: readonly LoweringModule[];
|
|
1238
1379
|
readonly problems: readonly ConfigProblem[];
|
|
1239
1380
|
}
|
|
1381
|
+
/** A library's own lowering: JavaScript the compiler loads and asks what a
|
|
1382
|
+
* call written against this library's types should become.
|
|
1383
|
+
*
|
|
1384
|
+
* The library declares the *types* in its definitions file; this is the other
|
|
1385
|
+
* half. `names:filter(f)` is a call to a function only because `@luaut/lua`
|
|
1386
|
+
* says so and ships the Luau behind it — the compiler knows how to ask, and
|
|
1387
|
+
* nothing about `filter`.
|
|
1388
|
+
*
|
|
1389
|
+
* `luaut.lowering` in the package.json names the module; what it must export
|
|
1390
|
+
* is the compiler's business (see luaut-build's `LoweringPlugin`). */
|
|
1391
|
+
interface LoweringModule {
|
|
1392
|
+
/** The JavaScript module to load. */
|
|
1393
|
+
readonly file: string;
|
|
1394
|
+
/** The package it came from, for reporting. */
|
|
1395
|
+
readonly from: string;
|
|
1396
|
+
}
|
|
1240
1397
|
declare function resolveTypeLibraries(config: LuautConfig, host?: ProjectHost): TypeLibraries;
|
|
1241
1398
|
|
|
1399
|
+
/**
|
|
1400
|
+
* The contract between a type library and the compiler.
|
|
1401
|
+
*
|
|
1402
|
+
* A library's definitions file says what a value *is*; when what it gives is
|
|
1403
|
+
* not something the value already answers to, the library must also say how
|
|
1404
|
+
* it runs. `names:filter(f)` is a call to a function because `@luaut/lua`
|
|
1405
|
+
* declares the method and ships the Luau behind it — the compiler lowers the
|
|
1406
|
+
* language (`import`, `export`, `?.`, `a ? b : c`, destructuring, spreads)
|
|
1407
|
+
* and asks a library about everything else.
|
|
1408
|
+
*
|
|
1409
|
+
* 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"
|
|
1416
|
+
*
|
|
1417
|
+
* const plugin: LoweringPlugin = {
|
|
1418
|
+
* runtime: { array: "local __NAME__ = {}\n..." },
|
|
1419
|
+
* methodCall({ method, receiver, use }) {
|
|
1420
|
+
* if (receiver?.kind === "array" && method === "filter") {
|
|
1421
|
+
* return { callee: `${use("array")}.filter` }
|
|
1422
|
+
* }
|
|
1423
|
+
* return undefined
|
|
1424
|
+
* },
|
|
1425
|
+
* }
|
|
1426
|
+
* export default plugin
|
|
1427
|
+
*/
|
|
1428
|
+
|
|
1429
|
+
interface LoweringPlugin {
|
|
1430
|
+
/** Luau the plugin needs in the output, by a key it chooses. Each is a
|
|
1431
|
+
* file's worth of source with `__NAME__` standing for the local the
|
|
1432
|
+
* compiler gives it, and each is emitted once, at the top of the output,
|
|
1433
|
+
* only if `use` asked for it:
|
|
1434
|
+
*
|
|
1435
|
+
* local __NAME__ = {}
|
|
1436
|
+
* function __NAME__.filter(t, test) ... end
|
|
1437
|
+
*/
|
|
1438
|
+
readonly runtime?: Readonly<Record<string, string>>;
|
|
1439
|
+
/** What `receiver:method(...)` becomes. `undefined` leaves a plain Luau
|
|
1440
|
+
* method call, which is what a value that answers to the method itself
|
|
1441
|
+
* wants — `text:upper()` reaches Lua's own. */
|
|
1442
|
+
methodCall?(call: MethodCall): MethodLowering | undefined;
|
|
1443
|
+
}
|
|
1444
|
+
interface MethodCall {
|
|
1445
|
+
/** The name written after `:`. */
|
|
1446
|
+
readonly method: string;
|
|
1447
|
+
/** The receiver's type, as the analyzer worked it out. `undefined` when
|
|
1448
|
+
* nothing typed it, where a plugin should decline rather than guess. */
|
|
1449
|
+
readonly receiver: Type | undefined;
|
|
1450
|
+
/** How many arguments were written. */
|
|
1451
|
+
readonly argumentCount: number;
|
|
1452
|
+
/** The local name the output gives one of `runtime`'s entries, emitting
|
|
1453
|
+
* it if this is the first call that needed it. */
|
|
1454
|
+
use(runtime: string): string;
|
|
1455
|
+
}
|
|
1456
|
+
interface MethodLowering {
|
|
1457
|
+
/** What to call instead: a name, or a `table.member` path — usually built
|
|
1458
|
+
* from `use(...)`. */
|
|
1459
|
+
readonly callee: string;
|
|
1460
|
+
/** Pass the receiver as the first argument. Default: yes. */
|
|
1461
|
+
readonly passReceiver?: boolean;
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1242
1464
|
/** Every file `specifier` could mean from `fromFile`, in the order they are
|
|
1243
1465
|
* tried. A resolver that caches should watch all of them: creating an earlier
|
|
1244
1466
|
* candidate changes what the import means. */
|
|
@@ -1285,4 +1507,4 @@ declare const luautparser: {
|
|
|
1285
1507
|
readonly analyzeTypes: typeof analyzeTypes;
|
|
1286
1508
|
};
|
|
1287
1509
|
|
|
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 };
|
|
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 };
|