@tilua/parser 2.2.0 → 2.4.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
@@ -242,16 +242,21 @@ interface DeclareClassStatement extends BaseNode {
242
242
  interface ErrorStatement extends BaseNode {
243
243
  type: "ErrorStatement";
244
244
  }
245
- /** `const x = 1` / `let x, y = a, b` — the only variable-binding form in tilua
246
- * (Luau's `local` is gone). `const` bindings are immutable and infer literal
247
- * types (`const n = 1` → `1`); `let` bindings are mutable and widen. */
245
+ /** `const x = 1` / `let [a, b] = pair` — the only variable-binding form in
246
+ * tilua (Luau's `local` is gone). One name, or one pattern, and one value:
247
+ * several are taken from an array with a destructuring. `const` bindings are
248
+ * immutable and infer literal types (`const n = 1` → `1`); `let` bindings
249
+ * are mutable and widen. */
248
250
  interface VariableDeclaration extends BaseNode {
249
251
  type: "VariableDeclaration";
250
252
  kind: "const" | "let";
251
- names: BindingTarget[];
252
- init: Expression[];
253
+ name: BindingTarget;
254
+ /** Absent only on `let x`. */
255
+ init?: Expression;
253
256
  }
254
- type BindingTarget = IdentifierPattern | ObjectPattern | ArrayPattern;
257
+ /** A member or an index (`t.a`, `t[i]`) is a leaf only in a destructuring
258
+ * assignment (`[t[i], t[j]] = [t[j], t[i]]`): a declaration binds names. */
259
+ type BindingTarget = IdentifierPattern | ObjectPattern | ArrayPattern | MemberExpression | IndexExpression;
255
260
  interface IdentifierPattern extends BaseNode {
256
261
  type: "IdentifierPattern";
257
262
  name: string;
@@ -448,10 +453,11 @@ interface ClassConstructor extends BaseNode {
448
453
  interface SuperExpression extends BaseNode {
449
454
  type: "SuperExpression";
450
455
  }
456
+ /** `x = v` / `[a, b] = [b, a]` — one target, one value. */
451
457
  interface AssignmentStatement extends BaseNode {
452
458
  type: "AssignmentStatement";
453
- targets: (Expression | ObjectPattern | ArrayPattern)[];
454
- values: Expression[];
459
+ target: Expression | ObjectPattern | ArrayPattern;
460
+ value: Expression;
455
461
  }
456
462
  interface CompoundAssignmentStatement extends BaseNode {
457
463
  type: "CompoundAssignmentStatement";
@@ -672,9 +678,7 @@ interface ArrayExpression extends BaseNode {
672
678
  * only produces one in those two places.
673
679
  *
674
680
  * Lua spreads with `table.unpack`, which only yields every value when it is
675
- * written last; anywhere else the compiler builds the whole list first. Bare
676
- * `...` is unaffected — that is the vararg pack, and `f(...)` passes it on
677
- * as it always did. */
681
+ * written last; anywhere else the compiler builds the whole list first. */
678
682
  interface SpreadElement extends BaseNode {
679
683
  type: "SpreadElement";
680
684
  argument: Expression;
package/dist/index.d.ts CHANGED
@@ -242,16 +242,21 @@ interface DeclareClassStatement extends BaseNode {
242
242
  interface ErrorStatement extends BaseNode {
243
243
  type: "ErrorStatement";
244
244
  }
245
- /** `const x = 1` / `let x, y = a, b` — the only variable-binding form in tilua
246
- * (Luau's `local` is gone). `const` bindings are immutable and infer literal
247
- * types (`const n = 1` → `1`); `let` bindings are mutable and widen. */
245
+ /** `const x = 1` / `let [a, b] = pair` — the only variable-binding form in
246
+ * tilua (Luau's `local` is gone). One name, or one pattern, and one value:
247
+ * several are taken from an array with a destructuring. `const` bindings are
248
+ * immutable and infer literal types (`const n = 1` → `1`); `let` bindings
249
+ * are mutable and widen. */
248
250
  interface VariableDeclaration extends BaseNode {
249
251
  type: "VariableDeclaration";
250
252
  kind: "const" | "let";
251
- names: BindingTarget[];
252
- init: Expression[];
253
+ name: BindingTarget;
254
+ /** Absent only on `let x`. */
255
+ init?: Expression;
253
256
  }
254
- type BindingTarget = IdentifierPattern | ObjectPattern | ArrayPattern;
257
+ /** A member or an index (`t.a`, `t[i]`) is a leaf only in a destructuring
258
+ * assignment (`[t[i], t[j]] = [t[j], t[i]]`): a declaration binds names. */
259
+ type BindingTarget = IdentifierPattern | ObjectPattern | ArrayPattern | MemberExpression | IndexExpression;
255
260
  interface IdentifierPattern extends BaseNode {
256
261
  type: "IdentifierPattern";
257
262
  name: string;
@@ -448,10 +453,11 @@ interface ClassConstructor extends BaseNode {
448
453
  interface SuperExpression extends BaseNode {
449
454
  type: "SuperExpression";
450
455
  }
456
+ /** `x = v` / `[a, b] = [b, a]` — one target, one value. */
451
457
  interface AssignmentStatement extends BaseNode {
452
458
  type: "AssignmentStatement";
453
- targets: (Expression | ObjectPattern | ArrayPattern)[];
454
- values: Expression[];
459
+ target: Expression | ObjectPattern | ArrayPattern;
460
+ value: Expression;
455
461
  }
456
462
  interface CompoundAssignmentStatement extends BaseNode {
457
463
  type: "CompoundAssignmentStatement";
@@ -672,9 +678,7 @@ interface ArrayExpression extends BaseNode {
672
678
  * only produces one in those two places.
673
679
  *
674
680
  * Lua spreads with `table.unpack`, which only yields every value when it is
675
- * written last; anywhere else the compiler builds the whole list first. Bare
676
- * `...` is unaffected — that is the vararg pack, and `f(...)` passes it on
677
- * as it always did. */
681
+ * written last; anywhere else the compiler builds the whole list first. */
678
682
  interface SpreadElement extends BaseNode {
679
683
  type: "SpreadElement";
680
684
  argument: Expression;