typescript-to-lua 1.0.0 → 1.2.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.
Files changed (185) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/CompilerOptions.d.ts +4 -3
  3. package/dist/LuaAST.d.ts +1 -0
  4. package/dist/LuaAST.js +14 -6
  5. package/dist/LuaLib.d.ts +4 -3
  6. package/dist/LuaLib.js +5 -4
  7. package/dist/LuaPrinter.d.ts +15 -4
  8. package/dist/LuaPrinter.js +79 -27
  9. package/dist/cli/diagnostics.js +2 -2
  10. package/dist/cli/parse.d.ts +1 -1
  11. package/dist/cli/parse.js +14 -0
  12. package/dist/cli/report.js +1 -1
  13. package/dist/cli/tsconfig.js +4 -4
  14. package/dist/lualib/ArrayFlat.lua +1 -1
  15. package/dist/lualib/ArrayFlatMap.lua +1 -1
  16. package/dist/lualib/ArrayIsArray.lua +1 -1
  17. package/dist/lualib/ArrayReduce.lua +7 -1
  18. package/dist/lualib/ArrayReduceRight.lua +7 -1
  19. package/dist/lualib/ArraySetLength.lua +1 -1
  20. package/dist/lualib/ArraySplice.lua +5 -5
  21. package/dist/lualib/Await.lua +39 -19
  22. package/dist/lualib/CloneDescriptor.lua +8 -8
  23. package/dist/lualib/Decorate.lua +1 -1
  24. package/dist/lualib/DelegatedYield.lua +1 -3
  25. package/dist/lualib/Delete.lua +6 -6
  26. package/dist/lualib/Error.lua +47 -44
  27. package/dist/lualib/Generator.lua +1 -5
  28. package/dist/lualib/InstanceOf.lua +1 -1
  29. package/dist/lualib/InstanceOfObject.lua +1 -1
  30. package/dist/lualib/Map.lua +130 -134
  31. package/dist/lualib/Number.lua +1 -1
  32. package/dist/lualib/NumberIsFinite.lua +1 -1
  33. package/dist/lualib/NumberToString.lua +3 -5
  34. package/dist/lualib/ObjectDefineProperty.lua +40 -8
  35. package/dist/lualib/ParseFloat.lua +9 -5
  36. package/dist/lualib/ParseInt.lua +15 -3
  37. package/dist/lualib/Promise.lua +36 -26
  38. package/dist/lualib/Set.lua +119 -123
  39. package/dist/lualib/SetDescriptor.lua +7 -1
  40. package/dist/lualib/SourceMapTraceBack.lua +19 -9
  41. package/dist/lualib/SparseArrayNew.lua +5 -0
  42. package/dist/lualib/SparseArrayPush.lua +9 -0
  43. package/dist/lualib/SparseArraySpread.lua +4 -0
  44. package/dist/lualib/StringAccess.lua +1 -1
  45. package/dist/lualib/StringCharCodeAt.lua +1 -1
  46. package/dist/lualib/StringEndsWith.lua +2 -2
  47. package/dist/lualib/StringPadEnd.lua +2 -2
  48. package/dist/lualib/StringPadStart.lua +2 -2
  49. package/dist/lualib/StringReplace.lua +12 -11
  50. package/dist/lualib/StringReplaceAll.lua +35 -0
  51. package/dist/lualib/StringSlice.lua +2 -2
  52. package/dist/lualib/StringSplit.lua +3 -3
  53. package/dist/lualib/StringStartsWith.lua +1 -1
  54. package/dist/lualib/StringSubstr.lua +1 -1
  55. package/dist/lualib/StringSubstring.lua +2 -2
  56. package/dist/lualib/Symbol.lua +3 -5
  57. package/dist/lualib/WeakMap.lua +40 -42
  58. package/dist/lualib/WeakSet.lua +36 -38
  59. package/dist/lualib/lualib_bundle.lua +705 -586
  60. package/dist/transformation/builtins/array.js +29 -30
  61. package/dist/transformation/builtins/console.js +2 -2
  62. package/dist/transformation/builtins/function.js +9 -10
  63. package/dist/transformation/builtins/global.js +8 -8
  64. package/dist/transformation/builtins/index.d.ts +1 -1
  65. package/dist/transformation/builtins/index.js +69 -36
  66. package/dist/transformation/builtins/math.js +4 -4
  67. package/dist/transformation/builtins/number.js +7 -7
  68. package/dist/transformation/builtins/object.d.ts +2 -1
  69. package/dist/transformation/builtins/object.js +12 -13
  70. package/dist/transformation/builtins/promise.js +9 -9
  71. package/dist/transformation/builtins/string.js +32 -31
  72. package/dist/transformation/builtins/symbol.js +3 -3
  73. package/dist/transformation/context/context.d.ts +12 -0
  74. package/dist/transformation/context/context.js +105 -6
  75. package/dist/transformation/index.js +1 -1
  76. package/dist/transformation/utils/annotations.d.ts +1 -3
  77. package/dist/transformation/utils/annotations.js +0 -2
  78. package/dist/transformation/utils/assignment-validation.js +8 -7
  79. package/dist/transformation/utils/diagnostics.d.ts +6 -0
  80. package/dist/transformation/utils/diagnostics.js +7 -5
  81. package/dist/transformation/utils/export.d.ts +3 -2
  82. package/dist/transformation/utils/export.js +14 -7
  83. package/dist/transformation/utils/function-context.js +8 -8
  84. package/dist/transformation/utils/lua-ast.d.ts +0 -1
  85. package/dist/transformation/utils/lua-ast.js +25 -35
  86. package/dist/transformation/utils/lualib.js +1 -1
  87. package/dist/transformation/utils/preceding-statements.d.ts +3 -0
  88. package/dist/transformation/utils/preceding-statements.js +11 -0
  89. package/dist/transformation/utils/safe-names.js +5 -5
  90. package/dist/transformation/utils/scope.d.ts +7 -0
  91. package/dist/transformation/utils/scope.js +77 -40
  92. package/dist/transformation/utils/symbols.js +6 -6
  93. package/dist/transformation/utils/typescript/index.d.ts +1 -0
  94. package/dist/transformation/utils/typescript/index.js +16 -1
  95. package/dist/transformation/utils/typescript/nodes.d.ts +2 -0
  96. package/dist/transformation/utils/typescript/nodes.js +21 -1
  97. package/dist/transformation/visitors/access.d.ts +3 -0
  98. package/dist/transformation/visitors/access.js +74 -47
  99. package/dist/transformation/visitors/async-await.js +5 -4
  100. package/dist/transformation/visitors/binary-expression/assignments.d.ts +3 -2
  101. package/dist/transformation/visitors/binary-expression/assignments.js +86 -77
  102. package/dist/transformation/visitors/binary-expression/bit.js +4 -4
  103. package/dist/transformation/visitors/binary-expression/compound.d.ts +5 -4
  104. package/dist/transformation/visitors/binary-expression/compound.js +69 -71
  105. package/dist/transformation/visitors/binary-expression/destructuring-assignments.d.ts +2 -2
  106. package/dist/transformation/visitors/binary-expression/destructuring-assignments.js +65 -36
  107. package/dist/transformation/visitors/binary-expression/index.d.ts +3 -1
  108. package/dist/transformation/visitors/binary-expression/index.js +84 -40
  109. package/dist/transformation/visitors/block.js +6 -6
  110. package/dist/transformation/visitors/break-continue.js +4 -9
  111. package/dist/transformation/visitors/call.d.ts +3 -2
  112. package/dist/transformation/visitors/call.js +130 -143
  113. package/dist/transformation/visitors/class/decorators.js +3 -3
  114. package/dist/transformation/visitors/class/index.js +43 -39
  115. package/dist/transformation/visitors/class/members/accessors.js +6 -6
  116. package/dist/transformation/visitors/class/members/constructor.js +7 -7
  117. package/dist/transformation/visitors/class/members/fields.js +6 -6
  118. package/dist/transformation/visitors/class/members/method.js +6 -6
  119. package/dist/transformation/visitors/class/new.js +14 -16
  120. package/dist/transformation/visitors/class/setup.js +11 -11
  121. package/dist/transformation/visitors/class/utils.js +2 -2
  122. package/dist/transformation/visitors/conditional.js +34 -20
  123. package/dist/transformation/visitors/delete.js +8 -4
  124. package/dist/transformation/visitors/enum.js +8 -8
  125. package/dist/transformation/visitors/errors.js +30 -30
  126. package/dist/transformation/visitors/expression-list.d.ts +7 -0
  127. package/dist/transformation/visitors/expression-list.js +120 -0
  128. package/dist/transformation/visitors/expression-statement.js +10 -6
  129. package/dist/transformation/visitors/function.js +30 -32
  130. package/dist/transformation/visitors/identifier.js +26 -22
  131. package/dist/transformation/visitors/index.js +2 -2
  132. package/dist/transformation/visitors/language-extensions/iterable.js +7 -7
  133. package/dist/transformation/visitors/language-extensions/multi.d.ts +1 -1
  134. package/dist/transformation/visitors/language-extensions/multi.js +3 -3
  135. package/dist/transformation/visitors/language-extensions/operators.js +6 -6
  136. package/dist/transformation/visitors/language-extensions/range.js +6 -6
  137. package/dist/transformation/visitors/language-extensions/table.js +5 -5
  138. package/dist/transformation/visitors/literal.d.ts +1 -2
  139. package/dist/transformation/visitors/literal.js +87 -57
  140. package/dist/transformation/visitors/loops/do-while.js +35 -9
  141. package/dist/transformation/visitors/loops/for-in.js +4 -4
  142. package/dist/transformation/visitors/loops/for-of.js +13 -13
  143. package/dist/transformation/visitors/loops/for.js +28 -8
  144. package/dist/transformation/visitors/loops/utils.d.ts +1 -0
  145. package/dist/transformation/visitors/loops/utils.js +21 -10
  146. package/dist/transformation/visitors/modules/export.js +14 -15
  147. package/dist/transformation/visitors/modules/import.js +10 -10
  148. package/dist/transformation/visitors/namespace.js +13 -13
  149. package/dist/transformation/visitors/optional-chaining.d.ts +16 -0
  150. package/dist/transformation/visitors/optional-chaining.js +172 -0
  151. package/dist/transformation/visitors/return.d.ts +1 -0
  152. package/dist/transformation/visitors/return.js +40 -26
  153. package/dist/transformation/visitors/sourceFile.js +12 -9
  154. package/dist/transformation/visitors/spread.js +11 -11
  155. package/dist/transformation/visitors/switch.js +152 -30
  156. package/dist/transformation/visitors/template.js +10 -7
  157. package/dist/transformation/visitors/typeof.js +4 -2
  158. package/dist/transformation/visitors/typescript.js +1 -1
  159. package/dist/transformation/visitors/unary-expression.js +9 -9
  160. package/dist/transformation/visitors/variable-declaration.js +46 -32
  161. package/dist/transformation/visitors/void.d.ts +6 -0
  162. package/dist/transformation/visitors/void.js +20 -0
  163. package/dist/transpilation/bundle.d.ts +3 -0
  164. package/dist/transpilation/bundle.js +56 -13
  165. package/dist/transpilation/diagnostics.js +3 -3
  166. package/dist/transpilation/index.js +2 -2
  167. package/dist/transpilation/output-collector.js +2 -2
  168. package/dist/transpilation/plugins.js +1 -1
  169. package/dist/transpilation/resolve.js +26 -14
  170. package/dist/transpilation/transformers.js +45 -25
  171. package/dist/transpilation/transpile.js +6 -6
  172. package/dist/transpilation/transpiler.js +8 -8
  173. package/dist/transpilation/utils.js +5 -3
  174. package/dist/tstl.js +8 -8
  175. package/dist/utils.js +2 -2
  176. package/package.json +15 -12
  177. package/dist/lualib/OptionalChainAccess.lua +0 -6
  178. package/dist/lualib/OptionalFunctionCall.lua +0 -6
  179. package/dist/lualib/OptionalMethodCall.lua +0 -11
  180. package/dist/transformation/utils/transform.d.ts +0 -8
  181. package/dist/transformation/utils/transform.js +0 -14
  182. package/dist/transformation/visitors/jsx/jsx.d.ts +0 -9
  183. package/dist/transformation/visitors/jsx/jsx.js +0 -237
  184. package/dist/transformation/visitors/jsx/xhtml.d.ts +0 -3
  185. package/dist/transformation/visitors/jsx/xhtml.js +0 -260
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.0
4
+
5
+ - Upgraded to TypeScript 4.5.x.
6
+ - Improved general output formatting.
7
+ - Added support for more complicated (nested) destructuring patterns, also fixing an exception they caused before.
8
+ - Fixed incorrect interactions between standard library functionality and optional chaining, e.g. `myArray?.forEach()`.
9
+ - Fixed rejected promises sometimes not getting the correct rejection reason.
10
+ - Fixed some `delete` behavior that was different in Lua compared to JS.
11
+ - Fixed a bug causing exported classes to lose their decorators.
12
+ - Fixed plugins checking for ts-node from the wrong location (tsconfig directory), plugins will now check for ts-node relative to the tstl directory.
13
+
14
+ Under the hood:
15
+
16
+ - We can now transform using preceding statements, allowing all kinds of optimizations and improvements to output Lua.
17
+ - Updated various language constructs to use preceding statements instead of inline immediately-invoked functions.
18
+
19
+ ## 1.1.0
20
+
21
+ - **[Breaking]** We now use TypeScript's JSX transformer instead of maintaining our own. As a result, `React.createElement` now requires a self parameter, so remove `@noSelf`, `this: void` if necessary.
22
+ - **[Breaking(-ish)]** Due to limitations in 5.1, try/catch can no longer be used in async or generator functions when targetting Lua 5.1. This was already broken but now tstl will explicitly give an error if you try.
23
+ - Added support for the `switch` statement in all versions! (Before they were not supported in 5.1 and universal).
24
+ - Added support for `string.prototype.replaceAll` and improved `string.prototype.replace` implementation.
25
+ - Added `noResolvePaths` tsconfig option to disable module resolution for environment-provided modules.
26
+ - Implemented support for void expressions, i.e `void(0)` or `void(ignoreThisReturnValue())`.
27
+ - Upgraded TypeScript to 4.4.4 and made it a peer dependency to hopefully avoid plugin issues due to mismatching TypeScript versions.
28
+ - The `$vararg` language extension can be used to access CLI arguments, now also in bundles.
29
+ - Fixed a bug regarding `baseUrl` and relative imports.
30
+ - Fixed `sourceMapTraceback: true` not working correctly for bundles.
31
+ - Fixed an issue regarding hoisting in switch case clauses.
32
+ - Added missing function context validation cases for object literals.
33
+ - Fixed a problem where awaiting rejected promises in try/catch would give the wrong result.
34
+ - Fixed an issue where chained `.then` calls on already-resolved or already-rejected promises would cause some callbacks to not fire while they should.
35
+ - Fixed source file paths in source maps being absolute, they are now relative again.
36
+
3
37
  ## 1.0.0
4
38
 
5
39
  - **[Breaking]** `/* @tupleReturn */` has been removed and will no longer have any effect. You will get an error if you try ot use it or if you use declarations that use it.
@@ -17,15 +17,16 @@ export interface LuaPluginImport {
17
17
  }
18
18
  export declare type CompilerOptions = OmitIndexSignature<ts.CompilerOptions> & {
19
19
  buildMode?: BuildMode;
20
- noImplicitSelf?: boolean;
21
- noHeader?: boolean;
22
20
  luaBundle?: string;
23
21
  luaBundleEntry?: string;
24
22
  luaTarget?: LuaTarget;
25
23
  luaLibImport?: LuaLibImportKind;
26
- sourceMapTraceback?: boolean;
27
24
  luaPlugins?: LuaPluginImport[];
25
+ noImplicitSelf?: boolean;
26
+ noHeader?: boolean;
27
+ noResolvePaths?: string[];
28
28
  plugins?: Array<ts.PluginImport | TransformerImport>;
29
+ sourceMapTraceback?: boolean;
29
30
  tstlVerbose?: boolean;
30
31
  [option: string]: any;
31
32
  };
package/dist/LuaAST.d.ts CHANGED
@@ -216,6 +216,7 @@ export interface StringLiteral extends Expression {
216
216
  }
217
217
  export declare function isStringLiteral(node: Node): node is StringLiteral;
218
218
  export declare function createStringLiteral(value: string, tsOriginal?: ts.Node): StringLiteral;
219
+ export declare function isLiteral(node: Node): node is NilLiteral | DotsLiteral | BooleanLiteral | NumericLiteral | StringLiteral;
219
220
  export declare enum FunctionExpressionFlags {
220
221
  None = 1,
221
222
  Inline = 2,
package/dist/LuaAST.js CHANGED
@@ -2,8 +2,8 @@
2
2
  // Simplified Lua AST based roughly on http://lua-users.org/wiki/MetaLuaAbstractSyntaxTree,
3
3
  // https://www.lua.org/manual/5.3/manual.html#9 and the TS AST implementation
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.createFunctionExpression = exports.isFunctionExpression = exports.FunctionExpressionFlags = exports.createStringLiteral = exports.isStringLiteral = exports.createNumericLiteral = exports.isNumericLiteral = exports.createDotsLiteral = exports.isDotsLiteral = exports.createBooleanLiteral = exports.isBooleanLiteral = exports.createNilLiteral = exports.isNilLiteral = exports.createExpressionStatement = exports.isExpressionStatement = exports.createBreakStatement = exports.isBreakStatement = exports.createReturnStatement = exports.isReturnStatement = exports.createLabelStatement = exports.isLabelStatement = exports.createGotoStatement = exports.isGotoStatement = exports.createForInStatement = exports.isForInStatement = exports.createForStatement = exports.isForStatement = exports.createRepeatStatement = exports.isRepeatStatement = exports.createWhileStatement = exports.isWhileStatement = exports.isIterationStatement = exports.createIfStatement = exports.isIfStatement = exports.createAssignmentStatement = exports.isAssignmentStatement = exports.createVariableDeclarationStatement = exports.isVariableDeclarationStatement = exports.createDoStatement = exports.isDoStatement = exports.createBlock = exports.isBlock = exports.createFile = exports.isFile = exports.getOriginalPos = exports.setNodeOriginal = exports.setNodePosition = exports.cloneNode = exports.createNode = exports.SyntaxKind = void 0;
6
- exports.isInlineFunctionExpression = exports.isFunctionDefinition = exports.isAssignmentLeftHandSideExpression = exports.createTableIndexExpression = exports.isTableIndexExpression = exports.createAnonymousIdentifier = exports.cloneIdentifier = exports.createIdentifier = exports.isIdentifier = exports.createMethodCallExpression = exports.isMethodCallExpression = exports.createCallExpression = exports.isCallExpression = exports.createBinaryExpression = exports.isBinaryExpression = exports.createUnaryExpression = exports.isUnaryExpression = exports.createTableExpression = exports.isTableExpression = exports.createTableFieldExpression = exports.isTableFieldExpression = void 0;
5
+ exports.isFunctionExpression = exports.FunctionExpressionFlags = exports.isLiteral = exports.createStringLiteral = exports.isStringLiteral = exports.createNumericLiteral = exports.isNumericLiteral = exports.createDotsLiteral = exports.isDotsLiteral = exports.createBooleanLiteral = exports.isBooleanLiteral = exports.createNilLiteral = exports.isNilLiteral = exports.createExpressionStatement = exports.isExpressionStatement = exports.createBreakStatement = exports.isBreakStatement = exports.createReturnStatement = exports.isReturnStatement = exports.createLabelStatement = exports.isLabelStatement = exports.createGotoStatement = exports.isGotoStatement = exports.createForInStatement = exports.isForInStatement = exports.createForStatement = exports.isForStatement = exports.createRepeatStatement = exports.isRepeatStatement = exports.createWhileStatement = exports.isWhileStatement = exports.isIterationStatement = exports.createIfStatement = exports.isIfStatement = exports.createAssignmentStatement = exports.isAssignmentStatement = exports.createVariableDeclarationStatement = exports.isVariableDeclarationStatement = exports.createDoStatement = exports.isDoStatement = exports.createBlock = exports.isBlock = exports.createFile = exports.isFile = exports.getOriginalPos = exports.setNodeOriginal = exports.setNodePosition = exports.cloneNode = exports.createNode = exports.SyntaxKind = void 0;
6
+ exports.isInlineFunctionExpression = exports.isFunctionDefinition = exports.isAssignmentLeftHandSideExpression = exports.createTableIndexExpression = exports.isTableIndexExpression = exports.createAnonymousIdentifier = exports.cloneIdentifier = exports.createIdentifier = exports.isIdentifier = exports.createMethodCallExpression = exports.isMethodCallExpression = exports.createCallExpression = exports.isCallExpression = exports.createBinaryExpression = exports.isBinaryExpression = exports.createUnaryExpression = exports.isUnaryExpression = exports.createTableExpression = exports.isTableExpression = exports.createTableFieldExpression = exports.isTableFieldExpression = exports.createFunctionExpression = void 0;
7
7
  // We can elide a lot of nodes especially tokens and keywords
8
8
  // because we don't create the AST from text
9
9
  const ts = require("typescript");
@@ -162,9 +162,9 @@ function isVariableDeclarationStatement(node) {
162
162
  exports.isVariableDeclarationStatement = isVariableDeclarationStatement;
163
163
  function createVariableDeclarationStatement(left, right, tsOriginal) {
164
164
  const statement = createNode(SyntaxKind.VariableDeclarationStatement, tsOriginal);
165
- statement.left = utils_1.castArray(left);
165
+ statement.left = (0, utils_1.castArray)(left);
166
166
  if (right)
167
- statement.right = utils_1.castArray(right);
167
+ statement.right = (0, utils_1.castArray)(right);
168
168
  return statement;
169
169
  }
170
170
  exports.createVariableDeclarationStatement = createVariableDeclarationStatement;
@@ -174,8 +174,8 @@ function isAssignmentStatement(node) {
174
174
  exports.isAssignmentStatement = isAssignmentStatement;
175
175
  function createAssignmentStatement(left, right, tsOriginal) {
176
176
  const statement = createNode(SyntaxKind.AssignmentStatement, tsOriginal);
177
- statement.left = utils_1.castArray(left);
178
- statement.right = right ? utils_1.castArray(right) : [];
177
+ statement.left = (0, utils_1.castArray)(left);
178
+ statement.right = right ? (0, utils_1.castArray)(right) : [];
179
179
  return statement;
180
180
  }
181
181
  exports.createAssignmentStatement = createAssignmentStatement;
@@ -338,6 +338,14 @@ function createStringLiteral(value, tsOriginal) {
338
338
  return expression;
339
339
  }
340
340
  exports.createStringLiteral = createStringLiteral;
341
+ function isLiteral(node) {
342
+ return (isNilLiteral(node) ||
343
+ isDotsLiteral(node) ||
344
+ isBooleanLiteral(node) ||
345
+ isNumericLiteral(node) ||
346
+ isStringLiteral(node));
347
+ }
348
+ exports.isLiteral = isLiteral;
341
349
  var FunctionExpressionFlags;
342
350
  (function (FunctionExpressionFlags) {
343
351
  FunctionExpressionFlags[FunctionExpressionFlags["None"] = 1] = "None";
package/dist/LuaLib.d.ts CHANGED
@@ -56,9 +56,6 @@ export declare enum LuaLibFeature {
56
56
  ObjectKeys = "ObjectKeys",
57
57
  ObjectRest = "ObjectRest",
58
58
  ObjectValues = "ObjectValues",
59
- OptionalChainAccess = "OptionalChainAccess",
60
- OptionalFunctionCall = "OptionalFunctionCall",
61
- OptionalMethodCall = "OptionalMethodCall",
62
59
  ParseFloat = "ParseFloat",
63
60
  ParseInt = "ParseInt",
64
61
  Promise = "Promise",
@@ -68,6 +65,9 @@ export declare enum LuaLibFeature {
68
65
  PromiseRace = "PromiseRace",
69
66
  Set = "Set",
70
67
  SetDescriptor = "SetDescriptor",
68
+ SparseArrayNew = "SparseArrayNew",
69
+ SparseArrayPush = "SparseArrayPush",
70
+ SparseArraySpread = "SparseArraySpread",
71
71
  WeakMap = "WeakMap",
72
72
  WeakSet = "WeakSet",
73
73
  SourceMapTraceBack = "SourceMapTraceBack",
@@ -81,6 +81,7 @@ export declare enum LuaLibFeature {
81
81
  StringPadEnd = "StringPadEnd",
82
82
  StringPadStart = "StringPadStart",
83
83
  StringReplace = "StringReplace",
84
+ StringReplaceAll = "StringReplaceAll",
84
85
  StringSlice = "StringSlice",
85
86
  StringSplit = "StringSplit",
86
87
  StringStartsWith = "StringStartsWith",
package/dist/LuaLib.js CHANGED
@@ -60,9 +60,6 @@ var LuaLibFeature;
60
60
  LuaLibFeature["ObjectKeys"] = "ObjectKeys";
61
61
  LuaLibFeature["ObjectRest"] = "ObjectRest";
62
62
  LuaLibFeature["ObjectValues"] = "ObjectValues";
63
- LuaLibFeature["OptionalChainAccess"] = "OptionalChainAccess";
64
- LuaLibFeature["OptionalFunctionCall"] = "OptionalFunctionCall";
65
- LuaLibFeature["OptionalMethodCall"] = "OptionalMethodCall";
66
63
  LuaLibFeature["ParseFloat"] = "ParseFloat";
67
64
  LuaLibFeature["ParseInt"] = "ParseInt";
68
65
  LuaLibFeature["Promise"] = "Promise";
@@ -72,6 +69,9 @@ var LuaLibFeature;
72
69
  LuaLibFeature["PromiseRace"] = "PromiseRace";
73
70
  LuaLibFeature["Set"] = "Set";
74
71
  LuaLibFeature["SetDescriptor"] = "SetDescriptor";
72
+ LuaLibFeature["SparseArrayNew"] = "SparseArrayNew";
73
+ LuaLibFeature["SparseArrayPush"] = "SparseArrayPush";
74
+ LuaLibFeature["SparseArraySpread"] = "SparseArraySpread";
75
75
  LuaLibFeature["WeakMap"] = "WeakMap";
76
76
  LuaLibFeature["WeakSet"] = "WeakSet";
77
77
  LuaLibFeature["SourceMapTraceBack"] = "SourceMapTraceBack";
@@ -85,6 +85,7 @@ var LuaLibFeature;
85
85
  LuaLibFeature["StringPadEnd"] = "StringPadEnd";
86
86
  LuaLibFeature["StringPadStart"] = "StringPadStart";
87
87
  LuaLibFeature["StringReplace"] = "StringReplace";
88
+ LuaLibFeature["StringReplaceAll"] = "StringReplaceAll";
88
89
  LuaLibFeature["StringSlice"] = "StringSlice";
89
90
  LuaLibFeature["StringSplit"] = "StringSplit";
90
91
  LuaLibFeature["StringStartsWith"] = "StringStartsWith";
@@ -106,7 +107,7 @@ const luaLibDependencies = {
106
107
  Await: [LuaLibFeature.InstanceOf, LuaLibFeature.New],
107
108
  Decorate: [LuaLibFeature.ObjectGetOwnPropertyDescriptor, LuaLibFeature.SetDescriptor, LuaLibFeature.ObjectAssign],
108
109
  DelegatedYield: [LuaLibFeature.StringAccess],
109
- Delete: [LuaLibFeature.ObjectGetOwnPropertyDescriptors],
110
+ Delete: [LuaLibFeature.ObjectGetOwnPropertyDescriptors, LuaLibFeature.Error, LuaLibFeature.New],
110
111
  Error: [LuaLibFeature.Class, LuaLibFeature.ClassExtends, LuaLibFeature.New],
111
112
  FunctionBind: [LuaLibFeature.Unpack],
112
113
  Generator: [LuaLibFeature.Symbol],
@@ -1,5 +1,6 @@
1
1
  import { SourceNode } from "source-map";
2
2
  import * as ts from "typescript";
3
+ import { CompilerOptions } from "./CompilerOptions";
3
4
  import * as lua from "./LuaAST";
4
5
  import { EmitHost } from "./transpilation";
5
6
  export declare const escapeString: (value: string) => string;
@@ -14,15 +15,21 @@ export interface PrintResult {
14
15
  export declare function createPrinter(printers: Printer[]): Printer;
15
16
  export declare class LuaPrinter {
16
17
  private emitHost;
18
+ private program;
19
+ private sourceFile;
17
20
  private static operatorMap;
21
+ private static operatorPrecedence;
22
+ private static rightAssociativeOperators;
18
23
  private currentIndent;
19
- private sourceFile;
20
- private options;
21
- constructor(emitHost: EmitHost, program: ts.Program, fileName: string);
24
+ protected luaFile: string;
25
+ protected relativeSourcePath: string;
26
+ protected options: CompilerOptions;
27
+ static readonly sourceMapTracebackPlaceholder = "{#SourceMapTraceback}";
28
+ constructor(emitHost: EmitHost, program: ts.Program, sourceFile: string);
22
29
  print(file: lua.File): PrintResult;
23
30
  private printInlineSourceMap;
24
31
  private printStackTraceOverride;
25
- private printFile;
32
+ protected printFile(file: lua.File): SourceNode;
26
33
  protected pushIndent(): void;
27
34
  protected popIndent(): void;
28
35
  protected indent(input?: SourceChunk): SourceChunk;
@@ -69,6 +76,10 @@ export declare class LuaPrinter {
69
76
  printTableIndexExpression(expression: lua.TableIndexExpression): SourceNode;
70
77
  printOperator(kind: lua.Operator): SourceNode;
71
78
  protected joinChunksWithComma(chunks: SourceChunk[]): SourceChunk[];
79
+ /**
80
+ * Returns true if the expression list (table field or parameters) should be printed on one line.
81
+ */
82
+ protected isSimpleExpressionList(expressions: lua.Expression[]): boolean;
72
83
  protected printExpressionList(expressions: lua.Expression[]): SourceChunk[];
73
84
  private buildSourceMap;
74
85
  }
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LuaPrinter = exports.createPrinter = exports.tstlHeader = exports.escapeString = void 0;
4
+ const path = require("path");
4
5
  const source_map_1 = require("source-map");
6
+ const _1 = require(".");
5
7
  const CompilerOptions_1 = require("./CompilerOptions");
6
8
  const lua = require("./LuaAST");
7
9
  const LuaLib_1 = require("./LuaLib");
@@ -71,11 +73,15 @@ function createPrinter(printers) {
71
73
  }
72
74
  exports.createPrinter = createPrinter;
73
75
  class LuaPrinter {
74
- constructor(emitHost, program, fileName) {
76
+ constructor(emitHost, program, sourceFile) {
75
77
  this.emitHost = emitHost;
78
+ this.program = program;
79
+ this.sourceFile = sourceFile;
76
80
  this.currentIndent = "";
77
81
  this.options = program.getCompilerOptions();
78
- this.sourceFile = fileName;
82
+ this.luaFile = (0, utils_1.normalizeSlashes)((0, _1.getEmitPath)(this.sourceFile, this.program));
83
+ // Source nodes contain relative path from mapped lua file to original TS source file
84
+ this.relativeSourcePath = (0, utils_1.normalizeSlashes)(path.relative(path.dirname(this.luaFile), this.sourceFile));
79
85
  }
80
86
  print(file) {
81
87
  // Add traceback lualib if sourcemap traceback option is enabled
@@ -94,7 +100,7 @@ class LuaPrinter {
94
100
  }
95
101
  if (this.options.sourceMapTraceback) {
96
102
  const stackTraceOverride = this.printStackTraceOverride(rootSourceNode);
97
- code = code.replace("{#SourceMapTraceback}", stackTraceOverride);
103
+ code = code.replace(LuaPrinter.sourceMapTracebackPlaceholder, stackTraceOverride);
98
104
  }
99
105
  return { code, sourceMap: sourceMap.toString(), sourceMapNode: rootSourceNode };
100
106
  }
@@ -136,10 +142,12 @@ class LuaPrinter {
136
142
  else if (luaLibImport === CompilerOptions_1.LuaLibImportKind.Inline && file.luaLibFeatures.size > 0) {
137
143
  // Inline lualib features
138
144
  header += "-- Lua Library inline imports\n";
139
- header += LuaLib_1.loadLuaLibFeatures(file.luaLibFeatures, this.emitHost);
145
+ header += (0, LuaLib_1.loadLuaLibFeatures)(file.luaLibFeatures, this.emitHost);
140
146
  }
141
- if (this.options.sourceMapTraceback) {
142
- header += "{#SourceMapTraceback}\n";
147
+ if (this.options.sourceMapTraceback && !(0, CompilerOptions_1.isBundleEnabled)(this.options)) {
148
+ // In bundle mode the traceback is being generated for the entire file in getBundleResult
149
+ // Otherwise, traceback is being generated locally
150
+ header += `${LuaPrinter.sourceMapTracebackPlaceholder}\n`;
143
151
  }
144
152
  return this.concatNodes(header, ...this.printStatementArray(file.statements));
145
153
  }
@@ -155,11 +163,11 @@ class LuaPrinter {
155
163
  createSourceNode(node, chunks, name) {
156
164
  const { line, column } = lua.getOriginalPos(node);
157
165
  return line !== undefined && column !== undefined
158
- ? new source_map_1.SourceNode(line + 1, column, this.sourceFile, chunks, name)
159
- : new source_map_1.SourceNode(null, null, this.sourceFile, chunks, name);
166
+ ? new source_map_1.SourceNode(line + 1, column, this.relativeSourcePath, chunks, name)
167
+ : new source_map_1.SourceNode(null, null, this.relativeSourcePath, chunks, name);
160
168
  }
161
169
  concatNodes(...chunks) {
162
- return new source_map_1.SourceNode(null, null, this.sourceFile, chunks);
170
+ return new source_map_1.SourceNode(null, null, this.relativeSourcePath, chunks);
163
171
  }
164
172
  printBlock(block) {
165
173
  return this.concatNodes(...this.printStatementArray(block.statements));
@@ -195,7 +203,7 @@ class LuaPrinter {
195
203
  if (lua.isReturnStatement(statement))
196
204
  break;
197
205
  }
198
- return statementNodes.length > 0 ? [...utils_1.intersperse(statementNodes, "\n"), "\n"] : [];
206
+ return statementNodes.length > 0 ? [...(0, utils_1.intersperse)(statementNodes, "\n"), "\n"] : [];
199
207
  }
200
208
  printStatement(statement) {
201
209
  let resultNode = this.printStatementExcludingComments(statement);
@@ -422,7 +430,7 @@ class LuaPrinter {
422
430
  }
423
431
  }
424
432
  printStringLiteral(expression) {
425
- return this.createSourceNode(expression, exports.escapeString(expression.value));
433
+ return this.createSourceNode(expression, (0, exports.escapeString)(expression.value));
426
434
  }
427
435
  printNumericLiteral(expression) {
428
436
  return this.createSourceNode(expression, String(expression.value));
@@ -486,7 +494,7 @@ class LuaPrinter {
486
494
  const chunks = [];
487
495
  const value = this.printExpression(expression.value);
488
496
  if (expression.key) {
489
- if (lua.isStringLiteral(expression.key) && safe_names_1.isValidLuaIdentifier(expression.key.value)) {
497
+ if (lua.isStringLiteral(expression.key) && (0, safe_names_1.isValidLuaIdentifier)(expression.key.value)) {
490
498
  chunks.push(expression.key.value, " = ", value);
491
499
  }
492
500
  else {
@@ -504,26 +512,31 @@ class LuaPrinter {
504
512
  printUnaryExpression(expression) {
505
513
  const chunks = [];
506
514
  chunks.push(this.printOperator(expression.operator));
507
- chunks.push(this.printExpressionInParenthesesIfNeeded(expression.operand));
515
+ chunks.push(this.printExpressionInParenthesesIfNeeded(expression.operand, LuaPrinter.operatorPrecedence[expression.operator]));
508
516
  return this.createSourceNode(expression, chunks);
509
517
  }
510
518
  printBinaryExpression(expression) {
511
519
  const chunks = [];
512
- chunks.push(this.printExpressionInParenthesesIfNeeded(expression.left));
520
+ const isRightAssociative = LuaPrinter.rightAssociativeOperators.has(expression.operator);
521
+ const precedence = LuaPrinter.operatorPrecedence[expression.operator];
522
+ chunks.push(this.printExpressionInParenthesesIfNeeded(expression.left, isRightAssociative ? precedence + 1 : precedence));
513
523
  chunks.push(" ", this.printOperator(expression.operator), " ");
514
- chunks.push(this.printExpressionInParenthesesIfNeeded(expression.right));
524
+ chunks.push(this.printExpressionInParenthesesIfNeeded(expression.right, isRightAssociative ? precedence : precedence + 1));
515
525
  return this.createSourceNode(expression, chunks);
516
526
  }
517
- printExpressionInParenthesesIfNeeded(expression) {
518
- return this.needsParenthesis(expression)
527
+ printExpressionInParenthesesIfNeeded(expression, minPrecedenceToOmit) {
528
+ return this.needsParenthesis(expression, minPrecedenceToOmit)
519
529
  ? this.createSourceNode(expression, ["(", this.printExpression(expression), ")"])
520
530
  : this.printExpression(expression);
521
531
  }
522
- needsParenthesis(expression) {
523
- return (lua.isBinaryExpression(expression) ||
524
- lua.isFunctionExpression(expression) ||
525
- lua.isTableExpression(expression) ||
526
- (lua.isUnaryExpression(expression) && expression.operator === lua.SyntaxKind.NotOperator));
532
+ needsParenthesis(expression, minPrecedenceToOmit) {
533
+ if (lua.isBinaryExpression(expression) || lua.isUnaryExpression(expression)) {
534
+ return (minPrecedenceToOmit === undefined ||
535
+ LuaPrinter.operatorPrecedence[expression.operator] < minPrecedenceToOmit);
536
+ }
537
+ else {
538
+ return lua.isFunctionExpression(expression) || lua.isTableExpression(expression);
539
+ }
527
540
  }
528
541
  printCallExpression(expression) {
529
542
  const chunks = [];
@@ -553,7 +566,7 @@ class LuaPrinter {
553
566
  printTableIndexExpression(expression) {
554
567
  const chunks = [];
555
568
  chunks.push(this.printExpressionInParenthesesIfNeeded(expression.table));
556
- if (lua.isStringLiteral(expression.index) && safe_names_1.isValidLuaIdentifier(expression.index.value)) {
569
+ if (lua.isStringLiteral(expression.index) && (0, safe_names_1.isValidLuaIdentifier)(expression.index.value)) {
557
570
  chunks.push(".", this.createSourceNode(expression.index, expression.index.value));
558
571
  }
559
572
  else {
@@ -562,14 +575,24 @@ class LuaPrinter {
562
575
  return this.createSourceNode(expression, chunks);
563
576
  }
564
577
  printOperator(kind) {
565
- return new source_map_1.SourceNode(null, null, this.sourceFile, LuaPrinter.operatorMap[kind]);
578
+ return new source_map_1.SourceNode(null, null, this.relativeSourcePath, LuaPrinter.operatorMap[kind]);
566
579
  }
567
580
  joinChunksWithComma(chunks) {
568
- return utils_1.intersperse(chunks, ", ");
581
+ return (0, utils_1.intersperse)(chunks, ", ");
582
+ }
583
+ /**
584
+ * Returns true if the expression list (table field or parameters) should be printed on one line.
585
+ */
586
+ isSimpleExpressionList(expressions) {
587
+ if (expressions.length <= 1)
588
+ return true;
589
+ if (expressions.length > 4)
590
+ return false;
591
+ return expressions.every(isSimpleExpression);
569
592
  }
570
593
  printExpressionList(expressions) {
571
594
  const chunks = [];
572
- if (expressions.every(isSimpleExpression)) {
595
+ if (this.isSimpleExpressionList(expressions)) {
573
596
  chunks.push(...this.joinChunksWithComma(expressions.map(e => this.printExpression(e))));
574
597
  }
575
598
  else {
@@ -588,7 +611,7 @@ class LuaPrinter {
588
611
  // will not generate 'empty' mappings in the source map that point to nothing in the original TS.
589
612
  buildSourceMap(sourceRoot, rootSourceNode) {
590
613
  const map = new source_map_1.SourceMapGenerator({
591
- file: utils_1.trimExtension(this.sourceFile) + ".lua",
614
+ file: path.basename(this.luaFile),
592
615
  sourceRoot,
593
616
  });
594
617
  let generatedLine = 1;
@@ -667,4 +690,33 @@ LuaPrinter.operatorMap = {
667
690
  [lua.SyntaxKind.BitwiseLeftShiftOperator]: "<<",
668
691
  [lua.SyntaxKind.BitwiseNotOperator]: "~",
669
692
  };
693
+ LuaPrinter.operatorPrecedence = {
694
+ [lua.SyntaxKind.OrOperator]: 1,
695
+ [lua.SyntaxKind.AndOperator]: 2,
696
+ [lua.SyntaxKind.EqualityOperator]: 3,
697
+ [lua.SyntaxKind.InequalityOperator]: 3,
698
+ [lua.SyntaxKind.LessThanOperator]: 3,
699
+ [lua.SyntaxKind.LessEqualOperator]: 3,
700
+ [lua.SyntaxKind.GreaterThanOperator]: 3,
701
+ [lua.SyntaxKind.GreaterEqualOperator]: 3,
702
+ [lua.SyntaxKind.BitwiseOrOperator]: 4,
703
+ [lua.SyntaxKind.BitwiseExclusiveOrOperator]: 5,
704
+ [lua.SyntaxKind.BitwiseAndOperator]: 6,
705
+ [lua.SyntaxKind.BitwiseLeftShiftOperator]: 7,
706
+ [lua.SyntaxKind.BitwiseRightShiftOperator]: 7,
707
+ [lua.SyntaxKind.ConcatOperator]: 8,
708
+ [lua.SyntaxKind.AdditionOperator]: 9,
709
+ [lua.SyntaxKind.SubtractionOperator]: 9,
710
+ [lua.SyntaxKind.MultiplicationOperator]: 10,
711
+ [lua.SyntaxKind.DivisionOperator]: 10,
712
+ [lua.SyntaxKind.FloorDivisionOperator]: 10,
713
+ [lua.SyntaxKind.ModuloOperator]: 10,
714
+ [lua.SyntaxKind.NotOperator]: 11,
715
+ [lua.SyntaxKind.LengthOperator]: 11,
716
+ [lua.SyntaxKind.NegationOperator]: 11,
717
+ [lua.SyntaxKind.BitwiseNotOperator]: 11,
718
+ [lua.SyntaxKind.PowerOperator]: 12,
719
+ };
720
+ LuaPrinter.rightAssociativeOperators = new Set([lua.SyntaxKind.ConcatOperator, lua.SyntaxKind.PowerOperator]);
721
+ LuaPrinter.sourceMapTracebackPlaceholder = "{#SourceMapTraceback}";
670
722
  //# sourceMappingURL=LuaPrinter.js.map
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.optionBuildMustBeFirstCommandLineArgument = exports.optionCanOnlyBeSpecifiedInTsconfigJsonFile = exports.argumentForOptionMustBe = exports.compilerOptionExpectsAnArgument = exports.theSpecifiedPathDoesNotExist = exports.cannotFindATsconfigJsonAtTheSpecifiedDirectory = exports.optionProjectCannotBeMixedWithSourceFilesOnACommandLine = exports.compilerOptionRequiresAValueOfType = exports.unknownCompilerOption = exports.watchErrorSummary = exports.tstlOptionsAreMovingToTheTstlObject = void 0;
4
4
  const ts = require("typescript");
5
5
  const utils_1 = require("../utils");
6
- exports.tstlOptionsAreMovingToTheTstlObject = utils_1.createSerialDiagnosticFactory((tstl) => ({
6
+ exports.tstlOptionsAreMovingToTheTstlObject = (0, utils_1.createSerialDiagnosticFactory)((tstl) => ({
7
7
  category: ts.DiagnosticCategory.Warning,
8
8
  messageText: 'TSTL options are moving to the "tstl" object. Adjust your tsconfig to look like\n' +
9
9
  `"tstl": ${JSON.stringify(tstl, undefined, 4)}`,
@@ -19,7 +19,7 @@ const watchErrorSummary = (errorCount) => ({
19
19
  : `Found ${errorCount} errors. Watching for file changes.`,
20
20
  });
21
21
  exports.watchErrorSummary = watchErrorSummary;
22
- const createCommandLineError = (code, getMessage) => utils_1.createDiagnosticFactoryWithCode(code, (...args) => ({ messageText: getMessage(...args) }));
22
+ const createCommandLineError = (code, getMessage) => (0, utils_1.createDiagnosticFactoryWithCode)(code, (...args) => ({ messageText: getMessage(...args) }));
23
23
  exports.unknownCompilerOption = createCommandLineError(5023, (name) => `Unknown compiler option '${name}'.`);
24
24
  exports.compilerOptionRequiresAValueOfType = createCommandLineError(5024, (name, type) => `Compiler option '${name}' requires a value of type ${type}.`);
25
25
  exports.optionProjectCannotBeMixedWithSourceFilesOnACommandLine = createCommandLineError(5042, () => "Option 'project' cannot be mixed with source files on a command line.");
@@ -13,7 +13,7 @@ interface CommandLineOptionOfEnum extends CommandLineOptionBase {
13
13
  choices: string[];
14
14
  }
15
15
  interface CommandLineOptionOfPrimitive extends CommandLineOptionBase {
16
- type: "boolean" | "string" | "object";
16
+ type: "boolean" | "string" | "object" | "array";
17
17
  }
18
18
  declare type CommandLineOption = CommandLineOptionOfEnum | CommandLineOptionOfPrimitive;
19
19
  export declare const optionDeclarations: CommandLineOption[];
package/dist/cli/parse.js CHANGED
@@ -59,6 +59,11 @@ exports.optionDeclarations = [
59
59
  description: "Provide verbose output useful for diagnosing problems.",
60
60
  type: "boolean",
61
61
  },
62
+ {
63
+ name: "noResolvePaths",
64
+ description: "An array of paths that tstl should not resolve and keep as-is.",
65
+ type: "array",
66
+ },
62
67
  ];
63
68
  function updateParsedConfigFile(parsedConfigFile) {
64
69
  let hasRootLevelOptions = false;
@@ -162,6 +167,15 @@ function readValue(option, value) {
162
167
  }
163
168
  return { value };
164
169
  }
170
+ case "array": {
171
+ if (!Array.isArray(value)) {
172
+ return {
173
+ value: undefined,
174
+ error: cliDiagnostics.compilerOptionRequiresAValueOfType(option.name, option.type),
175
+ };
176
+ }
177
+ return { value };
178
+ }
165
179
  case "enum": {
166
180
  if (typeof value !== "string") {
167
181
  return {
@@ -6,7 +6,7 @@ const prepareDiagnosticForFormatting = (diagnostic) => diagnostic.source === "ty
6
6
  exports.prepareDiagnosticForFormatting = prepareDiagnosticForFormatting;
7
7
  function createDiagnosticReporter(pretty, system = ts.sys) {
8
8
  const reporter = ts.createDiagnosticReporter(system, pretty);
9
- return diagnostic => reporter(exports.prepareDiagnosticForFormatting(diagnostic));
9
+ return diagnostic => reporter((0, exports.prepareDiagnosticForFormatting)(diagnostic));
10
10
  }
11
11
  exports.createDiagnosticReporter = createDiagnosticReporter;
12
12
  //# sourceMappingURL=report.js.map
@@ -12,14 +12,14 @@ function locateConfigFile(commandLine) {
12
12
  if (commandLine.fileNames.length > 0) {
13
13
  return undefined;
14
14
  }
15
- const searchPath = utils_1.normalizeSlashes(process.cwd());
15
+ const searchPath = (0, utils_1.normalizeSlashes)(process.cwd());
16
16
  return ts.findConfigFile(searchPath, ts.sys.fileExists);
17
17
  }
18
18
  if (commandLine.fileNames.length !== 0) {
19
19
  return cliDiagnostics.optionProjectCannotBeMixedWithSourceFilesOnACommandLine();
20
20
  }
21
21
  // TODO: Unlike tsc, this resolves `.` to absolute path
22
- const fileOrDirectory = utils_1.normalizeSlashes(path.resolve(process.cwd(), project));
22
+ const fileOrDirectory = (0, utils_1.normalizeSlashes)(path.resolve(process.cwd(), project));
23
23
  if (ts.sys.directoryExists(fileOrDirectory)) {
24
24
  const configFileName = path.posix.join(fileOrDirectory, "tsconfig.json");
25
25
  if (ts.sys.fileExists(configFileName)) {
@@ -39,7 +39,7 @@ function locateConfigFile(commandLine) {
39
39
  exports.locateConfigFile = locateConfigFile;
40
40
  function parseConfigFileWithSystem(configFileName, commandLineOptions, system = ts.sys) {
41
41
  const parsedConfigFile = ts.parseJsonSourceFileConfigFileContent(ts.readJsonConfigFile(configFileName, system.readFile), system, path.dirname(configFileName), commandLineOptions, configFileName);
42
- return parse_1.updateParsedConfigFile(parsedConfigFile);
42
+ return (0, parse_1.updateParsedConfigFile)(parsedConfigFile);
43
43
  }
44
44
  exports.parseConfigFileWithSystem = parseConfigFileWithSystem;
45
45
  function createConfigFileUpdater(optionsToExtend) {
@@ -49,7 +49,7 @@ function createConfigFileUpdater(optionsToExtend) {
49
49
  if (!configFile || !configFilePath)
50
50
  return [];
51
51
  if (!configFileMap.has(configFile)) {
52
- const parsedConfigFile = parse_1.updateParsedConfigFile(ts.parseJsonSourceFileConfigFileContent(configFile, ts.sys, path.dirname(configFilePath), optionsToExtend, configFilePath));
52
+ const parsedConfigFile = (0, parse_1.updateParsedConfigFile)(ts.parseJsonSourceFileConfigFileContent(configFile, ts.sys, path.dirname(configFilePath), optionsToExtend, configFilePath));
53
53
  configFileMap.set(configFile, parsedConfigFile);
54
54
  }
55
55
  const parsedConfigFile = configFileMap.get(configFile);
@@ -4,7 +4,7 @@ function __TS__ArrayFlat(array, depth)
4
4
  end
5
5
  local result = {}
6
6
  for ____, value in ipairs(array) do
7
- if (depth > 0) and __TS__ArrayIsArray(value) then
7
+ if depth > 0 and __TS__ArrayIsArray(value) then
8
8
  result = __TS__ArrayConcat(
9
9
  result,
10
10
  __TS__ArrayFlat(value, depth - 1)
@@ -4,7 +4,7 @@ function __TS__ArrayFlatMap(array, callback)
4
4
  local i = 0
5
5
  while i < #array do
6
6
  local value = callback(_G, array[i + 1], i, array)
7
- if (type(value) == "table") and __TS__ArrayIsArray(value) then
7
+ if type(value) == "table" and __TS__ArrayIsArray(value) then
8
8
  result = __TS__ArrayConcat(result, value)
9
9
  else
10
10
  result[#result + 1] = value
@@ -1,3 +1,3 @@
1
1
  function __TS__ArrayIsArray(value)
2
- return (type(value) == "table") and ((value[1] ~= nil) or (next(value, nil) == nil))
2
+ return type(value) == "table" and (value[1] ~= nil or next(value, nil) == nil)
3
3
  end
@@ -11,7 +11,13 @@ function __TS__ArrayReduce(arr, callbackFn, ...)
11
11
  error("Reduce of empty array with no initial value", 0)
12
12
  end
13
13
  for i = k, len - 1 do
14
- accumulator = callbackFn(_G, accumulator, arr[i + 1], i, arr)
14
+ accumulator = callbackFn(
15
+ _G,
16
+ accumulator,
17
+ arr[i + 1],
18
+ i,
19
+ arr
20
+ )
15
21
  end
16
22
  return accumulator
17
23
  end
@@ -11,7 +11,13 @@ function __TS__ArrayReduceRight(arr, callbackFn, ...)
11
11
  error("Reduce of empty array with no initial value", 0)
12
12
  end
13
13
  for i = k, 0, -1 do
14
- accumulator = callbackFn(_G, accumulator, arr[i + 1], i, arr)
14
+ accumulator = callbackFn(
15
+ _G,
16
+ accumulator,
17
+ arr[i + 1],
18
+ i,
19
+ arr
20
+ )
15
21
  end
16
22
  return accumulator
17
23
  end
@@ -1,5 +1,5 @@
1
1
  function __TS__ArraySetLength(arr, length)
2
- if (((length < 0) or (length ~= length)) or (length == math.huge)) or (math.floor(length) ~= length) then
2
+ if length < 0 or length ~= length or length == math.huge or math.floor(length) ~= length then
3
3
  error(
4
4
  "invalid array length: " .. tostring(length),
5
5
  0