typescript-to-lua 1.34.0 → 1.36.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 (116) hide show
  1. package/dist/CompilerOptions.js +34 -4
  2. package/dist/LuaAST.js +34 -1
  3. package/dist/LuaLib.js +35 -2
  4. package/dist/LuaPrinter.js +36 -3
  5. package/dist/cli/diagnostics.js +34 -1
  6. package/dist/cli/parse.js +35 -2
  7. package/dist/cli/report.js +34 -1
  8. package/dist/cli/tsconfig.js +36 -3
  9. package/dist/lualib/5.0/Map.lua +36 -12
  10. package/dist/lualib/5.0/ObjectAssign.lua +4 -2
  11. package/dist/lualib/5.0/Promise.lua +11 -20
  12. package/dist/lualib/5.0/Set.lua +36 -12
  13. package/dist/lualib/5.0/SetDescriptor.lua +7 -0
  14. package/dist/lualib/5.0/lualib_bundle.lua +94 -46
  15. package/dist/lualib/universal/Map.lua +36 -12
  16. package/dist/lualib/universal/ObjectAssign.lua +4 -2
  17. package/dist/lualib/universal/Promise.lua +11 -20
  18. package/dist/lualib/universal/Set.lua +36 -12
  19. package/dist/lualib/universal/SetDescriptor.lua +7 -0
  20. package/dist/lualib/universal/lualib_bundle.lua +94 -46
  21. package/dist/lualib-build/plugin.js +36 -3
  22. package/dist/lualib-build/util.js +34 -1
  23. package/dist/transformation/builtins/array.js +35 -2
  24. package/dist/transformation/builtins/console.js +35 -2
  25. package/dist/transformation/builtins/function.js +34 -1
  26. package/dist/transformation/builtins/index.js +35 -2
  27. package/dist/transformation/builtins/math.js +41 -3
  28. package/dist/transformation/builtins/number.js +42 -5
  29. package/dist/transformation/builtins/object.js +34 -1
  30. package/dist/transformation/builtins/promise.js +34 -1
  31. package/dist/transformation/builtins/string.js +34 -1
  32. package/dist/transformation/builtins/symbol.js +34 -1
  33. package/dist/transformation/context/context.js +35 -2
  34. package/dist/transformation/context/visitors.js +34 -1
  35. package/dist/transformation/index.js +34 -1
  36. package/dist/transformation/pre-transformers/using-transformer.js +34 -1
  37. package/dist/transformation/utils/annotations.js +34 -1
  38. package/dist/transformation/utils/assignment-validation.js +34 -1
  39. package/dist/transformation/utils/diagnostics.js +35 -2
  40. package/dist/transformation/utils/export.js +35 -2
  41. package/dist/transformation/utils/function-context.js +36 -4
  42. package/dist/transformation/utils/language-extensions.js +34 -1
  43. package/dist/transformation/utils/lua-ast.js +35 -2
  44. package/dist/transformation/utils/lualib.js +34 -1
  45. package/dist/transformation/utils/scope.d.ts +6 -0
  46. package/dist/transformation/utils/scope.js +56 -2
  47. package/dist/transformation/utils/typescript/index.js +27 -3
  48. package/dist/transformation/utils/typescript/nodes.js +34 -1
  49. package/dist/transformation/utils/typescript/types.js +34 -1
  50. package/dist/transformation/visitors/access.js +35 -2
  51. package/dist/transformation/visitors/async-await.js +35 -2
  52. package/dist/transformation/visitors/binary-expression/assignments.js +35 -2
  53. package/dist/transformation/visitors/binary-expression/bit.js +41 -2
  54. package/dist/transformation/visitors/binary-expression/compound.js +35 -2
  55. package/dist/transformation/visitors/binary-expression/destructuring-assignments.js +35 -2
  56. package/dist/transformation/visitors/binary-expression/index.js +35 -2
  57. package/dist/transformation/visitors/block.js +35 -2
  58. package/dist/transformation/visitors/break-continue.js +51 -2
  59. package/dist/transformation/visitors/call.js +35 -2
  60. package/dist/transformation/visitors/class/decorators.js +35 -2
  61. package/dist/transformation/visitors/class/index.js +35 -2
  62. package/dist/transformation/visitors/class/members/accessors.js +35 -2
  63. package/dist/transformation/visitors/class/members/constructor.js +35 -2
  64. package/dist/transformation/visitors/class/members/fields.js +34 -1
  65. package/dist/transformation/visitors/class/members/method.js +35 -2
  66. package/dist/transformation/visitors/class/new.js +34 -1
  67. package/dist/transformation/visitors/class/setup.js +35 -2
  68. package/dist/transformation/visitors/class/utils.js +34 -1
  69. package/dist/transformation/visitors/conditional.js +35 -2
  70. package/dist/transformation/visitors/delete.js +35 -2
  71. package/dist/transformation/visitors/enum.js +35 -2
  72. package/dist/transformation/visitors/errors.js +119 -21
  73. package/dist/transformation/visitors/expression-list.js +35 -2
  74. package/dist/transformation/visitors/expression-statement.js +34 -1
  75. package/dist/transformation/visitors/function.js +35 -2
  76. package/dist/transformation/visitors/identifier.js +35 -2
  77. package/dist/transformation/visitors/index.js +34 -1
  78. package/dist/transformation/visitors/language-extensions/iterable.js +35 -2
  79. package/dist/transformation/visitors/language-extensions/multi.js +35 -2
  80. package/dist/transformation/visitors/language-extensions/operators.js +34 -1
  81. package/dist/transformation/visitors/language-extensions/range.js +36 -3
  82. package/dist/transformation/visitors/language-extensions/table.js +34 -1
  83. package/dist/transformation/visitors/language-extensions/vararg.js +34 -1
  84. package/dist/transformation/visitors/literal.js +35 -2
  85. package/dist/transformation/visitors/loops/do-while.js +34 -1
  86. package/dist/transformation/visitors/loops/for-in.js +34 -1
  87. package/dist/transformation/visitors/loops/for-of.js +35 -2
  88. package/dist/transformation/visitors/loops/for.js +35 -2
  89. package/dist/transformation/visitors/loops/utils.js +35 -2
  90. package/dist/transformation/visitors/modules/export.js +36 -3
  91. package/dist/transformation/visitors/modules/import.js +36 -3
  92. package/dist/transformation/visitors/namespace.js +35 -2
  93. package/dist/transformation/visitors/optional-chaining.js +35 -2
  94. package/dist/transformation/visitors/return.js +75 -19
  95. package/dist/transformation/visitors/sourceFile.js +35 -2
  96. package/dist/transformation/visitors/spread.js +35 -2
  97. package/dist/transformation/visitors/switch.js +35 -2
  98. package/dist/transformation/visitors/template.js +35 -2
  99. package/dist/transformation/visitors/typeof.js +35 -2
  100. package/dist/transformation/visitors/typescript.js +34 -1
  101. package/dist/transformation/visitors/unary-expression.js +35 -2
  102. package/dist/transformation/visitors/variable-declaration.js +36 -3
  103. package/dist/transformation/visitors/void.js +35 -2
  104. package/dist/transpilation/bundle.js +34 -1
  105. package/dist/transpilation/diagnostics.d.ts +1 -1
  106. package/dist/transpilation/diagnostics.js +37 -3
  107. package/dist/transpilation/index.js +25 -3
  108. package/dist/transpilation/plugins.js +34 -1
  109. package/dist/transpilation/resolve.js +48 -12
  110. package/dist/transpilation/transformers.js +36 -3
  111. package/dist/transpilation/transpile.js +36 -3
  112. package/dist/transpilation/transpiler.js +56 -9
  113. package/dist/transpilation/utils.js +37 -4
  114. package/dist/tstl.js +37 -4
  115. package/dist/utils.js +37 -4
  116. package/package.json +9 -9
@@ -10,6 +10,28 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
13
35
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
37
  };
@@ -19,9 +41,9 @@ exports.transpileProject = transpileProject;
19
41
  exports.createVirtualProgram = createVirtualProgram;
20
42
  exports.transpileVirtualProject = transpileVirtualProject;
21
43
  exports.transpileString = transpileString;
22
- const fs = require("fs");
23
- const path = require("path");
24
- const ts = require("typescript");
44
+ const fs = __importStar(require("fs"));
45
+ const path = __importStar(require("path"));
46
+ const ts = __importStar(require("typescript"));
25
47
  const tsconfig_1 = require("../cli/tsconfig");
26
48
  const utils_1 = require("../utils");
27
49
  const output_collector_1 = require("./output-collector");
@@ -1,8 +1,41 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.getPlugins = getPlugins;
4
37
  const utils_1 = require("./utils");
5
- const performance = require("../measure-performance");
38
+ const performance = __importStar(require("../measure-performance"));
6
39
  function getPlugins(program) {
7
40
  var _a;
8
41
  performance.startSection("getPlugins");
@@ -1,16 +1,49 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.resolveDependencies = resolveDependencies;
4
- const path = require("path");
5
- const resolve = require("enhanced-resolve");
6
- const fs = require("fs");
37
+ const path = __importStar(require("path"));
38
+ const resolve = __importStar(require("enhanced-resolve"));
39
+ const fs = __importStar(require("fs"));
7
40
  const source_map_1 = require("source-map");
8
41
  const transpiler_1 = require("./transpiler");
9
42
  const utils_1 = require("../utils");
10
43
  const diagnostics_1 = require("./diagnostics");
11
44
  const CompilerOptions_1 = require("../CompilerOptions");
12
45
  const find_lua_requires_1 = require("./find-lua-requires");
13
- const picomatch = require("picomatch");
46
+ const picomatch = __importStar(require("picomatch"));
14
47
  const resolver = resolve.ResolverFactory.createResolver({
15
48
  extensions: [".lua"],
16
49
  enforceExtension: true, // Resolved file must be a lua file
@@ -30,9 +63,7 @@ class ResolutionContext {
30
63
  this.processedDependencies = new Set();
31
64
  // value is false if already searched but not found
32
65
  this.pathToFile = new Map();
33
- const unique = [...new Set(options.noResolvePaths)];
34
- const matchers = unique.map(x => picomatch(x));
35
- this.noResolvePaths = matchers;
66
+ this.noResolvePaths = [...new Set(options.noResolvePaths)];
36
67
  }
37
68
  addAndResolveDependencies(file) {
38
69
  if (this.resolvedFiles.has(file.fileName))
@@ -62,7 +93,7 @@ class ResolutionContext {
62
93
  this.resolvedFiles.set("lualib_bundle", { fileName: "lualib_bundle", code: "" });
63
94
  return;
64
95
  }
65
- if (this.noResolvePaths.find(isMatch => isMatch(required.requirePath))) {
96
+ if (this.noResolvePaths.find(glob => picomatch.isMatch(required.requirePath, glob))) {
66
97
  if (this.options.tstlVerbose) {
67
98
  console.log(`Skipping module resolution of ${required.requirePath} as it is in the tsconfig noResolvePaths.`);
68
99
  }
@@ -151,6 +182,7 @@ class ResolutionContext {
151
182
  this.diagnostics.push((0, diagnostics_1.couldNotResolveRequire)(required.requirePath, path.relative((0, transpiler_1.getProjectRoot)(this.program), file.fileName)));
152
183
  }
153
184
  resolveDependencyPath(requiringFile, dependency) {
185
+ var _a;
154
186
  const fileDirectory = path.dirname(requiringFile.fileName);
155
187
  if (this.options.tstlVerbose) {
156
188
  console.log(`Resolving "${dependency}" from ${(0, utils_1.normalizeSlashes)(requiringFile.fileName)}`);
@@ -168,11 +200,15 @@ class ResolutionContext {
168
200
  const fileFromPath = this.getFileFromPath(resolvedPath);
169
201
  if (fileFromPath)
170
202
  return fileFromPath;
171
- if (this.options.paths && this.options.baseUrl) {
203
+ if (this.options.paths) {
172
204
  // If no file found yet and paths are present, try to find project file via paths mappings
173
- const fileFromPaths = this.tryGetModuleNameFromPaths(dependencyPath, this.options.paths, this.options.baseUrl);
174
- if (fileFromPaths)
175
- return fileFromPaths;
205
+ // When baseUrl is not set, resolve paths relative to the tsconfig directory (TS 6.0+ behavior)
206
+ const pathsBase = (_a = this.options.baseUrl) !== null && _a !== void 0 ? _a : (this.options.configFilePath ? path.dirname(this.options.configFilePath) : undefined);
207
+ if (pathsBase) {
208
+ const fileFromPaths = this.tryGetModuleNameFromPaths(dependencyPath, this.options.paths, pathsBase);
209
+ if (fileFromPaths)
210
+ return fileFromPaths;
211
+ }
176
212
  }
177
213
  // Not a TS file in our project sources, use resolver to check if we can find dependency
178
214
  try {
@@ -1,11 +1,44 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.stripParenthesisExpressionsTransformer = exports.noImplicitSelfTransformer = void 0;
4
37
  exports.getTransformers = getTransformers;
5
- const ts = require("typescript");
38
+ const ts = __importStar(require("typescript"));
6
39
  // TODO: Don't depend on CLI?
7
- const cliDiagnostics = require("../cli/diagnostics");
8
- const diagnosticFactories = require("./diagnostics");
40
+ const cliDiagnostics = __importStar(require("../cli/diagnostics"));
41
+ const diagnosticFactories = __importStar(require("./diagnostics"));
9
42
  const utils_1 = require("./utils");
10
43
  function getTransformers(program, diagnostics, customTransformers, onSourceFile) {
11
44
  var _a, _b, _c, _d, _e, _f;
@@ -1,14 +1,47 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.getProgramTranspileResult = getProgramTranspileResult;
4
- const path = require("path");
5
- const ts = require("typescript");
37
+ const path = __importStar(require("path"));
38
+ const ts = __importStar(require("typescript"));
6
39
  const CompilerOptions_1 = require("../CompilerOptions");
7
40
  const LuaPrinter_1 = require("../LuaPrinter");
8
41
  const transformation_1 = require("../transformation");
9
42
  const utils_1 = require("../utils");
10
43
  const transformers_1 = require("./transformers");
11
- const performance = require("../measure-performance");
44
+ const performance = __importStar(require("../measure-performance"));
12
45
  function getProgramTranspileResult(emitHost, writeFileResult, { program, sourceFiles: targetSourceFiles, customTransformers = {}, plugins = [] }) {
13
46
  var _a, _b;
14
47
  performance.startSection("beforeTransform");
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.Transpiler = void 0;
4
37
  exports.getEmitPath = getEmitPath;
@@ -6,16 +39,17 @@ exports.getEmitPathRelativeToOutDir = getEmitPathRelativeToOutDir;
6
39
  exports.getSourceDir = getSourceDir;
7
40
  exports.getEmitOutDir = getEmitOutDir;
8
41
  exports.getProjectRoot = getProjectRoot;
9
- const path = require("path");
10
- const ts = require("typescript");
42
+ const path = __importStar(require("path"));
43
+ const ts = __importStar(require("typescript"));
11
44
  const CompilerOptions_1 = require("../CompilerOptions");
12
45
  const LuaLib_1 = require("../LuaLib");
13
46
  const utils_1 = require("../utils");
14
47
  const bundle_1 = require("./bundle");
48
+ const diagnostics_1 = require("./diagnostics");
15
49
  const plugins_1 = require("./plugins");
16
50
  const resolve_1 = require("./resolve");
17
51
  const transpile_1 = require("./transpile");
18
- const performance = require("../measure-performance");
52
+ const performance = __importStar(require("../measure-performance"));
19
53
  class Transpiler {
20
54
  constructor({ emitHost = ts.sys } = {}) {
21
55
  this.emitHost = emitHost;
@@ -99,10 +133,18 @@ class Transpiler {
99
133
  emitPlan = [bundleFile];
100
134
  }
101
135
  else {
102
- emitPlan = resolutionResult.resolvedFiles.map(file => ({
103
- ...file,
104
- outputPath: getEmitPath(file.fileName, program),
105
- }));
136
+ const outputPathMap = new Map();
137
+ emitPlan = resolutionResult.resolvedFiles.map(file => {
138
+ const outputPath = getEmitPath(file.fileName, program);
139
+ const existing = outputPathMap.get(outputPath);
140
+ if (existing) {
141
+ diagnostics.push((0, diagnostics_1.emitPathCollision)(outputPath, existing, file.fileName));
142
+ }
143
+ else {
144
+ outputPathMap.set(outputPath, file.fileName);
145
+ }
146
+ return { ...file, outputPath };
147
+ });
106
148
  }
107
149
  performance.endSection("getEmitPlan");
108
150
  return { emitPlan };
@@ -136,11 +178,16 @@ function getEmitPathRelativeToOutDir(fileName, program) {
136
178
  if (emitPathSplits[0] === "node_modules") {
137
179
  emitPathSplits[0] = "lua_modules";
138
180
  }
181
+ // Replace dots with underscores in path segments so that Lua's require()
182
+ // resolves correctly. Dots are path separators in Lua's module system, so
183
+ // "Foo.Bar/index.lua" would be unreachable via require("Foo.Bar.index")
184
+ // since Lua interprets it as "Foo/Bar/index.lua".
185
+ emitPathSplits[emitPathSplits.length - 1] = (0, utils_1.trimExtension)(emitPathSplits[emitPathSplits.length - 1]);
186
+ emitPathSplits = emitPathSplits.map(segment => segment.replace(/\./g, "_"));
139
187
  // Set extension
140
188
  const extension = ((_a = program.getCompilerOptions().extension) !== null && _a !== void 0 ? _a : "lua").trim();
141
189
  const trimmedExtension = extension.startsWith(".") ? extension.substring(1) : extension;
142
- emitPathSplits[emitPathSplits.length - 1] =
143
- (0, utils_1.trimExtension)(emitPathSplits[emitPathSplits.length - 1]) + "." + trimmedExtension;
190
+ emitPathSplits[emitPathSplits.length - 1] += "." + trimmedExtension;
144
191
  return path.join(...emitPathSplits);
145
192
  }
146
193
  function getSourceDir(program) {
@@ -1,12 +1,45 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.getConfigDirectory = void 0;
4
37
  exports.resolvePlugin = resolvePlugin;
5
- const path = require("path");
6
- const resolve = require("resolve");
38
+ const path = __importStar(require("path"));
39
+ const resolve = __importStar(require("resolve"));
7
40
  // TODO: Don't depend on CLI?
8
- const cliDiagnostics = require("../cli/diagnostics");
9
- const diagnosticFactories = require("./diagnostics");
41
+ const cliDiagnostics = __importStar(require("../cli/diagnostics"));
42
+ const diagnosticFactories = __importStar(require("./diagnostics"));
10
43
  const getConfigDirectory = (options) => options.configFilePath ? path.dirname(options.configFilePath) : process.cwd();
11
44
  exports.getConfigDirectory = getConfigDirectory;
12
45
  const getTstlDirectory = () => path.dirname(__dirname);
package/dist/tstl.js CHANGED
@@ -1,15 +1,48 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
3
36
  Object.defineProperty(exports, "__esModule", { value: true });
4
- const ts = require("typescript");
5
- const tstl = require(".");
6
- const cliDiagnostics = require("./cli/diagnostics");
37
+ const ts = __importStar(require("typescript"));
38
+ const tstl = __importStar(require("."));
39
+ const cliDiagnostics = __importStar(require("./cli/diagnostics"));
7
40
  const information_1 = require("./cli/information");
8
41
  const parse_1 = require("./cli/parse");
9
42
  const report_1 = require("./cli/report");
10
43
  const tsconfig_1 = require("./cli/tsconfig");
11
44
  const CompilerOptions_1 = require("./CompilerOptions");
12
- const performance = require("./measure-performance");
45
+ const performance = __importStar(require("./measure-performance"));
13
46
  const shouldBePretty = ({ pretty } = {}) => { var _a, _b, _c; return pretty !== undefined ? pretty : (_c = (_b = (_a = ts.sys).writeOutputIsTTY) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : false; };
14
47
  let reportDiagnostic = (0, report_1.createDiagnosticReporter)(false);
15
48
  function updateReportDiagnostic(options) {
package/dist/utils.js CHANGED
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.trimExtension = exports.normalizeSlashes = exports.createSerialDiagnosticFactory = exports.createDiagnosticFactoryWithCode = exports.intersection = exports.union = exports.intersperse = void 0;
4
37
  exports.castArray = castArray;
@@ -9,9 +42,9 @@ exports.cast = cast;
9
42
  exports.assert = assert;
10
43
  exports.assertNever = assertNever;
11
44
  exports.assume = assume;
12
- const ts = require("typescript");
13
- const nativeAssert = require("assert");
14
- const path = require("path");
45
+ const ts = __importStar(require("typescript"));
46
+ const nativeAssert = __importStar(require("assert"));
47
+ const path = __importStar(require("path"));
15
48
  function castArray(value) {
16
49
  return Array.isArray(value) ? value : [value];
17
50
  }
@@ -64,7 +97,7 @@ function cast(item, cast) {
64
97
  }
65
98
  }
66
99
  function assert(value, message) {
67
- nativeAssert(value, message);
100
+ nativeAssert.ok(value, message);
68
101
  }
69
102
  function assertNever(_value) {
70
103
  throw new Error("Value is expected to be never");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typescript-to-lua",
3
- "version": "1.34.0",
3
+ "version": "1.36.0",
4
4
  "description": "A generic TypeScript to Lua transpiler. Write your code in TypeScript and publish Lua!",
5
5
  "repository": "https://github.com/TypeScriptToLua/TypeScriptToLua",
6
6
  "homepage": "https://typescripttolua.github.io/",
@@ -31,7 +31,7 @@
31
31
  "lint:prettier": "prettier --check . || (echo 'Run `npm run fix:prettier` to fix it.' && exit 1)",
32
32
  "lint:eslint": "eslint .",
33
33
  "fix:prettier": "prettier --write .",
34
- "check:language-extensions": "tsc --strict language-extensions/index.d.ts",
34
+ "check:language-extensions": "tsc --strict --ignoreConfig language-extensions/index.d.ts",
35
35
  "preversion": "npm run build && npm test",
36
36
  "postversion": "git push && git push --tags"
37
37
  },
@@ -42,7 +42,7 @@
42
42
  "node": ">=16.10.0"
43
43
  },
44
44
  "peerDependencies": {
45
- "typescript": "5.9.3"
45
+ "typescript": "6.0.2"
46
46
  },
47
47
  "dependencies": {
48
48
  "@typescript-to-lua/language-extensions": "1.19.0",
@@ -58,18 +58,18 @@
58
58
  "@types/node": "^22.10.0",
59
59
  "@types/picomatch": "^2.3.0",
60
60
  "@types/resolve": "1.14.0",
61
- "eslint": "^9.22.0",
62
- "eslint-plugin-jest": "^28.8.3",
61
+ "eslint": "^9.39.4",
62
+ "eslint-plugin-jest": "^28.14.0",
63
63
  "fs-extra": "^8.1.0",
64
64
  "javascript-stringify": "^2.0.1",
65
- "jest": "^29.5.0",
65
+ "jest": "^29.7.0",
66
66
  "jest-circus": "^29.7.0",
67
67
  "lua-types": "^2.14.1",
68
68
  "lua-wasm-bindings": "^0.5.3",
69
69
  "prettier": "^2.8.8",
70
- "ts-jest": "^29.2.5",
70
+ "ts-jest": "^29.4.9",
71
71
  "ts-node": "^10.9.2",
72
- "typescript": "5.9.3",
73
- "typescript-eslint": "^8.46.3"
72
+ "typescript": "6.0.2",
73
+ "typescript-eslint": "^8.58.0"
74
74
  }
75
75
  }