typescript-to-lua 1.25.2 → 1.26.1

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.
Files changed (105) hide show
  1. package/dist/CompilerOptions.js +2 -2
  2. package/dist/LuaAST.js +76 -77
  3. package/dist/LuaLib.d.ts +1 -0
  4. package/dist/LuaLib.js +13 -12
  5. package/dist/LuaPrinter.js +2 -2
  6. package/dist/cli/information.js +2 -2
  7. package/dist/cli/parse.js +3 -3
  8. package/dist/cli/report.d.ts +4 -4
  9. package/dist/cli/report.js +2 -2
  10. package/dist/cli/tsconfig.js +3 -4
  11. package/dist/lualib/5.0/MathSign.lua +5 -4
  12. package/dist/lualib/5.0/MathTrunc.lua +6 -0
  13. package/dist/lualib/5.0/Set.lua +58 -0
  14. package/dist/lualib/5.0/lualib_bundle.lua +79 -12
  15. package/dist/lualib/5.0/lualib_module_info.json +13 -1
  16. package/dist/lualib/universal/MathSign.lua +5 -4
  17. package/dist/lualib/universal/MathTrunc.lua +6 -0
  18. package/dist/lualib/universal/Set.lua +58 -0
  19. package/dist/lualib/universal/lualib_bundle.lua +79 -12
  20. package/dist/lualib/universal/lualib_module_info.json +13 -1
  21. package/dist/lualib-build/plugin.d.ts +1 -1
  22. package/dist/lualib-build/util.js +8 -9
  23. package/dist/measure-performance.js +7 -8
  24. package/dist/transformation/builtins/array.js +3 -4
  25. package/dist/transformation/builtins/console.js +1 -2
  26. package/dist/transformation/builtins/function.js +2 -3
  27. package/dist/transformation/builtins/global.js +1 -2
  28. package/dist/transformation/builtins/index.js +4 -5
  29. package/dist/transformation/builtins/map.js +1 -2
  30. package/dist/transformation/builtins/math.js +5 -3
  31. package/dist/transformation/builtins/number.js +3 -4
  32. package/dist/transformation/builtins/object.js +2 -3
  33. package/dist/transformation/builtins/promise.js +4 -5
  34. package/dist/transformation/builtins/string.js +3 -4
  35. package/dist/transformation/builtins/symbol.js +1 -2
  36. package/dist/transformation/context/context.d.ts +0 -3
  37. package/dist/transformation/index.js +2 -3
  38. package/dist/transformation/pre-transformers/using-transformer.js +1 -2
  39. package/dist/transformation/utils/annotations.js +5 -5
  40. package/dist/transformation/utils/assignment-validation.js +1 -2
  41. package/dist/transformation/utils/export.js +14 -14
  42. package/dist/transformation/utils/function-context.js +3 -3
  43. package/dist/transformation/utils/language-extensions.js +10 -10
  44. package/dist/transformation/utils/lua-ast.js +12 -12
  45. package/dist/transformation/utils/lualib.js +3 -3
  46. package/dist/transformation/utils/preceding-statements.js +1 -2
  47. package/dist/transformation/utils/safe-names.js +3 -3
  48. package/dist/transformation/utils/scope.js +11 -11
  49. package/dist/transformation/utils/symbols.js +4 -5
  50. package/dist/transformation/utils/typescript/index.js +13 -14
  51. package/dist/transformation/utils/typescript/nodes.js +8 -9
  52. package/dist/transformation/utils/typescript/types.js +10 -11
  53. package/dist/transformation/visitors/access.js +4 -4
  54. package/dist/transformation/visitors/async-await.js +3 -3
  55. package/dist/transformation/visitors/binary-expression/assignments.js +5 -6
  56. package/dist/transformation/visitors/binary-expression/bit.js +3 -3
  57. package/dist/transformation/visitors/binary-expression/compound.js +3 -3
  58. package/dist/transformation/visitors/binary-expression/destructuring-assignments.js +3 -4
  59. package/dist/transformation/visitors/binary-expression/index.js +4 -4
  60. package/dist/transformation/visitors/block.js +3 -3
  61. package/dist/transformation/visitors/call.js +6 -6
  62. package/dist/transformation/visitors/class/decorators.js +6 -7
  63. package/dist/transformation/visitors/class/index.js +14 -3
  64. package/dist/transformation/visitors/class/members/accessors.js +1 -2
  65. package/dist/transformation/visitors/class/members/constructor.js +3 -4
  66. package/dist/transformation/visitors/class/members/fields.js +2 -3
  67. package/dist/transformation/visitors/class/members/method.js +3 -4
  68. package/dist/transformation/visitors/class/setup.js +2 -3
  69. package/dist/transformation/visitors/class/utils.js +5 -6
  70. package/dist/transformation/visitors/conditional.js +3 -3
  71. package/dist/transformation/visitors/enum.js +2 -2
  72. package/dist/transformation/visitors/expression-list.js +4 -5
  73. package/dist/transformation/visitors/expression-statement.js +2 -2
  74. package/dist/transformation/visitors/function.js +9 -9
  75. package/dist/transformation/visitors/identifier.js +4 -4
  76. package/dist/transformation/visitors/language-extensions/call-extension.js +2 -2
  77. package/dist/transformation/visitors/language-extensions/identifier.js +2 -3
  78. package/dist/transformation/visitors/language-extensions/iterable.js +3 -4
  79. package/dist/transformation/visitors/language-extensions/multi.js +8 -9
  80. package/dist/transformation/visitors/language-extensions/range.js +3 -4
  81. package/dist/transformation/visitors/language-extensions/table.js +2 -2
  82. package/dist/transformation/visitors/language-extensions/vararg.js +2 -3
  83. package/dist/transformation/visitors/literal.js +3 -3
  84. package/dist/transformation/visitors/loops/utils.js +4 -5
  85. package/dist/transformation/visitors/modules/export.js +0 -3
  86. package/dist/transformation/visitors/modules/import.js +2 -2
  87. package/dist/transformation/visitors/namespace.js +3 -3
  88. package/dist/transformation/visitors/optional-chaining.js +6 -7
  89. package/dist/transformation/visitors/return.js +3 -3
  90. package/dist/transformation/visitors/spread.js +2 -2
  91. package/dist/transformation/visitors/typeof.js +2 -2
  92. package/dist/transformation/visitors/unary-expression.js +2 -2
  93. package/dist/transformation/visitors/variable-declaration.js +6 -6
  94. package/dist/transpilation/bundle.js +3 -3
  95. package/dist/transpilation/find-lua-requires.js +1 -2
  96. package/dist/transpilation/index.js +5 -6
  97. package/dist/transpilation/output-collector.js +1 -2
  98. package/dist/transpilation/plugins.js +1 -2
  99. package/dist/transpilation/resolve.js +1 -2
  100. package/dist/transpilation/transformers.js +2 -2
  101. package/dist/transpilation/transpile.js +1 -2
  102. package/dist/transpilation/transpiler.js +6 -6
  103. package/dist/transpilation/utils.js +2 -2
  104. package/dist/utils.js +9 -9
  105. package/package.json +6 -7
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformCompoundAssignmentStatement = exports.transformCompoundAssignmentExpression = exports.unwrapCompoundAssignmentToken = exports.isCompoundAssignmentToken = void 0;
3
+ exports.unwrapCompoundAssignmentToken = exports.isCompoundAssignmentToken = void 0;
4
+ exports.transformCompoundAssignmentExpression = transformCompoundAssignmentExpression;
5
+ exports.transformCompoundAssignmentStatement = transformCompoundAssignmentStatement;
4
6
  const ts = require("typescript");
5
7
  const lua = require("../../../LuaAST");
6
8
  const utils_1 = require("../../../utils");
@@ -127,7 +129,6 @@ lhs, rhs, operator, isPostfix) {
127
129
  context.addPrecedingStatements(precedingStatements);
128
130
  return result;
129
131
  }
130
- exports.transformCompoundAssignmentExpression = transformCompoundAssignmentExpression;
131
132
  function transformCompoundAssignmentStatement(context, node, lhs, rhs, operator) {
132
133
  if ((0, destructuring_assignments_1.isArrayLength)(context, lhs)) {
133
134
  const { precedingStatements, result: lengthSetterStatement } = transformCompoundLengthSetter(context, node, lhs, rhs, operator);
@@ -167,7 +168,6 @@ function transformCompoundAssignmentStatement(context, node, lhs, rhs, operator)
167
168
  return (0, assignments_1.transformAssignmentWithRightPrecedingStatements)(context, lhs, operatorExpression, rightPrecedingStatements2);
168
169
  }
169
170
  }
170
- exports.transformCompoundAssignmentStatement = transformCompoundAssignmentStatement;
171
171
  function isSetterSkippingCompoundAssignmentOperator(operator) {
172
172
  return (operator === ts.SyntaxKind.AmpersandAmpersandToken ||
173
173
  operator === ts.SyntaxKind.BarBarToken ||
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformAssignmentPattern = exports.transformDestructuringAssignment = exports.isArrayLength = void 0;
3
+ exports.isArrayLength = isArrayLength;
4
+ exports.transformDestructuringAssignment = transformDestructuringAssignment;
5
+ exports.transformAssignmentPattern = transformAssignmentPattern;
4
6
  const ts = require("typescript");
5
7
  const _1 = require(".");
6
8
  const lua = require("../../../LuaAST");
@@ -26,11 +28,9 @@ function isArrayLength(context, expression) {
26
28
  : undefined;
27
29
  return name === "length";
28
30
  }
29
- exports.isArrayLength = isArrayLength;
30
31
  function transformDestructuringAssignment(context, node, root, rightHasPrecedingStatements) {
31
32
  return transformAssignmentPattern(context, node.left, root, rightHasPrecedingStatements);
32
33
  }
33
- exports.transformDestructuringAssignment = transformDestructuringAssignment;
34
34
  function transformAssignmentPattern(context, node, root, rightHasPrecedingStatements) {
35
35
  switch (node.kind) {
36
36
  case ts.SyntaxKind.ObjectLiteralExpression:
@@ -39,7 +39,6 @@ function transformAssignmentPattern(context, node, root, rightHasPrecedingStatem
39
39
  return transformArrayLiteralAssignmentPattern(context, node, root, rightHasPrecedingStatements);
40
40
  }
41
41
  }
42
- exports.transformAssignmentPattern = transformAssignmentPattern;
43
42
  function transformArrayLiteralAssignmentPattern(context, node, root, rightHasPrecedingStatements) {
44
43
  return node.elements.flatMap((element, index) => {
45
44
  const indexedRoot = lua.createTableIndexExpression(root, lua.createNumericLiteral(index + 1), element);
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformBinaryExpressionStatement = exports.transformBinaryExpression = exports.transformBinaryOperation = exports.createShortCircuitBinaryExpressionPrecedingStatements = void 0;
3
+ exports.transformBinaryExpression = void 0;
4
+ exports.createShortCircuitBinaryExpressionPrecedingStatements = createShortCircuitBinaryExpressionPrecedingStatements;
5
+ exports.transformBinaryOperation = transformBinaryOperation;
6
+ exports.transformBinaryExpressionStatement = transformBinaryExpressionStatement;
4
7
  const ts = require("typescript");
5
8
  const CompilerOptions_1 = require("../../../CompilerOptions");
6
9
  const lua = require("../../../LuaAST");
@@ -80,7 +83,6 @@ function createShortCircuitBinaryExpressionPrecedingStatements(context, lhs, rhs
80
83
  const ifStatement = lua.createIfStatement(condition, lua.createBlock([...rightPrecedingStatements, lua.createAssignmentStatement(conditionIdentifier, rhs)]), undefined, node === null || node === void 0 ? void 0 : node.left);
81
84
  return { precedingStatements: [assignmentStatement, ifStatement], result: conditionIdentifier };
82
85
  }
83
- exports.createShortCircuitBinaryExpressionPrecedingStatements = createShortCircuitBinaryExpressionPrecedingStatements;
84
86
  function transformShortCircuitBinaryExpression(context, node, operator) {
85
87
  const lhs = context.transformExpression(node.left);
86
88
  const { precedingStatements, result } = (0, preceding_statements_1.transformInPrecedingStatementScope)(context, () => context.transformExpression(node.right));
@@ -96,7 +98,6 @@ function transformBinaryOperation(context, left, right, rightPrecedingStatements
96
98
  result: transformBinaryOperationWithNoPrecedingStatements(context, left, right, operator, node),
97
99
  };
98
100
  }
99
- exports.transformBinaryOperation = transformBinaryOperation;
100
101
  const transformBinaryExpression = (node, context) => {
101
102
  const operator = node.operatorToken.kind;
102
103
  const typeOfResult = (0, typeof_1.transformTypeOfBinaryExpression)(context, node);
@@ -167,7 +168,6 @@ function transformBinaryExpressionStatement(context, node) {
167
168
  return lua.createDoStatement(statements, expression);
168
169
  }
169
170
  }
170
- exports.transformBinaryExpressionStatement = transformBinaryExpressionStatement;
171
171
  function transformNullishCoalescingOperationNoPrecedingStatements(context, node, transformedLeft, transformedRight) {
172
172
  const lhsType = context.checker.getTypeAtLocation(node.left);
173
173
  // Check if we can take a shortcut to 'lhs or rhs' if the left-hand side cannot be 'false'.
@@ -1,20 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformBlock = exports.transformScopeBlock = exports.transformBlockOrStatement = void 0;
3
+ exports.transformBlock = void 0;
4
+ exports.transformBlockOrStatement = transformBlockOrStatement;
5
+ exports.transformScopeBlock = transformScopeBlock;
4
6
  const ts = require("typescript");
5
7
  const lua = require("../../LuaAST");
6
8
  const scope_1 = require("../utils/scope");
7
9
  function transformBlockOrStatement(context, statement) {
8
10
  return context.transformStatements(ts.isBlock(statement) ? statement.statements : statement);
9
11
  }
10
- exports.transformBlockOrStatement = transformBlockOrStatement;
11
12
  function transformScopeBlock(context, node, scopeType) {
12
13
  context.pushScope(scopeType);
13
14
  const statements = (0, scope_1.performHoisting)(context, context.transformStatements(node.statements));
14
15
  const scope = context.popScope();
15
16
  return [lua.createBlock(statements, node), scope];
16
17
  }
17
- exports.transformScopeBlock = transformScopeBlock;
18
18
  const transformBlock = (node, context) => {
19
19
  context.pushScope(scope_1.ScopeType.Block);
20
20
  const statements = (0, scope_1.performHoisting)(context, context.transformStatements(node.statements));
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCalledExpression = exports.transformCallExpression = exports.transformContextualCallExpression = exports.transformCallAndArguments = exports.transformArguments = exports.validateArguments = void 0;
3
+ exports.transformCallExpression = void 0;
4
+ exports.validateArguments = validateArguments;
5
+ exports.transformArguments = transformArguments;
6
+ exports.transformCallAndArguments = transformCallAndArguments;
7
+ exports.transformContextualCallExpression = transformContextualCallExpression;
8
+ exports.getCalledExpression = getCalledExpression;
4
9
  const ts = require("typescript");
5
10
  const lua = require("../../LuaAST");
6
11
  const builtins_1 = require("../builtins");
@@ -31,12 +36,10 @@ function validateArguments(context, params, signature) {
31
36
  }
32
37
  }
33
38
  }
34
- exports.validateArguments = validateArguments;
35
39
  function transformArguments(context, params, signature, callContext) {
36
40
  validateArguments(context, params, signature);
37
41
  return (0, expression_list_1.transformExpressionList)(context, callContext ? [callContext, ...params] : params);
38
42
  }
39
- exports.transformArguments = transformArguments;
40
43
  function transformCallWithArguments(context, callExpression, transformedArguments, argPrecedingStatements, callContext) {
41
44
  let call = context.transformExpression(callExpression);
42
45
  let transformedContext;
@@ -59,7 +62,6 @@ function transformCallAndArguments(context, callExpression, params, signature, c
59
62
  const { precedingStatements: argPrecedingStatements, result: transformedArguments } = (0, preceding_statements_1.transformInPrecedingStatementScope)(context, () => transformArguments(context, params, signature, callContext));
60
63
  return transformCallWithArguments(context, callExpression, transformedArguments, argPrecedingStatements);
61
64
  }
62
- exports.transformCallAndArguments = transformCallAndArguments;
63
65
  function transformElementAccessCall(context, left, transformedArguments, argPrecedingStatements) {
64
66
  // Cache left-side if it has effects
65
67
  // local ____self = context; return ____self[argument](parameters);
@@ -118,7 +120,6 @@ function transformContextualCallExpression(context, node, args) {
118
120
  throw new Error(`Unsupported LeftHandSideExpression kind: ${ts.SyntaxKind[left.kind]}`);
119
121
  }
120
122
  }
121
- exports.transformContextualCallExpression = transformContextualCallExpression;
122
123
  function transformPropertyCall(context, node, calledMethod) {
123
124
  const signature = context.checker.getResolvedSignature(node);
124
125
  if (calledMethod.expression.kind === ts.SyntaxKind.SuperKeyword) {
@@ -203,5 +204,4 @@ exports.transformCallExpression = transformCallExpression;
203
204
  function getCalledExpression(node) {
204
205
  return ts.skipOuterExpressions(node.expression);
205
206
  }
206
- exports.getCalledExpression = getCalledExpression;
207
207
  //# sourceMappingURL=call.js.map
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createConstructorDecoratingExpression = exports.createClassPropertyDecoratingExpression = exports.createClassAccessorDecoratingExpression = exports.createClassMethodDecoratingExpression = exports.createClassDecoratingExpression = exports.transformDecoratorExpression = void 0;
3
+ exports.transformDecoratorExpression = transformDecoratorExpression;
4
+ exports.createClassDecoratingExpression = createClassDecoratingExpression;
5
+ exports.createClassMethodDecoratingExpression = createClassMethodDecoratingExpression;
6
+ exports.createClassAccessorDecoratingExpression = createClassAccessorDecoratingExpression;
7
+ exports.createClassPropertyDecoratingExpression = createClassPropertyDecoratingExpression;
8
+ exports.createConstructorDecoratingExpression = createConstructorDecoratingExpression;
4
9
  const ts = require("typescript");
5
10
  const lua = require("../../../LuaAST");
6
11
  const diagnostics_1 = require("../../utils/diagnostics");
@@ -19,7 +24,6 @@ function transformDecoratorExpression(context, decorator) {
19
24
  }
20
25
  return context.transformExpression(expression);
21
26
  }
22
- exports.transformDecoratorExpression = transformDecoratorExpression;
23
27
  function createClassDecoratingExpression(context, classDeclaration, className) {
24
28
  var _a, _b, _c, _d;
25
29
  const classDecorators = (_b = (_a = ts.getDecorators(classDeclaration)) === null || _a === void 0 ? void 0 : _a.map(d => transformDecoratorExpression(context, d))) !== null && _b !== void 0 ? _b : [];
@@ -33,7 +37,6 @@ function createClassDecoratingExpression(context, classDeclaration, className) {
33
37
  name: lua.createStringLiteral((_d = (_c = classDeclaration.name) === null || _c === void 0 ? void 0 : _c.getText()) !== null && _d !== void 0 ? _d : ""),
34
38
  });
35
39
  }
36
- exports.createClassDecoratingExpression = createClassDecoratingExpression;
37
40
  function createClassMethodDecoratingExpression(context, methodDeclaration, originalMethod, className) {
38
41
  var _a, _b;
39
42
  const parameterDecorators = getParameterDecorators(context, methodDeclaration);
@@ -52,7 +55,6 @@ function createClassMethodDecoratingExpression(context, methodDeclaration, origi
52
55
  static: lua.createBooleanLiteral((0, utils_2.isStaticNode)(methodDeclaration)),
53
56
  });
54
57
  }
55
- exports.createClassMethodDecoratingExpression = createClassMethodDecoratingExpression;
56
58
  function createClassAccessorDecoratingExpression(context, accessor, originalAccessor, className) {
57
59
  var _a, _b;
58
60
  const accessorDecorators = (_b = (_a = ts.getDecorators(accessor)) === null || _a === void 0 ? void 0 : _a.map(d => transformDecoratorExpression(context, d))) !== null && _b !== void 0 ? _b : [];
@@ -70,7 +72,6 @@ function createClassAccessorDecoratingExpression(context, accessor, originalAcce
70
72
  static: lua.createBooleanLiteral((0, utils_2.isStaticNode)(accessor)),
71
73
  });
72
74
  }
73
- exports.createClassAccessorDecoratingExpression = createClassAccessorDecoratingExpression;
74
75
  function createClassPropertyDecoratingExpression(context, property, className) {
75
76
  var _a;
76
77
  const decorators = (_a = ts.getDecorators(property)) !== null && _a !== void 0 ? _a : [];
@@ -98,7 +99,6 @@ function createClassPropertyDecoratingExpression(context, property, className) {
98
99
  static: lua.createBooleanLiteral((0, utils_2.isStaticNode)(property)),
99
100
  });
100
101
  }
101
- exports.createClassPropertyDecoratingExpression = createClassPropertyDecoratingExpression;
102
102
  function createDecoratingExpression(context, className, originalValue, decorators, decoratorContext) {
103
103
  const decoratorTable = lua.createTableExpression(decorators.map(d => lua.createTableFieldExpression(d)));
104
104
  const decoratorContextTable = objectToLuaTableLiteral(decoratorContext);
@@ -136,5 +136,4 @@ function createConstructorDecoratingExpression(context, node, className) {
136
136
  return lua.createExpressionStatement(decorateMethod);
137
137
  }
138
138
  }
139
- exports.createConstructorDecoratingExpression = createConstructorDecoratingExpression;
140
139
  //# sourceMappingURL=decorators.js.map
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformSuperExpression = exports.transformClassAsExpression = exports.transformThisExpression = exports.transformClassDeclaration = void 0;
3
+ exports.transformSuperExpression = exports.transformThisExpression = exports.transformClassDeclaration = void 0;
4
+ exports.transformClassAsExpression = transformClassAsExpression;
4
5
  const ts = require("typescript");
5
6
  const lua = require("../../../LuaAST");
6
7
  const export_1 = require("../../utils/export");
@@ -39,7 +40,6 @@ function transformClassAsExpression(expression, context) {
39
40
  context.addPrecedingStatements(statements);
40
41
  return name;
41
42
  }
42
- exports.transformClassAsExpression = transformClassAsExpression;
43
43
  function transformClassLikeDeclaration(classDeclaration, context, nameOverride) {
44
44
  var _a;
45
45
  let className;
@@ -115,7 +115,7 @@ function transformClassLikeDeclaration(classDeclaration, context, nameOverride)
115
115
  for (const member of classDeclaration.members) {
116
116
  if (ts.isAccessor(member)) {
117
117
  // Accessors
118
- const accessors = context.resolver.getAllAccessorDeclarations(member);
118
+ const accessors = getAllAccessorDeclarations(classDeclaration);
119
119
  if (accessors.firstAccessor !== member)
120
120
  continue;
121
121
  const accessorsResult = (0, accessors_1.transformAccessorDeclarations)(context, accessors, localClassName);
@@ -161,6 +161,17 @@ function transformClassLikeDeclaration(classDeclaration, context, nameOverride)
161
161
  context.classSuperInfos.pop();
162
162
  return { statements: result, name: className };
163
163
  }
164
+ function getAllAccessorDeclarations(classDeclaration) {
165
+ const getAccessor = classDeclaration.members.find(ts.isGetAccessor);
166
+ const setAccessor = classDeclaration.members.find(ts.isSetAccessor);
167
+ // Get the first of the two (that is not undefined)
168
+ const firstAccessor = getAccessor && (!setAccessor || getAccessor.pos < setAccessor.pos) ? getAccessor : setAccessor;
169
+ return {
170
+ firstAccessor,
171
+ setAccessor,
172
+ getAccessor,
173
+ };
174
+ }
164
175
  const transformSuperExpression = (expression, context) => {
165
176
  const superInfos = context.classSuperInfos;
166
177
  const superInfo = superInfos[superInfos.length - 1];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformAccessorDeclarations = void 0;
3
+ exports.transformAccessorDeclarations = transformAccessorDeclarations;
4
4
  const ts = require("typescript");
5
5
  const lua = require("../../../../LuaAST");
6
6
  const lua_ast_1 = require("../../../utils/lua-ast");
@@ -42,5 +42,4 @@ function transformAccessorDeclarations(context, { firstAccessor, getAccessor, se
42
42
  const call = (0, lualib_1.transformLuaLibFunction)(context, feature, undefined, ...parameters);
43
43
  return lua.createExpressionStatement(call);
44
44
  }
45
- exports.transformAccessorDeclarations = transformAccessorDeclarations;
46
45
  //# sourceMappingURL=accessors.js.map
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformConstructorDeclaration = exports.createConstructorName = exports.createPrototypeName = void 0;
3
+ exports.createPrototypeName = createPrototypeName;
4
+ exports.createConstructorName = createConstructorName;
5
+ exports.transformConstructorDeclaration = transformConstructorDeclaration;
4
6
  const ts = require("typescript");
5
7
  const lua = require("../../../../LuaAST");
6
8
  const lua_ast_1 = require("../../../utils/lua-ast");
@@ -11,11 +13,9 @@ const fields_1 = require("./fields");
11
13
  function createPrototypeName(className) {
12
14
  return lua.createTableIndexExpression(lua.cloneIdentifier(className), lua.createStringLiteral("prototype"));
13
15
  }
14
- exports.createPrototypeName = createPrototypeName;
15
16
  function createConstructorName(className) {
16
17
  return lua.createTableIndexExpression(createPrototypeName(className), lua.createStringLiteral("____constructor"));
17
18
  }
18
- exports.createConstructorName = createConstructorName;
19
19
  function transformConstructorDeclaration(context, statement, className, instanceFields, classDeclaration) {
20
20
  // Don't transform methods without body (overload declarations)
21
21
  if (!statement.body) {
@@ -61,5 +61,4 @@ function transformConstructorDeclaration(context, statement, className, instance
61
61
  context.popScope();
62
62
  return lua.createAssignmentStatement(createConstructorName(className), lua.createFunctionExpression(block, params, dotsLiteral, lua.NodeFlags.Declaration), constructorWasGenerated ? classDeclaration : statement);
63
63
  }
64
- exports.transformConstructorDeclaration = transformConstructorDeclaration;
65
64
  //# sourceMappingURL=constructor.js.map
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformStaticPropertyDeclaration = exports.transformClassInstanceFields = void 0;
3
+ exports.transformClassInstanceFields = transformClassInstanceFields;
4
+ exports.transformStaticPropertyDeclaration = transformStaticPropertyDeclaration;
4
5
  const lua = require("../../../../LuaAST");
5
6
  const lua_ast_1 = require("../../../utils/lua-ast");
6
7
  const preceding_statements_1 = require("../../../utils/preceding-statements");
@@ -22,7 +23,6 @@ function transformClassInstanceFields(context, instanceFields) {
22
23
  }
23
24
  return statements;
24
25
  }
25
- exports.transformClassInstanceFields = transformClassInstanceFields;
26
26
  function transformStaticPropertyDeclaration(context, field, className) {
27
27
  if (!field.initializer)
28
28
  return;
@@ -31,5 +31,4 @@ function transformStaticPropertyDeclaration(context, field, className) {
31
31
  const classField = lua.createTableIndexExpression(lua.cloneIdentifier(className), fieldName);
32
32
  return lua.createAssignmentStatement(classField, value);
33
33
  }
34
- exports.transformStaticPropertyDeclaration = transformStaticPropertyDeclaration;
35
34
  //# sourceMappingURL=fields.js.map
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformMethodDeclaration = exports.transformMethodName = exports.transformMemberExpressionOwnerName = void 0;
3
+ exports.transformMemberExpressionOwnerName = transformMemberExpressionOwnerName;
4
+ exports.transformMethodName = transformMethodName;
5
+ exports.transformMethodDeclaration = transformMethodDeclaration;
4
6
  const ts = require("typescript");
5
7
  const lua = require("../../../../LuaAST");
6
8
  const function_1 = require("../../function");
@@ -11,7 +13,6 @@ const decorators_1 = require("../decorators");
11
13
  function transformMemberExpressionOwnerName(node, className) {
12
14
  return (0, utils_1.isStaticNode)(node) ? lua.cloneIdentifier(className) : (0, constructor_1.createPrototypeName)(className);
13
15
  }
14
- exports.transformMemberExpressionOwnerName = transformMemberExpressionOwnerName;
15
16
  function transformMethodName(context, node) {
16
17
  const methodName = (0, literal_1.transformPropertyName)(context, node.name);
17
18
  if (lua.isStringLiteral(methodName) && methodName.value === "toString") {
@@ -19,7 +20,6 @@ function transformMethodName(context, node) {
19
20
  }
20
21
  return methodName;
21
22
  }
22
- exports.transformMethodName = transformMethodName;
23
23
  function transformMethodDeclaration(context, node, className) {
24
24
  var _a, _b;
25
25
  // Don't transform methods without body (overload declarations)
@@ -50,5 +50,4 @@ function transformMethodDeclaration(context, node, className) {
50
50
  ];
51
51
  }
52
52
  }
53
- exports.transformMethodDeclaration = transformMethodDeclaration;
54
53
  //# sourceMappingURL=method.js.map
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getReflectionClassName = exports.createClassSetup = void 0;
3
+ exports.createClassSetup = createClassSetup;
4
+ exports.getReflectionClassName = getReflectionClassName;
4
5
  const ts = require("typescript");
5
6
  const lua = require("../../../LuaAST");
6
7
  const utils_1 = require("../../../utils");
@@ -42,7 +43,6 @@ function createClassSetup(context, statement, className, localClassName, extends
42
43
  }
43
44
  return result;
44
45
  }
45
- exports.createClassSetup = createClassSetup;
46
46
  function getReflectionClassName(declaration, className) {
47
47
  if (declaration.name) {
48
48
  return lua.createStringLiteral(declaration.name.text);
@@ -58,5 +58,4 @@ function getReflectionClassName(declaration, className) {
58
58
  }
59
59
  return lua.createStringLiteral("");
60
60
  }
61
- exports.getReflectionClassName = getReflectionClassName;
62
61
  //# sourceMappingURL=setup.js.map
@@ -1,32 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getExtendedType = exports.getExtendedNode = exports.getExtendsClause = exports.isStaticNode = exports.isPrivateNode = void 0;
3
+ exports.isPrivateNode = isPrivateNode;
4
+ exports.isStaticNode = isStaticNode;
5
+ exports.getExtendsClause = getExtendsClause;
6
+ exports.getExtendedNode = getExtendedNode;
7
+ exports.getExtendedType = getExtendedType;
4
8
  const ts = require("typescript");
5
9
  function isPrivateNode(node) {
6
10
  var _a;
7
11
  return ((_a = node.modifiers) === null || _a === void 0 ? void 0 : _a.some(m => m.kind === ts.SyntaxKind.PrivateKeyword)) === true;
8
12
  }
9
- exports.isPrivateNode = isPrivateNode;
10
13
  function isStaticNode(node) {
11
14
  var _a;
12
15
  return ((_a = node.modifiers) === null || _a === void 0 ? void 0 : _a.some(m => m.kind === ts.SyntaxKind.StaticKeyword)) === true;
13
16
  }
14
- exports.isStaticNode = isStaticNode;
15
17
  function getExtendsClause(node) {
16
18
  var _a;
17
19
  return (_a = node.heritageClauses) === null || _a === void 0 ? void 0 : _a.find(clause => clause.token === ts.SyntaxKind.ExtendsKeyword);
18
20
  }
19
- exports.getExtendsClause = getExtendsClause;
20
21
  function getExtendedNode(node) {
21
22
  const extendsClause = getExtendsClause(node);
22
23
  if (!extendsClause)
23
24
  return;
24
25
  return extendsClause.types[0];
25
26
  }
26
- exports.getExtendedNode = getExtendedNode;
27
27
  function getExtendedType(context, node) {
28
28
  const extendedNode = getExtendedNode(node);
29
29
  return extendedNode && context.checker.getTypeAtLocation(extendedNode);
30
30
  }
31
- exports.getExtendedType = getExtendedType;
32
31
  //# sourceMappingURL=utils.js.map
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkOnlyTruthyCondition = exports.transformIfStatement = exports.transformConditionalExpression = void 0;
3
+ exports.transformConditionalExpression = void 0;
4
+ exports.transformIfStatement = transformIfStatement;
5
+ exports.checkOnlyTruthyCondition = checkOnlyTruthyCondition;
4
6
  const ts = require("typescript");
5
7
  const lua = require("../../LuaAST");
6
8
  const preceding_statements_1 = require("../utils/preceding-statements");
@@ -74,7 +76,6 @@ function transformIfStatement(statement, context) {
74
76
  }
75
77
  return lua.createIfStatement(condition, ifBlock);
76
78
  }
77
- exports.transformIfStatement = transformIfStatement;
78
79
  function checkOnlyTruthyCondition(condition, context) {
79
80
  if (context.options.strictNullChecks === false)
80
81
  return; // This check is not valid if everything could implicitly be nil
@@ -84,5 +85,4 @@ function checkOnlyTruthyCondition(condition, context) {
84
85
  context.diagnostics.push((0, diagnostics_1.truthyOnlyConditionalValue)(condition));
85
86
  }
86
87
  }
87
- exports.checkOnlyTruthyCondition = checkOnlyTruthyCondition;
88
88
  //# sourceMappingURL=conditional.js.map
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformEnumDeclaration = exports.tryGetConstEnumValue = void 0;
3
+ exports.transformEnumDeclaration = void 0;
4
+ exports.tryGetConstEnumValue = tryGetConstEnumValue;
4
5
  const ts = require("typescript");
5
6
  const lua = require("../../LuaAST");
6
7
  const annotations_1 = require("../utils/annotations");
@@ -18,7 +19,6 @@ function tryGetConstEnumValue(context, node) {
18
19
  return lua.createNumericLiteral(value, node);
19
20
  }
20
21
  }
21
- exports.tryGetConstEnumValue = tryGetConstEnumValue;
22
22
  const transformEnumDeclaration = (node, context) => {
23
23
  if (ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Const && !context.options.preserveConstEnums) {
24
24
  return undefined;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformOrderedExpressions = exports.transformExpressionList = exports.moveToPrecedingTemp = exports.shouldMoveToTemp = void 0;
3
+ exports.shouldMoveToTemp = shouldMoveToTemp;
4
+ exports.moveToPrecedingTemp = moveToPrecedingTemp;
5
+ exports.transformExpressionList = transformExpressionList;
6
+ exports.transformOrderedExpressions = transformOrderedExpressions;
4
7
  const assert = require("assert");
5
8
  const ts = require("typescript");
6
9
  const lua = require("../../LuaAST");
@@ -17,7 +20,6 @@ function shouldMoveToTemp(context, expression, tsOriginal) {
17
20
  (0, optional_chaining_1.isOptionalContinuation)(tsOriginal) ||
18
21
  tsOriginal.kind === ts.SyntaxKind.ThisKeyword)));
19
22
  }
20
- exports.shouldMoveToTemp = shouldMoveToTemp;
21
23
  // Cache an expression in a preceding statement and return the temp identifier
22
24
  function moveToPrecedingTemp(context, expression, tsOriginal) {
23
25
  if (!shouldMoveToTemp(context, expression, tsOriginal)) {
@@ -28,7 +30,6 @@ function moveToPrecedingTemp(context, expression, tsOriginal) {
28
30
  context.addPrecedingStatements(tempDeclaration);
29
31
  return lua.cloneIdentifier(tempIdentifier, tsOriginal);
30
32
  }
31
- exports.moveToPrecedingTemp = moveToPrecedingTemp;
32
33
  function transformExpressions(context, expressions) {
33
34
  const precedingStatements = [];
34
35
  const transformedExpressions = [];
@@ -113,11 +114,9 @@ function transformExpressionList(context, expressions) {
113
114
  return transformExpressionsUsingTemps(context, expressions, transformedExpressions, precedingStatements, lastPrecedingStatementsIndex);
114
115
  }
115
116
  }
116
- exports.transformExpressionList = transformExpressionList;
117
117
  // Transforms a series of expressions while maintaining execution order
118
118
  function transformOrderedExpressions(context, expressions) {
119
119
  const { transformedExpressions, precedingStatements, lastPrecedingStatementsIndex } = transformExpressions(context, expressions);
120
120
  return transformExpressionsUsingTemps(context, expressions, transformedExpressions, precedingStatements, lastPrecedingStatementsIndex);
121
121
  }
122
- exports.transformOrderedExpressions = transformOrderedExpressions;
123
122
  //# sourceMappingURL=expression-list.js.map
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.wrapInStatement = exports.transformExpressionStatement = void 0;
3
+ exports.transformExpressionStatement = void 0;
4
+ exports.wrapInStatement = wrapInStatement;
4
5
  const lua = require("../../LuaAST");
5
6
  const context_1 = require("../context");
6
7
  const binary_expression_1 = require("./binary-expression");
@@ -33,5 +34,4 @@ function wrapInStatement(result) {
33
34
  // Assign expression statements to dummy to make sure they're legal Lua
34
35
  return lua.createVariableDeclarationStatement(lua.createAnonymousIdentifier(), result);
35
36
  }
36
- exports.wrapInStatement = wrapInStatement;
37
37
  //# sourceMappingURL=expression-statement.js.map
@@ -1,6 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformYieldExpression = exports.transformFunctionDeclaration = exports.transformFunctionLikeDeclaration = exports.transformFunctionToExpression = exports.transformParameters = exports.transformFunctionBody = exports.transformFunctionBodyHeader = exports.transformFunctionBodyContent = exports.isFunctionTypeWithProperties = exports.createCallableTable = void 0;
3
+ exports.transformYieldExpression = exports.transformFunctionDeclaration = void 0;
4
+ exports.createCallableTable = createCallableTable;
5
+ exports.isFunctionTypeWithProperties = isFunctionTypeWithProperties;
6
+ exports.transformFunctionBodyContent = transformFunctionBodyContent;
7
+ exports.transformFunctionBodyHeader = transformFunctionBodyHeader;
8
+ exports.transformFunctionBody = transformFunctionBody;
9
+ exports.transformParameters = transformParameters;
10
+ exports.transformFunctionToExpression = transformFunctionToExpression;
11
+ exports.transformFunctionLikeDeclaration = transformFunctionLikeDeclaration;
4
12
  const ts = require("typescript");
5
13
  const CompilerOptions_1 = require("../../CompilerOptions");
6
14
  const lua = require("../../LuaAST");
@@ -58,7 +66,6 @@ function createCallableTable(functionExpression) {
58
66
  ]),
59
67
  ]);
60
68
  }
61
- exports.createCallableTable = createCallableTable;
62
69
  function isFunctionTypeWithProperties(context, functionType) {
63
70
  if (functionType.isUnion()) {
64
71
  return functionType.types.some(t => isFunctionTypeWithProperties(context, t));
@@ -70,7 +77,6 @@ function isFunctionTypeWithProperties(context, functionType) {
70
77
  );
71
78
  }
72
79
  }
73
- exports.isFunctionTypeWithProperties = isFunctionTypeWithProperties;
74
80
  function transformFunctionBodyContent(context, body) {
75
81
  if (!ts.isBlock(body)) {
76
82
  const { precedingStatements, result: returnStatement } = (0, preceding_statements_1.transformInPrecedingStatementScope)(context, () => (0, return_1.transformExpressionBodyToReturnStatement)(context, body));
@@ -79,7 +85,6 @@ function transformFunctionBodyContent(context, body) {
79
85
  const bodyStatements = (0, scope_1.performHoisting)(context, context.transformStatements(body.statements));
80
86
  return bodyStatements;
81
87
  }
82
- exports.transformFunctionBodyContent = transformFunctionBodyContent;
83
88
  function transformFunctionBodyHeader(context, bodyScope, parameters, spreadIdentifier) {
84
89
  const headerStatements = [];
85
90
  // Add default parameters and object binding patterns
@@ -115,7 +120,6 @@ function transformFunctionBodyHeader(context, bodyScope, parameters, spreadIdent
115
120
  headerStatements.push(...bindingPatternDeclarations);
116
121
  return headerStatements;
117
122
  }
118
- exports.transformFunctionBodyHeader = transformFunctionBodyHeader;
119
123
  function transformFunctionBody(context, parameters, body, spreadIdentifier, node) {
120
124
  const scope = context.pushScope(scope_1.ScopeType.Function);
121
125
  scope.node = node;
@@ -127,7 +131,6 @@ function transformFunctionBody(context, parameters, body, spreadIdentifier, node
127
131
  context.popScope();
128
132
  return [[...headerStatements, ...bodyStatements], scope];
129
133
  }
130
- exports.transformFunctionBody = transformFunctionBody;
131
134
  function transformParameters(context, parameters, functionContext) {
132
135
  // Build parameter string
133
136
  const paramNames = [];
@@ -159,7 +162,6 @@ function transformParameters(context, parameters, functionContext) {
159
162
  }
160
163
  return [paramNames, dotsLiteral, restParamName];
161
164
  }
162
- exports.transformParameters = transformParameters;
163
165
  function transformFunctionToExpression(context, node) {
164
166
  var _a;
165
167
  (0, utils_1.assert)(node.body);
@@ -198,7 +200,6 @@ function transformFunctionToExpression(context, node) {
198
200
  functionScope,
199
201
  ];
200
202
  }
201
- exports.transformFunctionToExpression = transformFunctionToExpression;
202
203
  function transformFunctionLikeDeclaration(node, context) {
203
204
  if (node.body === undefined) {
204
205
  // This code can be reached only from object methods, which is TypeScript error
@@ -232,7 +233,6 @@ function transformFunctionLikeDeclaration(node, context) {
232
233
  ? createCallableTable(functionExpression)
233
234
  : functionExpression;
234
235
  }
235
- exports.transformFunctionLikeDeclaration = transformFunctionLikeDeclaration;
236
236
  const transformFunctionDeclaration = (node, context) => {
237
237
  var _a;
238
238
  // Don't transform functions without body (overload declarations)
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformIdentifierExpression = exports.transformIdentifierWithSymbol = exports.getCustomNameFromSymbol = exports.transformIdentifier = void 0;
3
+ exports.transformIdentifierExpression = void 0;
4
+ exports.transformIdentifier = transformIdentifier;
5
+ exports.getCustomNameFromSymbol = getCustomNameFromSymbol;
6
+ exports.transformIdentifierWithSymbol = transformIdentifierWithSymbol;
4
7
  const ts = require("typescript");
5
8
  const lua = require("../../LuaAST");
6
9
  const builtins_1 = require("../builtins");
@@ -19,7 +22,6 @@ const annotations_1 = require("../utils/annotations");
19
22
  function transformIdentifier(context, identifier) {
20
23
  return transformNonValueIdentifier(context, identifier, context.checker.getSymbolAtLocation(identifier));
21
24
  }
22
- exports.transformIdentifier = transformIdentifier;
23
25
  function getCustomNameFromSymbol(symbol) {
24
26
  let retVal;
25
27
  if (symbol) {
@@ -41,7 +43,6 @@ function getCustomNameFromSymbol(symbol) {
41
43
  }
42
44
  return retVal;
43
45
  }
44
- exports.getCustomNameFromSymbol = getCustomNameFromSymbol;
45
46
  function transformNonValueIdentifier(context, identifier, symbol) {
46
47
  if ((0, optional_chaining_1.isOptionalContinuation)(identifier)) {
47
48
  const result = lua.createIdentifier(identifier.text, undefined, context_1.tempSymbolId);
@@ -95,7 +96,6 @@ function transformIdentifierWithSymbol(context, node, symbol) {
95
96
  }
96
97
  return transformNonValueIdentifier(context, node, symbol);
97
98
  }
98
- exports.transformIdentifierWithSymbol = transformIdentifierWithSymbol;
99
99
  const transformIdentifierExpression = (node, context) => {
100
100
  if (ts.identifierToKeywordKind(node) === ts.SyntaxKind.UndefinedKeyword) {
101
101
  return lua.createNilLiteral(node);
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transformLanguageExtensionCallExpression = exports.callExtensions = void 0;
3
+ exports.callExtensions = void 0;
4
+ exports.transformLanguageExtensionCallExpression = transformLanguageExtensionCallExpression;
4
5
  const language_extensions_1 = require("../../utils/language-extensions");
5
6
  const operators_1 = require("./operators");
6
7
  const table_1 = require("./table");
@@ -19,5 +20,4 @@ function transformLanguageExtensionCallExpression(context, node) {
19
20
  return transformer(context, node, extensionKind);
20
21
  }
21
22
  }
22
- exports.transformLanguageExtensionCallExpression = transformLanguageExtensionCallExpression;
23
23
  //# sourceMappingURL=call-extension.js.map