@tilua/parser 2.3.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/README.md +45 -23
- package/dist/index.cjs +431 -65
- package/dist/index.d.cts +73 -23
- package/dist/index.d.ts +73 -23
- package/dist/index.js +431 -65
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -212,7 +212,7 @@ interface ExportAllStatement extends BaseNode {
|
|
|
212
212
|
type: "ExportAllStatement";
|
|
213
213
|
source: StringLiteral;
|
|
214
214
|
}
|
|
215
|
-
type Statement = VariableDeclaration | FunctionDeclaration | FunctionDeclarationStatement | ClassDeclaration | AssignmentStatement | CompoundAssignmentStatement | CallStatement | ExpressionStatement | 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 | ExpressionStatement | DoStatement | WhileStatement | RepeatStatement | IfStatement | NumericForStatement | GenericForStatement | ReturnStatement | BreakStatement | ContinueStatement | TypeAliasStatement | ExportTypeAliasStatement | ImportStatement | ExportStatement | ExportDefaultStatement | ExportNamedStatement | ExportAllStatement | DeclareStatement | DeclareClassStatement | DeclareMetatableStatement | ErrorStatement;
|
|
216
216
|
/** `declare game: DataModel` / `declare function require(m: string): unknown`
|
|
217
217
|
* — an ambient value/function declaration for a definitions file (`.d.tilua`).
|
|
218
218
|
* Contributes a global type; emits no runtime code. */
|
|
@@ -236,6 +236,25 @@ interface DeclareClassStatement extends BaseNode {
|
|
|
236
236
|
superclass?: TypeReference;
|
|
237
237
|
body: TableTypeNode;
|
|
238
238
|
}
|
|
239
|
+
/** `declare metatable string: { __index: StringLibrary }` — the metatable
|
|
240
|
+
* every value of `target` has, as far as types go. A method call reads
|
|
241
|
+
* through its `__index`: `text:upper()` is `upper` there.
|
|
242
|
+
*
|
|
243
|
+
* A library may declare one a value does not really have — Lua gives an
|
|
244
|
+
* array none — and ship a lowering that turns a call through it into a
|
|
245
|
+
* call of its own (`names:filter(f)` becomes `array.filter(names, f)`).
|
|
246
|
+
* The compiler asks the library that declared the metatable, and only it.
|
|
247
|
+
*
|
|
248
|
+
* `target` may use the declaration's type parameters: `<T> T[]` is every
|
|
249
|
+
* array, `T` its elements; `<T extends {}> T` every plain table, `T` the
|
|
250
|
+
* table itself. The most specific target a value matches is its metatable,
|
|
251
|
+
* and declaring one target again adds to it. */
|
|
252
|
+
interface DeclareMetatableStatement extends BaseNode {
|
|
253
|
+
type: "DeclareMetatableStatement";
|
|
254
|
+
generics: GenericTypeParameter[];
|
|
255
|
+
target: TypeNode;
|
|
256
|
+
metatable: TypeNode;
|
|
257
|
+
}
|
|
239
258
|
/** A statement position that could not be parsed. Only produced when parsing
|
|
240
259
|
* in recovery mode (`parseWithRecovery`); its span covers the skipped tokens
|
|
241
260
|
* so tools can still map a cursor there. */
|
|
@@ -254,7 +273,9 @@ interface VariableDeclaration extends BaseNode {
|
|
|
254
273
|
/** Absent only on `let x`. */
|
|
255
274
|
init?: Expression;
|
|
256
275
|
}
|
|
257
|
-
|
|
276
|
+
/** A member or an index (`t.a`, `t[i]`) is a leaf only in a destructuring
|
|
277
|
+
* assignment (`[t[i], t[j]] = [t[j], t[i]]`): a declaration binds names. */
|
|
278
|
+
type BindingTarget = IdentifierPattern | ObjectPattern | ArrayPattern | MemberExpression | IndexExpression;
|
|
258
279
|
interface IdentifierPattern extends BaseNode {
|
|
259
280
|
type: "IdentifierPattern";
|
|
260
281
|
name: string;
|
|
@@ -1486,8 +1507,27 @@ interface TypeAnalysis {
|
|
|
1486
1507
|
/** How each `for (const item in source)` walks its source; see
|
|
1487
1508
|
* `LoopForm`. A loop missing here walks values. */
|
|
1488
1509
|
readonly loops: ReadonlyMap<GenericForStatement, LoopForm>;
|
|
1510
|
+
/** Each `receiver:method(...)` whose method the receiver's metatable
|
|
1511
|
+
* gave it (`declare metatable`), and which library declared that. A call
|
|
1512
|
+
* missing here reached a member of the receiver's own. */
|
|
1513
|
+
readonly methodSources: ReadonlyMap<MethodCallExpression, MethodSource>;
|
|
1514
|
+
/** The members a value's metatable `__index` gives it — what an editor
|
|
1515
|
+
* offers after `:`. Empty for a value no metatable matches. */
|
|
1516
|
+
readonly metatableMembers: (type: Type) => ReadonlyMap<string, Type>;
|
|
1489
1517
|
readonly diagnostics: TypeDiagnostic[];
|
|
1490
1518
|
}
|
|
1519
|
+
/** Where a metatable reached by a method call was declared: by the language
|
|
1520
|
+
* itself (the prelude's metatables for strings, arrays and tables), by a
|
|
1521
|
+
* library (its index in `libs`), or by the program. The compiler lowers a
|
|
1522
|
+
* language method itself, and asks a library about its own. */
|
|
1523
|
+
type MethodSource = {
|
|
1524
|
+
readonly origin: "language";
|
|
1525
|
+
} | {
|
|
1526
|
+
readonly origin: "library";
|
|
1527
|
+
readonly library: number;
|
|
1528
|
+
} | {
|
|
1529
|
+
readonly origin: "program";
|
|
1530
|
+
};
|
|
1491
1531
|
/** A type a module exports: the resolved type, plus the parameter names of a
|
|
1492
1532
|
* generic alias so an importer can instantiate it (`Box<number>`). */
|
|
1493
1533
|
interface ExportedType {
|
|
@@ -1549,14 +1589,19 @@ resolveModule?: (specifier: string) => ModuleExports | undefined): ModuleExports
|
|
|
1549
1589
|
* What a runtime provides — `print`, `string`, `game` — is not here: that is a
|
|
1550
1590
|
* type library's job (`@tilua-types/lua`, `@tilua-types/roblox`).
|
|
1551
1591
|
*
|
|
1552
|
-
*
|
|
1553
|
-
*
|
|
1554
|
-
*
|
|
1555
|
-
*
|
|
1556
|
-
* (`
|
|
1557
|
-
*
|
|
1592
|
+
* Strings, arrays and tables are the language's own, so the metatables they
|
|
1593
|
+
* answer to are declared here too — `declare metatable`, in tilua, the way a
|
|
1594
|
+
* library declares one. A string's is Lua's (`upper`, `sub`) with tilua's
|
|
1595
|
+
* answers where Lua's are several values (`find` is an array); the rest —
|
|
1596
|
+
* `names:filter(f)`, `text:trim()`, `point:keys()` — no Lua value really
|
|
1597
|
+
* has, and the compiler lowers each call to a function of its own runtime.
|
|
1598
|
+
* A library adds to any of them by declaring the same target again.
|
|
1599
|
+
*
|
|
1600
|
+
* The analyzer supplies only what no type can compute: `ObjectKeys<T>`,
|
|
1601
|
+
* `ObjectValues<T>` and `ObjectEntries<T>`, an object's members as tuples in
|
|
1602
|
+
* the order they were written.
|
|
1558
1603
|
*/
|
|
1559
|
-
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 (...args: unknown[]) => infer R ? R : never\ntype Parameters<T> = T extends (...args: 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";
|
|
1604
|
+
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 (...args: unknown[]) => infer R ? R : never\ntype Parameters<T> = T extends (...args: 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\n-- ============================================================\n-- The metatables of the language's own values\n-- ============================================================\n\n-- A string's methods. The first group is Lua's string library, which a\n-- string really answers to; where Lua answers several values, tilua answers\n-- one, as the global functions do (`find` is an array, `gsub` the new\n-- string). The second group is written the way JavaScript writes it.\n--\n-- Positions are Lua's: `sub` and `slice` count from 1, and `indexOf` is\n-- `nil` when the text is not there.\ndeclare metatable string: {\n __index: {\n upper: (self: string) => string,\n lower: (self: string) => string,\n len: (self: string) => number,\n sub: (self: string, i: number, j?: number) => string,\n rep: (self: string, n: number, separator?: string) => string,\n reverse: (self: string) => string,\n format: (self: string, ...args: unknown[]) => string,\n byte: ((self: string, i?: number) => number) & ((self: string, i: number, j: number) => number[]),\n find: (self: string, pattern: string, init?: number, plain?: boolean) => [number, number, ...string[]] | nil,\n match: (self: string, pattern: string, init?: number) => [...string[]] | nil,\n gmatch: (self: string, pattern: string) => () => [string, ...string[]] | nil,\n gsub: (self: string, pattern: string, replacement: unknown, n?: number) => string,\n\n trim: (self: string) => string,\n trimStart: (self: string) => string,\n trimEnd: (self: string) => string,\n startsWith: (self: string, text: string) => boolean,\n endsWith: (self: string, text: string) => boolean,\n includes: (self: string, text: string) => boolean,\n indexOf: (self: string, text: string, start?: number) => number | nil,\n slice: (self: string, start?: number, stop?: number) => string,\n replace: (self: string, text: string, replacement: string) => string,\n replaceAll: (self: string, text: string, replacement: string) => string,\n padStart: (self: string, length: number, padding?: string) => string,\n padEnd: (self: string, length: number, padding?: string) => string,\n },\n}\n\n-- An array's methods. Lua gives an array no metatable: the compiler lowers\n-- each call to a plain function, so they work on any array, one a Lua\n-- library made included.\n--\n-- Indices are Lua's: the first element is 1, and `indexOf` / `findIndex`\n-- answer `nil` rather than JavaScript's -1. `sort` takes Lua's comparator\n-- (true when `a` comes first). `push`, `pop`, `shift`, `unshift`,\n-- `sort` and `reverse` change the array; everything else returns a new one.\ndeclare metatable<T> T[]: {\n __index: {\n find: (self: T[], test: (value: T, index: number) => boolean) => T | nil,\n findIndex: (self: T[], test: (value: T, index: number) => boolean) => number | nil,\n filter: (self: T[], test: (value: T, index: number) => boolean) => T[],\n map: <U>(self: T[], transform: (value: T, index: number) => U) => U[],\n forEach: (self: T[], visit: (value: T, index: number) => nil) => nil,\n some: (self: T[], test: (value: T, index: number) => boolean) => boolean,\n every: (self: T[], test: (value: T, index: number) => boolean) => boolean,\n reduce: <U>(self: T[], step: (total: U, value: T, index: number) => U, initial: U) => U,\n includes: (self: T[], value: T) => boolean,\n indexOf: (self: T[], value: T, start?: number) => number | nil,\n join: (self: T[], separator?: string) => string,\n concat: (self: T[], ...others: T[][]) => T[],\n slice: (self: T[], start?: number, stop?: number) => T[],\n flat: (self: T[]) => T[],\n reverse: (self: T[]) => T[],\n sort: (self: T[], compare?: (a: T, b: T) => boolean) => T[],\n push: (self: T[], ...args: T[]) => number,\n pop: (self: T[]) => T | nil,\n shift: (self: T[]) => T | nil,\n unshift: (self: T[], ...args: T[]) => number,\n },\n}\n\n-- A table's methods. Unlike JavaScript's `Object.keys`, they answer a\n-- tuple, in the order the table's type wrote its members:\n--\n-- const point = { x: 1, y: \"up\" }\n-- point:keys() -- [\"x\", \"y\"]\n-- point:values() -- [number, string]\n-- point:entries() -- [[\"x\", number], [\"y\", string]]\n--\n-- A Lua table has no order of its own, so the compiler hands its runtime the\n-- keys as the type lists them. An optional member keeps its place, holding\n-- `nil` when it is missing; an indexer's keys follow the named ones. A\n-- member of the table's own with one of these names is what a call reaches,\n-- and a class instance, which has a metatable of its own, has none of them.\ndeclare metatable<T extends {}> T: {\n __index: {\n keys: (self: T) => ObjectKeys<T>,\n values: (self: T) => ObjectValues<T>,\n entries: (self: T) => ObjectEntries<T>,\n },\n}\n";
|
|
1560
1605
|
|
|
1561
1606
|
interface ProjectHost {
|
|
1562
1607
|
/** A file's text, or `undefined` when there is no such file. */
|
|
@@ -1632,9 +1677,9 @@ interface TypeLibraries {
|
|
|
1632
1677
|
* call written against this library's types should become.
|
|
1633
1678
|
*
|
|
1634
1679
|
* The library declares the *types* in its definitions file; this is the other
|
|
1635
|
-
* half. `names:
|
|
1636
|
-
* says so and ships the Luau behind it —
|
|
1637
|
-
* nothing about `
|
|
1680
|
+
* half. `names:first()` is a call to a function only because the library that
|
|
1681
|
+
* put `first` in an array's metatable says so and ships the Luau behind it —
|
|
1682
|
+
* the compiler knows how to ask, and nothing about `first`.
|
|
1638
1683
|
*
|
|
1639
1684
|
* `tilua.lowering` in the package.json names the module; what it must export
|
|
1640
1685
|
* is the compiler's business (see @tilua/compiler's `LoweringPlugin`). */
|
|
@@ -1643,6 +1688,10 @@ interface LoweringModule {
|
|
|
1643
1688
|
readonly file: string;
|
|
1644
1689
|
/** The package it came from, for reporting. */
|
|
1645
1690
|
readonly from: string;
|
|
1691
|
+
/** The package's definitions file, as its index in `files` — what the
|
|
1692
|
+
* analyzer names when a method comes from a metatable the package
|
|
1693
|
+
* declared (`MethodSource`), so the compiler asks this lowering. */
|
|
1694
|
+
readonly library: number;
|
|
1646
1695
|
}
|
|
1647
1696
|
declare function resolveTypeLibraries(config: TiluaConfig, host?: ProjectHost): TypeLibraries;
|
|
1648
1697
|
|
|
@@ -1651,10 +1700,11 @@ declare function resolveTypeLibraries(config: TiluaConfig, host?: ProjectHost):
|
|
|
1651
1700
|
*
|
|
1652
1701
|
* A library's definitions file says what a value *is*; when what it gives is
|
|
1653
1702
|
* not something the value already answers to, the library must also say how
|
|
1654
|
-
* it runs. `names:
|
|
1655
|
-
*
|
|
1656
|
-
* language (`import`, `export`, `?.`, `a ? b : c`, destructuring,
|
|
1657
|
-
* and
|
|
1703
|
+
* it runs. `names:first()` is a call to a function when a library declares
|
|
1704
|
+
* `first` in an array's metatable and ships the Luau behind it — the compiler
|
|
1705
|
+
* lowers the language (`import`, `export`, `?.`, `a ? b : c`, destructuring,
|
|
1706
|
+
* spreads, and the methods of the language's own metatables, such as
|
|
1707
|
+
* `names:filter(f)`) and asks a library about what the library declared.
|
|
1658
1708
|
*
|
|
1659
1709
|
* These types are declarations only: nothing here runs, and the parser never
|
|
1660
1710
|
* loads a lowering module. They live here so a library can be checked against
|
|
@@ -1666,10 +1716,8 @@ declare function resolveTypeLibraries(config: TiluaConfig, host?: ProjectHost):
|
|
|
1666
1716
|
* /** @type {import("@tilua/parser").LoweringPlugin} *\/
|
|
1667
1717
|
* const plugin = {
|
|
1668
1718
|
* runtime: { array: "local __NAME__ = {}\n..." },
|
|
1669
|
-
* methodCall({ method,
|
|
1670
|
-
* if (
|
|
1671
|
-
* return { callee: `${use("array")}.filter` }
|
|
1672
|
-
* }
|
|
1719
|
+
* methodCall({ method, use }) {
|
|
1720
|
+
* if (method === "first") return { callee: `${use("array")}.first` }
|
|
1673
1721
|
* return undefined
|
|
1674
1722
|
* },
|
|
1675
1723
|
* }
|
|
@@ -1694,10 +1742,12 @@ interface LoweringPlugin {
|
|
|
1694
1742
|
* that callback's errors the same way.
|
|
1695
1743
|
*
|
|
1696
1744
|
* local __NAME__ = {}
|
|
1697
|
-
* function __NAME__.
|
|
1745
|
+
* function __NAME__.first(t) return t[1] end
|
|
1698
1746
|
*/
|
|
1699
1747
|
readonly runtime?: Readonly<Record<string, string>>;
|
|
1700
|
-
/** What `receiver:method(...)` becomes.
|
|
1748
|
+
/** What `receiver:method(...)` becomes. Asked about a method a metatable
|
|
1749
|
+
* gave the receiver only when this library declared that metatable, and
|
|
1750
|
+
* about a method of the receiver's own always. `undefined` leaves a plain Luau
|
|
1701
1751
|
* method call, which is what a value that answers to the method itself
|
|
1702
1752
|
* wants — `text:upper()` reaches Lua's own. */
|
|
1703
1753
|
methodCall?(call: MethodCall): MethodLowering | undefined;
|
|
@@ -1828,4 +1878,4 @@ declare const tilua: {
|
|
|
1828
1878
|
readonly analyzeTypes: typeof analyzeTypes;
|
|
1829
1879
|
};
|
|
1830
1880
|
|
|
1831
|
-
export { type AnalyzeTypesOptions, type AnyType, type ArgumentInfo, 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, type BuildTarget, CONFIG_FILE_NAMES, type CallExpression, type CallLowering, type CallSite, type CallStatement, type ClassAccessibility, 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 ExpressionStatement, 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 GlobalCall, type GlobalValue, 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, LANGUAGE_GLOBALS, LexError, type LiteralToken, type LiteralType, type LoweringModule, type LoweringPlugin, 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 SuperExpression, type TableExpression, type TableField, type TableTypeNode, type TableTypeProperty, type TemplateLiteralType, type TemplateLiteralTypeNode, type TiluaConfig, 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 TypeOrigin, type TypeParamType, type TypePredicate, type TypePredicateNode, type TypeReference, type TypedIdentifier, type TypeofTypeNode, UNUSED_EXPECT_ERROR, type UnaryExpression, UnaryOperators, type Unification, type UnionType, type UnionTypeNode, type UnknownType, type VariableDeclaration, type WhileStatement, aliasNameOf, analyzeScopes, analyzeTypes, anyType, applyDirectives, arrayOf, booleanType, bufferType, containsTypeParam, declaredUnknownType, tilua as default, difference, directivesOf, equalTypes, falsyType, findConfig, fn, formatType, getBinding, intersection, isAssignable, isClassType, isGlobal, isPossiblyFalsy, isPossiblyTruthy, isUnassignedGlobal, literal, loadConfig, 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, tilua, tokenize, tuple, tupleMembers, typeParam, unify, union, unknownType, widen, withAliasName, withoutAliasName };
|
|
1881
|
+
export { type AnalyzeTypesOptions, type AnyType, type ArgumentInfo, 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, type BuildTarget, CONFIG_FILE_NAMES, type CallExpression, type CallLowering, type CallSite, type CallStatement, type ClassAccessibility, 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 DeclareMetatableStatement, 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 ExpressionStatement, 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 GlobalCall, type GlobalValue, 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, LANGUAGE_GLOBALS, LexError, type LiteralToken, type LiteralType, type LoweringModule, type LoweringPlugin, 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 SuperExpression, type TableExpression, type TableField, type TableTypeNode, type TableTypeProperty, type TemplateLiteralType, type TemplateLiteralTypeNode, type TiluaConfig, 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 TypeOrigin, type TypeParamType, type TypePredicate, type TypePredicateNode, type TypeReference, type TypedIdentifier, type TypeofTypeNode, UNUSED_EXPECT_ERROR, type UnaryExpression, UnaryOperators, type Unification, type UnionType, type UnionTypeNode, type UnknownType, type VariableDeclaration, type WhileStatement, aliasNameOf, analyzeScopes, analyzeTypes, anyType, applyDirectives, arrayOf, booleanType, bufferType, containsTypeParam, declaredUnknownType, tilua as default, difference, directivesOf, equalTypes, falsyType, findConfig, fn, formatType, getBinding, intersection, isAssignable, isClassType, isGlobal, isPossiblyFalsy, isPossiblyTruthy, isUnassignedGlobal, literal, loadConfig, 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, tilua, tokenize, tuple, tupleMembers, typeParam, unify, union, unknownType, widen, withAliasName, withoutAliasName };
|
package/dist/index.d.ts
CHANGED
|
@@ -212,7 +212,7 @@ interface ExportAllStatement extends BaseNode {
|
|
|
212
212
|
type: "ExportAllStatement";
|
|
213
213
|
source: StringLiteral;
|
|
214
214
|
}
|
|
215
|
-
type Statement = VariableDeclaration | FunctionDeclaration | FunctionDeclarationStatement | ClassDeclaration | AssignmentStatement | CompoundAssignmentStatement | CallStatement | ExpressionStatement | 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 | ExpressionStatement | DoStatement | WhileStatement | RepeatStatement | IfStatement | NumericForStatement | GenericForStatement | ReturnStatement | BreakStatement | ContinueStatement | TypeAliasStatement | ExportTypeAliasStatement | ImportStatement | ExportStatement | ExportDefaultStatement | ExportNamedStatement | ExportAllStatement | DeclareStatement | DeclareClassStatement | DeclareMetatableStatement | ErrorStatement;
|
|
216
216
|
/** `declare game: DataModel` / `declare function require(m: string): unknown`
|
|
217
217
|
* — an ambient value/function declaration for a definitions file (`.d.tilua`).
|
|
218
218
|
* Contributes a global type; emits no runtime code. */
|
|
@@ -236,6 +236,25 @@ interface DeclareClassStatement extends BaseNode {
|
|
|
236
236
|
superclass?: TypeReference;
|
|
237
237
|
body: TableTypeNode;
|
|
238
238
|
}
|
|
239
|
+
/** `declare metatable string: { __index: StringLibrary }` — the metatable
|
|
240
|
+
* every value of `target` has, as far as types go. A method call reads
|
|
241
|
+
* through its `__index`: `text:upper()` is `upper` there.
|
|
242
|
+
*
|
|
243
|
+
* A library may declare one a value does not really have — Lua gives an
|
|
244
|
+
* array none — and ship a lowering that turns a call through it into a
|
|
245
|
+
* call of its own (`names:filter(f)` becomes `array.filter(names, f)`).
|
|
246
|
+
* The compiler asks the library that declared the metatable, and only it.
|
|
247
|
+
*
|
|
248
|
+
* `target` may use the declaration's type parameters: `<T> T[]` is every
|
|
249
|
+
* array, `T` its elements; `<T extends {}> T` every plain table, `T` the
|
|
250
|
+
* table itself. The most specific target a value matches is its metatable,
|
|
251
|
+
* and declaring one target again adds to it. */
|
|
252
|
+
interface DeclareMetatableStatement extends BaseNode {
|
|
253
|
+
type: "DeclareMetatableStatement";
|
|
254
|
+
generics: GenericTypeParameter[];
|
|
255
|
+
target: TypeNode;
|
|
256
|
+
metatable: TypeNode;
|
|
257
|
+
}
|
|
239
258
|
/** A statement position that could not be parsed. Only produced when parsing
|
|
240
259
|
* in recovery mode (`parseWithRecovery`); its span covers the skipped tokens
|
|
241
260
|
* so tools can still map a cursor there. */
|
|
@@ -254,7 +273,9 @@ interface VariableDeclaration extends BaseNode {
|
|
|
254
273
|
/** Absent only on `let x`. */
|
|
255
274
|
init?: Expression;
|
|
256
275
|
}
|
|
257
|
-
|
|
276
|
+
/** A member or an index (`t.a`, `t[i]`) is a leaf only in a destructuring
|
|
277
|
+
* assignment (`[t[i], t[j]] = [t[j], t[i]]`): a declaration binds names. */
|
|
278
|
+
type BindingTarget = IdentifierPattern | ObjectPattern | ArrayPattern | MemberExpression | IndexExpression;
|
|
258
279
|
interface IdentifierPattern extends BaseNode {
|
|
259
280
|
type: "IdentifierPattern";
|
|
260
281
|
name: string;
|
|
@@ -1486,8 +1507,27 @@ interface TypeAnalysis {
|
|
|
1486
1507
|
/** How each `for (const item in source)` walks its source; see
|
|
1487
1508
|
* `LoopForm`. A loop missing here walks values. */
|
|
1488
1509
|
readonly loops: ReadonlyMap<GenericForStatement, LoopForm>;
|
|
1510
|
+
/** Each `receiver:method(...)` whose method the receiver's metatable
|
|
1511
|
+
* gave it (`declare metatable`), and which library declared that. A call
|
|
1512
|
+
* missing here reached a member of the receiver's own. */
|
|
1513
|
+
readonly methodSources: ReadonlyMap<MethodCallExpression, MethodSource>;
|
|
1514
|
+
/** The members a value's metatable `__index` gives it — what an editor
|
|
1515
|
+
* offers after `:`. Empty for a value no metatable matches. */
|
|
1516
|
+
readonly metatableMembers: (type: Type) => ReadonlyMap<string, Type>;
|
|
1489
1517
|
readonly diagnostics: TypeDiagnostic[];
|
|
1490
1518
|
}
|
|
1519
|
+
/** Where a metatable reached by a method call was declared: by the language
|
|
1520
|
+
* itself (the prelude's metatables for strings, arrays and tables), by a
|
|
1521
|
+
* library (its index in `libs`), or by the program. The compiler lowers a
|
|
1522
|
+
* language method itself, and asks a library about its own. */
|
|
1523
|
+
type MethodSource = {
|
|
1524
|
+
readonly origin: "language";
|
|
1525
|
+
} | {
|
|
1526
|
+
readonly origin: "library";
|
|
1527
|
+
readonly library: number;
|
|
1528
|
+
} | {
|
|
1529
|
+
readonly origin: "program";
|
|
1530
|
+
};
|
|
1491
1531
|
/** A type a module exports: the resolved type, plus the parameter names of a
|
|
1492
1532
|
* generic alias so an importer can instantiate it (`Box<number>`). */
|
|
1493
1533
|
interface ExportedType {
|
|
@@ -1549,14 +1589,19 @@ resolveModule?: (specifier: string) => ModuleExports | undefined): ModuleExports
|
|
|
1549
1589
|
* What a runtime provides — `print`, `string`, `game` — is not here: that is a
|
|
1550
1590
|
* type library's job (`@tilua-types/lua`, `@tilua-types/roblox`).
|
|
1551
1591
|
*
|
|
1552
|
-
*
|
|
1553
|
-
*
|
|
1554
|
-
*
|
|
1555
|
-
*
|
|
1556
|
-
* (`
|
|
1557
|
-
*
|
|
1592
|
+
* Strings, arrays and tables are the language's own, so the metatables they
|
|
1593
|
+
* answer to are declared here too — `declare metatable`, in tilua, the way a
|
|
1594
|
+
* library declares one. A string's is Lua's (`upper`, `sub`) with tilua's
|
|
1595
|
+
* answers where Lua's are several values (`find` is an array); the rest —
|
|
1596
|
+
* `names:filter(f)`, `text:trim()`, `point:keys()` — no Lua value really
|
|
1597
|
+
* has, and the compiler lowers each call to a function of its own runtime.
|
|
1598
|
+
* A library adds to any of them by declaring the same target again.
|
|
1599
|
+
*
|
|
1600
|
+
* The analyzer supplies only what no type can compute: `ObjectKeys<T>`,
|
|
1601
|
+
* `ObjectValues<T>` and `ObjectEntries<T>`, an object's members as tuples in
|
|
1602
|
+
* the order they were written.
|
|
1558
1603
|
*/
|
|
1559
|
-
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 (...args: unknown[]) => infer R ? R : never\ntype Parameters<T> = T extends (...args: 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";
|
|
1604
|
+
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 (...args: unknown[]) => infer R ? R : never\ntype Parameters<T> = T extends (...args: 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\n-- ============================================================\n-- The metatables of the language's own values\n-- ============================================================\n\n-- A string's methods. The first group is Lua's string library, which a\n-- string really answers to; where Lua answers several values, tilua answers\n-- one, as the global functions do (`find` is an array, `gsub` the new\n-- string). The second group is written the way JavaScript writes it.\n--\n-- Positions are Lua's: `sub` and `slice` count from 1, and `indexOf` is\n-- `nil` when the text is not there.\ndeclare metatable string: {\n __index: {\n upper: (self: string) => string,\n lower: (self: string) => string,\n len: (self: string) => number,\n sub: (self: string, i: number, j?: number) => string,\n rep: (self: string, n: number, separator?: string) => string,\n reverse: (self: string) => string,\n format: (self: string, ...args: unknown[]) => string,\n byte: ((self: string, i?: number) => number) & ((self: string, i: number, j: number) => number[]),\n find: (self: string, pattern: string, init?: number, plain?: boolean) => [number, number, ...string[]] | nil,\n match: (self: string, pattern: string, init?: number) => [...string[]] | nil,\n gmatch: (self: string, pattern: string) => () => [string, ...string[]] | nil,\n gsub: (self: string, pattern: string, replacement: unknown, n?: number) => string,\n\n trim: (self: string) => string,\n trimStart: (self: string) => string,\n trimEnd: (self: string) => string,\n startsWith: (self: string, text: string) => boolean,\n endsWith: (self: string, text: string) => boolean,\n includes: (self: string, text: string) => boolean,\n indexOf: (self: string, text: string, start?: number) => number | nil,\n slice: (self: string, start?: number, stop?: number) => string,\n replace: (self: string, text: string, replacement: string) => string,\n replaceAll: (self: string, text: string, replacement: string) => string,\n padStart: (self: string, length: number, padding?: string) => string,\n padEnd: (self: string, length: number, padding?: string) => string,\n },\n}\n\n-- An array's methods. Lua gives an array no metatable: the compiler lowers\n-- each call to a plain function, so they work on any array, one a Lua\n-- library made included.\n--\n-- Indices are Lua's: the first element is 1, and `indexOf` / `findIndex`\n-- answer `nil` rather than JavaScript's -1. `sort` takes Lua's comparator\n-- (true when `a` comes first). `push`, `pop`, `shift`, `unshift`,\n-- `sort` and `reverse` change the array; everything else returns a new one.\ndeclare metatable<T> T[]: {\n __index: {\n find: (self: T[], test: (value: T, index: number) => boolean) => T | nil,\n findIndex: (self: T[], test: (value: T, index: number) => boolean) => number | nil,\n filter: (self: T[], test: (value: T, index: number) => boolean) => T[],\n map: <U>(self: T[], transform: (value: T, index: number) => U) => U[],\n forEach: (self: T[], visit: (value: T, index: number) => nil) => nil,\n some: (self: T[], test: (value: T, index: number) => boolean) => boolean,\n every: (self: T[], test: (value: T, index: number) => boolean) => boolean,\n reduce: <U>(self: T[], step: (total: U, value: T, index: number) => U, initial: U) => U,\n includes: (self: T[], value: T) => boolean,\n indexOf: (self: T[], value: T, start?: number) => number | nil,\n join: (self: T[], separator?: string) => string,\n concat: (self: T[], ...others: T[][]) => T[],\n slice: (self: T[], start?: number, stop?: number) => T[],\n flat: (self: T[]) => T[],\n reverse: (self: T[]) => T[],\n sort: (self: T[], compare?: (a: T, b: T) => boolean) => T[],\n push: (self: T[], ...args: T[]) => number,\n pop: (self: T[]) => T | nil,\n shift: (self: T[]) => T | nil,\n unshift: (self: T[], ...args: T[]) => number,\n },\n}\n\n-- A table's methods. Unlike JavaScript's `Object.keys`, they answer a\n-- tuple, in the order the table's type wrote its members:\n--\n-- const point = { x: 1, y: \"up\" }\n-- point:keys() -- [\"x\", \"y\"]\n-- point:values() -- [number, string]\n-- point:entries() -- [[\"x\", number], [\"y\", string]]\n--\n-- A Lua table has no order of its own, so the compiler hands its runtime the\n-- keys as the type lists them. An optional member keeps its place, holding\n-- `nil` when it is missing; an indexer's keys follow the named ones. A\n-- member of the table's own with one of these names is what a call reaches,\n-- and a class instance, which has a metatable of its own, has none of them.\ndeclare metatable<T extends {}> T: {\n __index: {\n keys: (self: T) => ObjectKeys<T>,\n values: (self: T) => ObjectValues<T>,\n entries: (self: T) => ObjectEntries<T>,\n },\n}\n";
|
|
1560
1605
|
|
|
1561
1606
|
interface ProjectHost {
|
|
1562
1607
|
/** A file's text, or `undefined` when there is no such file. */
|
|
@@ -1632,9 +1677,9 @@ interface TypeLibraries {
|
|
|
1632
1677
|
* call written against this library's types should become.
|
|
1633
1678
|
*
|
|
1634
1679
|
* The library declares the *types* in its definitions file; this is the other
|
|
1635
|
-
* half. `names:
|
|
1636
|
-
* says so and ships the Luau behind it —
|
|
1637
|
-
* nothing about `
|
|
1680
|
+
* half. `names:first()` is a call to a function only because the library that
|
|
1681
|
+
* put `first` in an array's metatable says so and ships the Luau behind it —
|
|
1682
|
+
* the compiler knows how to ask, and nothing about `first`.
|
|
1638
1683
|
*
|
|
1639
1684
|
* `tilua.lowering` in the package.json names the module; what it must export
|
|
1640
1685
|
* is the compiler's business (see @tilua/compiler's `LoweringPlugin`). */
|
|
@@ -1643,6 +1688,10 @@ interface LoweringModule {
|
|
|
1643
1688
|
readonly file: string;
|
|
1644
1689
|
/** The package it came from, for reporting. */
|
|
1645
1690
|
readonly from: string;
|
|
1691
|
+
/** The package's definitions file, as its index in `files` — what the
|
|
1692
|
+
* analyzer names when a method comes from a metatable the package
|
|
1693
|
+
* declared (`MethodSource`), so the compiler asks this lowering. */
|
|
1694
|
+
readonly library: number;
|
|
1646
1695
|
}
|
|
1647
1696
|
declare function resolveTypeLibraries(config: TiluaConfig, host?: ProjectHost): TypeLibraries;
|
|
1648
1697
|
|
|
@@ -1651,10 +1700,11 @@ declare function resolveTypeLibraries(config: TiluaConfig, host?: ProjectHost):
|
|
|
1651
1700
|
*
|
|
1652
1701
|
* A library's definitions file says what a value *is*; when what it gives is
|
|
1653
1702
|
* not something the value already answers to, the library must also say how
|
|
1654
|
-
* it runs. `names:
|
|
1655
|
-
*
|
|
1656
|
-
* language (`import`, `export`, `?.`, `a ? b : c`, destructuring,
|
|
1657
|
-
* and
|
|
1703
|
+
* it runs. `names:first()` is a call to a function when a library declares
|
|
1704
|
+
* `first` in an array's metatable and ships the Luau behind it — the compiler
|
|
1705
|
+
* lowers the language (`import`, `export`, `?.`, `a ? b : c`, destructuring,
|
|
1706
|
+
* spreads, and the methods of the language's own metatables, such as
|
|
1707
|
+
* `names:filter(f)`) and asks a library about what the library declared.
|
|
1658
1708
|
*
|
|
1659
1709
|
* These types are declarations only: nothing here runs, and the parser never
|
|
1660
1710
|
* loads a lowering module. They live here so a library can be checked against
|
|
@@ -1666,10 +1716,8 @@ declare function resolveTypeLibraries(config: TiluaConfig, host?: ProjectHost):
|
|
|
1666
1716
|
* /** @type {import("@tilua/parser").LoweringPlugin} *\/
|
|
1667
1717
|
* const plugin = {
|
|
1668
1718
|
* runtime: { array: "local __NAME__ = {}\n..." },
|
|
1669
|
-
* methodCall({ method,
|
|
1670
|
-
* if (
|
|
1671
|
-
* return { callee: `${use("array")}.filter` }
|
|
1672
|
-
* }
|
|
1719
|
+
* methodCall({ method, use }) {
|
|
1720
|
+
* if (method === "first") return { callee: `${use("array")}.first` }
|
|
1673
1721
|
* return undefined
|
|
1674
1722
|
* },
|
|
1675
1723
|
* }
|
|
@@ -1694,10 +1742,12 @@ interface LoweringPlugin {
|
|
|
1694
1742
|
* that callback's errors the same way.
|
|
1695
1743
|
*
|
|
1696
1744
|
* local __NAME__ = {}
|
|
1697
|
-
* function __NAME__.
|
|
1745
|
+
* function __NAME__.first(t) return t[1] end
|
|
1698
1746
|
*/
|
|
1699
1747
|
readonly runtime?: Readonly<Record<string, string>>;
|
|
1700
|
-
/** What `receiver:method(...)` becomes.
|
|
1748
|
+
/** What `receiver:method(...)` becomes. Asked about a method a metatable
|
|
1749
|
+
* gave the receiver only when this library declared that metatable, and
|
|
1750
|
+
* about a method of the receiver's own always. `undefined` leaves a plain Luau
|
|
1701
1751
|
* method call, which is what a value that answers to the method itself
|
|
1702
1752
|
* wants — `text:upper()` reaches Lua's own. */
|
|
1703
1753
|
methodCall?(call: MethodCall): MethodLowering | undefined;
|
|
@@ -1828,4 +1878,4 @@ declare const tilua: {
|
|
|
1828
1878
|
readonly analyzeTypes: typeof analyzeTypes;
|
|
1829
1879
|
};
|
|
1830
1880
|
|
|
1831
|
-
export { type AnalyzeTypesOptions, type AnyType, type ArgumentInfo, 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, type BuildTarget, CONFIG_FILE_NAMES, type CallExpression, type CallLowering, type CallSite, type CallStatement, type ClassAccessibility, 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 ExpressionStatement, 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 GlobalCall, type GlobalValue, 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, LANGUAGE_GLOBALS, LexError, type LiteralToken, type LiteralType, type LoweringModule, type LoweringPlugin, 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 SuperExpression, type TableExpression, type TableField, type TableTypeNode, type TableTypeProperty, type TemplateLiteralType, type TemplateLiteralTypeNode, type TiluaConfig, 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 TypeOrigin, type TypeParamType, type TypePredicate, type TypePredicateNode, type TypeReference, type TypedIdentifier, type TypeofTypeNode, UNUSED_EXPECT_ERROR, type UnaryExpression, UnaryOperators, type Unification, type UnionType, type UnionTypeNode, type UnknownType, type VariableDeclaration, type WhileStatement, aliasNameOf, analyzeScopes, analyzeTypes, anyType, applyDirectives, arrayOf, booleanType, bufferType, containsTypeParam, declaredUnknownType, tilua as default, difference, directivesOf, equalTypes, falsyType, findConfig, fn, formatType, getBinding, intersection, isAssignable, isClassType, isGlobal, isPossiblyFalsy, isPossiblyTruthy, isUnassignedGlobal, literal, loadConfig, 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, tilua, tokenize, tuple, tupleMembers, typeParam, unify, union, unknownType, widen, withAliasName, withoutAliasName };
|
|
1881
|
+
export { type AnalyzeTypesOptions, type AnyType, type ArgumentInfo, 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, type BuildTarget, CONFIG_FILE_NAMES, type CallExpression, type CallLowering, type CallSite, type CallStatement, type ClassAccessibility, 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 DeclareMetatableStatement, 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 ExpressionStatement, 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 GlobalCall, type GlobalValue, 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, LANGUAGE_GLOBALS, LexError, type LiteralToken, type LiteralType, type LoweringModule, type LoweringPlugin, 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 SuperExpression, type TableExpression, type TableField, type TableTypeNode, type TableTypeProperty, type TemplateLiteralType, type TemplateLiteralTypeNode, type TiluaConfig, 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 TypeOrigin, type TypeParamType, type TypePredicate, type TypePredicateNode, type TypeReference, type TypedIdentifier, type TypeofTypeNode, UNUSED_EXPECT_ERROR, type UnaryExpression, UnaryOperators, type Unification, type UnionType, type UnionTypeNode, type UnknownType, type VariableDeclaration, type WhileStatement, aliasNameOf, analyzeScopes, analyzeTypes, anyType, applyDirectives, arrayOf, booleanType, bufferType, containsTypeParam, declaredUnknownType, tilua as default, difference, directivesOf, equalTypes, falsyType, findConfig, fn, formatType, getBinding, intersection, isAssignable, isClassType, isGlobal, isPossiblyFalsy, isPossiblyTruthy, isUnassignedGlobal, literal, loadConfig, 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, tilua, tokenize, tuple, tupleMembers, typeParam, unify, union, unknownType, widen, withAliasName, withoutAliasName };
|