typescript-to-lua 1.3.4 → 1.4.2

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 (139) hide show
  1. package/dist/CompilerOptions.d.ts +1 -1
  2. package/dist/CompilerOptions.js +0 -1
  3. package/dist/LuaLib.d.ts +13 -1
  4. package/dist/LuaLib.js +62 -65
  5. package/dist/LuaPrinter.js +13 -12
  6. package/dist/cli/parse.js +5 -0
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.js +5 -1
  9. package/dist/lualib/ArrayConcat.lua +1 -1
  10. package/dist/lualib/ArrayEntries.lua +1 -1
  11. package/dist/lualib/ArrayEvery.lua +2 -2
  12. package/dist/lualib/ArrayFilter.lua +2 -2
  13. package/dist/lualib/ArrayFind.lua +2 -2
  14. package/dist/lualib/ArrayFindIndex.lua +2 -2
  15. package/dist/lualib/ArrayFlat.lua +1 -1
  16. package/dist/lualib/ArrayFlatMap.lua +2 -2
  17. package/dist/lualib/ArrayForEach.lua +2 -2
  18. package/dist/lualib/ArrayFrom.lua +32 -0
  19. package/dist/lualib/ArrayIncludes.lua +1 -1
  20. package/dist/lualib/ArrayIndexOf.lua +1 -1
  21. package/dist/lualib/ArrayIsArray.lua +1 -1
  22. package/dist/lualib/ArrayJoin.lua +1 -1
  23. package/dist/lualib/ArrayMap.lua +2 -2
  24. package/dist/lualib/ArrayPush.lua +1 -1
  25. package/dist/lualib/ArrayReduce.lua +2 -2
  26. package/dist/lualib/ArrayReduceRight.lua +2 -2
  27. package/dist/lualib/ArrayReverse.lua +1 -1
  28. package/dist/lualib/ArraySetLength.lua +1 -1
  29. package/dist/lualib/ArrayShift.lua +1 -1
  30. package/dist/lualib/ArraySlice.lua +1 -1
  31. package/dist/lualib/ArraySome.lua +2 -2
  32. package/dist/lualib/ArraySort.lua +2 -2
  33. package/dist/lualib/ArraySplice.lua +1 -1
  34. package/dist/lualib/ArrayToObject.lua +1 -1
  35. package/dist/lualib/ArrayUnshift.lua +1 -1
  36. package/dist/lualib/Await.lua +13 -13
  37. package/dist/lualib/Class.lua +1 -1
  38. package/dist/lualib/ClassExtends.lua +1 -1
  39. package/dist/lualib/CloneDescriptor.lua +1 -1
  40. package/dist/lualib/Decorate.lua +5 -5
  41. package/dist/lualib/DecorateParam.lua +2 -2
  42. package/dist/lualib/DelegatedYield.lua +1 -1
  43. package/dist/lualib/Delete.lua +1 -1
  44. package/dist/lualib/Error.lua +68 -69
  45. package/dist/lualib/FunctionBind.lua +1 -1
  46. package/dist/lualib/Generator.lua +26 -23
  47. package/dist/lualib/InstanceOf.lua +1 -1
  48. package/dist/lualib/InstanceOfObject.lua +1 -1
  49. package/dist/lualib/Iterator.lua +35 -32
  50. package/dist/lualib/Map.lua +131 -129
  51. package/dist/lualib/MathAtan2.lua +1 -1
  52. package/dist/lualib/MathSign.lua +1 -1
  53. package/dist/lualib/New.lua +1 -1
  54. package/dist/lualib/Number.lua +1 -1
  55. package/dist/lualib/NumberIsFinite.lua +1 -1
  56. package/dist/lualib/NumberIsNaN.lua +1 -1
  57. package/dist/lualib/NumberToString.lua +42 -39
  58. package/dist/lualib/ObjectAssign.lua +1 -1
  59. package/dist/lualib/ObjectDefineProperty.lua +1 -1
  60. package/dist/lualib/ObjectEntries.lua +1 -1
  61. package/dist/lualib/ObjectFromEntries.lua +1 -1
  62. package/dist/lualib/ObjectGetOwnPropertyDescriptor.lua +1 -1
  63. package/dist/lualib/ObjectGetOwnPropertyDescriptors.lua +1 -1
  64. package/dist/lualib/ObjectKeys.lua +1 -1
  65. package/dist/lualib/ObjectRest.lua +1 -1
  66. package/dist/lualib/ObjectValues.lua +1 -1
  67. package/dist/lualib/ParseFloat.lua +1 -1
  68. package/dist/lualib/ParseInt.lua +39 -36
  69. package/dist/lualib/Promise.lua +148 -152
  70. package/dist/lualib/PromiseAll.lua +5 -5
  71. package/dist/lualib/PromiseAllSettled.lua +5 -5
  72. package/dist/lualib/PromiseAny.lua +5 -5
  73. package/dist/lualib/PromiseRace.lua +5 -5
  74. package/dist/lualib/Set.lua +120 -118
  75. package/dist/lualib/SetDescriptor.lua +67 -64
  76. package/dist/lualib/SourceMapTraceBack.lua +7 -6
  77. package/dist/lualib/SparseArrayNew.lua +1 -1
  78. package/dist/lualib/SparseArrayPush.lua +1 -1
  79. package/dist/lualib/SparseArraySpread.lua +1 -1
  80. package/dist/lualib/Spread.lua +1 -1
  81. package/dist/lualib/StringAccess.lua +1 -1
  82. package/dist/lualib/StringCharAt.lua +1 -1
  83. package/dist/lualib/StringCharCodeAt.lua +1 -1
  84. package/dist/lualib/StringConcat.lua +1 -1
  85. package/dist/lualib/StringEndsWith.lua +1 -1
  86. package/dist/lualib/StringIncludes.lua +1 -1
  87. package/dist/lualib/StringPadEnd.lua +1 -1
  88. package/dist/lualib/StringPadStart.lua +1 -1
  89. package/dist/lualib/StringReplace.lua +2 -2
  90. package/dist/lualib/StringReplaceAll.lua +4 -4
  91. package/dist/lualib/StringSlice.lua +1 -1
  92. package/dist/lualib/StringSplit.lua +1 -1
  93. package/dist/lualib/StringStartsWith.lua +1 -1
  94. package/dist/lualib/StringSubstr.lua +1 -1
  95. package/dist/lualib/StringSubstring.lua +1 -1
  96. package/dist/lualib/StringTrim.lua +1 -1
  97. package/dist/lualib/StringTrimEnd.lua +1 -1
  98. package/dist/lualib/StringTrimStart.lua +1 -1
  99. package/dist/lualib/Symbol.lua +14 -11
  100. package/dist/lualib/SymbolRegistry.lua +13 -10
  101. package/dist/lualib/TypeOf.lua +1 -1
  102. package/dist/lualib/Unpack.lua +1 -1
  103. package/dist/lualib/WeakMap.lua +41 -39
  104. package/dist/lualib/WeakSet.lua +37 -35
  105. package/dist/lualib/lualib_bundle.lua +1096 -932
  106. package/dist/lualib/lualib_module_info.json +628 -0
  107. package/dist/lualib-build/plugin.d.ts +23 -0
  108. package/dist/lualib-build/plugin.js +138 -0
  109. package/dist/lualib-build/util.d.ts +19 -0
  110. package/dist/lualib-build/util.js +43 -0
  111. package/dist/transformation/builtins/array.d.ts +1 -1
  112. package/dist/transformation/builtins/array.js +5 -0
  113. package/dist/transformation/builtins/function.js +2 -1
  114. package/dist/transformation/builtins/index.d.ts +1 -0
  115. package/dist/transformation/builtins/index.js +63 -16
  116. package/dist/transformation/context/index.js +5 -1
  117. package/dist/transformation/utils/diagnostics.d.ts +3 -0
  118. package/dist/transformation/utils/diagnostics.js +2 -1
  119. package/dist/transformation/utils/typescript/index.js +5 -1
  120. package/dist/transformation/utils/typescript/types.d.ts +2 -0
  121. package/dist/transformation/utils/typescript/types.js +10 -1
  122. package/dist/transformation/visitors/class/index.js +1 -5
  123. package/dist/transformation/visitors/class/new.d.ts +1 -2
  124. package/dist/transformation/visitors/class/new.js +1 -40
  125. package/dist/transformation/visitors/conditional.js +15 -14
  126. package/dist/transformation/visitors/identifier.js +5 -0
  127. package/dist/transformation/visitors/literal.js +22 -0
  128. package/dist/transformation/visitors/modules/import.js +4 -14
  129. package/dist/transpilation/bundle.js +1 -1
  130. package/dist/transpilation/index.js +5 -1
  131. package/dist/transpilation/plugins.d.ts +19 -1
  132. package/dist/transpilation/plugins.js +6 -2
  133. package/dist/transpilation/resolve.js +1 -0
  134. package/dist/transpilation/transpile.d.ts +1 -1
  135. package/dist/transpilation/transpile.js +13 -5
  136. package/dist/transpilation/transpiler.js +25 -11
  137. package/dist/transpilation/utils.d.ts +2 -0
  138. package/package.json +12 -11
  139. package/CHANGELOG.md +0 -703
@@ -174,10 +174,32 @@ const transformObjectLiteralExpression = (expression, context) => {
174
174
  }
175
175
  };
176
176
  const transformArrayLiteralExpression = (expression, context) => {
177
+ // Disallow using undefined/null in array literals
178
+ checkForUndefinedOrNullInArrayLiteral(expression, context);
177
179
  const filteredElements = expression.elements.map(e => ts.isOmittedExpression(e) ? ts.factory.createIdentifier("undefined") : e);
178
180
  const values = (0, expression_list_1.transformExpressionList)(context, filteredElements).map(e => lua.createTableFieldExpression(e));
179
181
  return lua.createTableExpression(values, expression);
180
182
  };
183
+ function checkForUndefinedOrNullInArrayLiteral(array, context) {
184
+ // Look for last non-nil element in literal
185
+ let lastNonUndefinedIndex = array.elements.length - 1;
186
+ for (; lastNonUndefinedIndex >= 0; lastNonUndefinedIndex--) {
187
+ if (!isUndefinedOrNull(array.elements[lastNonUndefinedIndex])) {
188
+ break;
189
+ }
190
+ }
191
+ // Add diagnostics for non-trailing nil elements in array literal
192
+ for (let i = 0; i < array.elements.length; i++) {
193
+ if (i < lastNonUndefinedIndex && isUndefinedOrNull(array.elements[i])) {
194
+ context.diagnostics.push((0, diagnostics_1.undefinedInArrayLiteral)(array.elements[i]));
195
+ }
196
+ }
197
+ }
198
+ function isUndefinedOrNull(node) {
199
+ return (node.kind === ts.SyntaxKind.UndefinedKeyword ||
200
+ node.kind === ts.SyntaxKind.NullKeyword ||
201
+ (ts.isIdentifier(node) && node.text === "undefined"));
202
+ }
181
203
  exports.literalVisitors = {
182
204
  [ts.SyntaxKind.NullKeyword]: node => lua.createNilLiteral(node),
183
205
  [ts.SyntaxKind.TrueKeyword]: node => lua.createBooleanLiteral(true, node),
@@ -48,13 +48,8 @@ const transformImportDeclaration = (statement, context) => {
48
48
  // require("module")
49
49
  if (statement.importClause === undefined) {
50
50
  result.push(lua.createExpressionStatement(requireCall));
51
- if (scope.importStatements) {
52
- scope.importStatements.push(...result);
53
- return undefined;
54
- }
55
- else {
56
- return result;
57
- }
51
+ scope.importStatements.push(...result);
52
+ return undefined;
58
53
  }
59
54
  const importPath = ts.isStringLiteral(statement.moduleSpecifier)
60
55
  ? statement.moduleSpecifier.text.replace(/"/g, "")
@@ -100,13 +95,8 @@ const transformImportDeclaration = (statement, context) => {
100
95
  if (usingRequireStatement) {
101
96
  result.unshift(lua.createVariableDeclarationStatement(importUniqueName, requireCall, statement));
102
97
  }
103
- if (scope.importStatements) {
104
- scope.importStatements.push(...result);
105
- return undefined;
106
- }
107
- else {
108
- return result;
109
- }
98
+ scope.importStatements.push(...result);
99
+ return undefined;
110
100
  };
111
101
  exports.transformImportDeclaration = transformImportDeclaration;
112
102
  const transformExternalModuleReference = (node, context) => createModuleRequire(context, node.expression, node);
@@ -85,7 +85,7 @@ function getBundleResult(program, files) {
85
85
  const footers = [];
86
86
  if (options.sourceMapTraceback) {
87
87
  // Generates SourceMapTraceback for the entire file
88
- footers.push('require("lualib_bundle")\n');
88
+ footers.push('local __TS__SourceMapTraceBack = require("lualib_bundle").__TS__SourceMapTraceBack\n');
89
89
  footers.push(`${exports.sourceMapTracebackBundlePlaceholder}\n`);
90
90
  }
91
91
  const sourceChunks = [requireOverride, moduleTable, ...footers, entryPoint];
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -1,6 +1,9 @@
1
1
  import * as ts from "typescript";
2
+ import { EmitHost } from "..";
3
+ import { CompilerOptions } from "../CompilerOptions";
2
4
  import { Printer } from "../LuaPrinter";
3
5
  import { Visitors } from "../transformation/context";
6
+ import { EmitFile, ProcessedFile } from "./utils";
4
7
  export interface Plugin {
5
8
  /**
6
9
  * An augmentation to the map of visitors that transform TypeScript AST to Lua AST.
@@ -14,5 +17,20 @@ export interface Plugin {
14
17
  * At most one custom printer can be provided across all plugins.
15
18
  */
16
19
  printer?: Printer;
20
+ /**
21
+ * This function is called before transpilation of the TypeScript program starts.
22
+ */
23
+ beforeTransform?: (program: ts.Program, options: CompilerOptions, emitHost: EmitHost) => ts.Diagnostic[] | void;
24
+ /**
25
+ * This function is called after translating the input program to Lua, but before resolving dependencies or bundling.
26
+ */
27
+ afterPrint?: (program: ts.Program, options: CompilerOptions, emitHost: EmitHost, result: ProcessedFile[]) => ts.Diagnostic[] | void;
28
+ /**
29
+ * This function is called after translating the input program to Lua, after resolving dependencies and after bundling.
30
+ */
31
+ beforeEmit?: (program: ts.Program, options: CompilerOptions, emitHost: EmitHost, result: EmitFile[]) => ts.Diagnostic[] | void;
17
32
  }
18
- export declare function getPlugins(program: ts.Program, diagnostics: ts.Diagnostic[], customPlugins: Plugin[]): Plugin[];
33
+ export declare function getPlugins(program: ts.Program): {
34
+ diagnostics: ts.Diagnostic[];
35
+ plugins: Plugin[];
36
+ };
@@ -2,8 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getPlugins = void 0;
4
4
  const utils_1 = require("./utils");
5
- function getPlugins(program, diagnostics, customPlugins) {
5
+ function getPlugins(program) {
6
6
  var _a;
7
+ const diagnostics = [];
7
8
  const pluginsFromOptions = [];
8
9
  const options = program.getCompilerOptions();
9
10
  for (const [index, pluginOption] of ((_a = options.luaPlugins) !== null && _a !== void 0 ? _a : []).entries()) {
@@ -16,7 +17,10 @@ function getPlugins(program, diagnostics, customPlugins) {
16
17
  const plugin = typeof factory === "function" ? factory(pluginOption) : factory;
17
18
  pluginsFromOptions.push(plugin);
18
19
  }
19
- return [...customPlugins, ...pluginsFromOptions];
20
+ if (options.tstlVerbose) {
21
+ console.log(`Loaded ${pluginsFromOptions.length} plugins`);
22
+ }
23
+ return { diagnostics, plugins: pluginsFromOptions };
20
24
  }
21
25
  exports.getPlugins = getPlugins;
22
26
  //# sourceMappingURL=plugins.js.map
@@ -14,6 +14,7 @@ const resolver = resolve.ResolverFactory.createResolver({
14
14
  enforceExtension: true,
15
15
  fileSystem: { ...new resolve.CachedInputFileSystem(fs) },
16
16
  useSyncFileSystemCalls: true,
17
+ symlinks: false, // Do not resolve symlinks to their original paths (that breaks node_modules detection)
17
18
  });
18
19
  class ResolutionContext {
19
20
  constructor(program, options, emitHost) {
@@ -11,4 +11,4 @@ export interface TranspileResult {
11
11
  diagnostics: ts.Diagnostic[];
12
12
  transpiledFiles: ProcessedFile[];
13
13
  }
14
- export declare function getProgramTranspileResult(emitHost: EmitHost, writeFileResult: ts.WriteFileCallback, { program, sourceFiles: targetSourceFiles, customTransformers, plugins: customPlugins }: TranspileOptions): TranspileResult;
14
+ export declare function getProgramTranspileResult(emitHost: EmitHost, writeFileResult: ts.WriteFileCallback, { program, sourceFiles: targetSourceFiles, customTransformers, plugins }: TranspileOptions): TranspileResult;
@@ -7,9 +7,9 @@ const CompilerOptions_1 = require("../CompilerOptions");
7
7
  const LuaPrinter_1 = require("../LuaPrinter");
8
8
  const transformation_1 = require("../transformation");
9
9
  const utils_1 = require("../utils");
10
- const plugins_1 = require("./plugins");
11
10
  const transformers_1 = require("./transformers");
12
- function getProgramTranspileResult(emitHost, writeFileResult, { program, sourceFiles: targetSourceFiles, customTransformers = {}, plugins: customPlugins = [] }) {
11
+ function getProgramTranspileResult(emitHost, writeFileResult, { program, sourceFiles: targetSourceFiles, customTransformers = {}, plugins = [] }) {
12
+ var _a, _b;
13
13
  const options = program.getCompilerOptions();
14
14
  if (options.tstlVerbose) {
15
15
  console.log("Parsing project settings");
@@ -39,9 +39,11 @@ function getProgramTranspileResult(emitHost, writeFileResult, { program, sourceF
39
39
  return { diagnostics: preEmitDiagnostics, transpiledFiles };
40
40
  }
41
41
  }
42
- const plugins = (0, plugins_1.getPlugins)(program, diagnostics, customPlugins);
43
- if (options.tstlVerbose) {
44
- console.log(`Successfully loaded ${plugins.length} plugins`);
42
+ for (const plugin of plugins) {
43
+ if (plugin.beforeTransform) {
44
+ const pluginDiagnostics = (_a = plugin.beforeTransform(program, options, emitHost)) !== null && _a !== void 0 ? _a : [];
45
+ diagnostics.push(...pluginDiagnostics);
46
+ }
45
47
  }
46
48
  const visitorMap = (0, transformation_1.createVisitorMap)(plugins.map(p => p.visitors).filter(utils_1.isNonNull));
47
49
  const printer = (0, LuaPrinter_1.createPrinter)(plugins.map(p => p.printer).filter(utils_1.isNonNull));
@@ -95,6 +97,12 @@ function getProgramTranspileResult(emitHost, writeFileResult, { program, sourceF
95
97
  if (options.noEmit || (options.noEmitOnError && diagnostics.length > 0)) {
96
98
  transpiledFiles = [];
97
99
  }
100
+ for (const plugin of plugins) {
101
+ if (plugin.afterPrint) {
102
+ const pluginDiagnostics = (_b = plugin.afterPrint(program, options, emitHost, transpiledFiles)) !== null && _b !== void 0 ? _b : [];
103
+ diagnostics.push(...pluginDiagnostics);
104
+ }
105
+ }
98
106
  return { diagnostics, transpiledFiles };
99
107
  }
100
108
  exports.getProgramTranspileResult = getProgramTranspileResult;
@@ -7,6 +7,7 @@ const CompilerOptions_1 = require("../CompilerOptions");
7
7
  const LuaLib_1 = require("../LuaLib");
8
8
  const utils_1 = require("../utils");
9
9
  const bundle_1 = require("./bundle");
10
+ const plugins_1 = require("./plugins");
10
11
  const resolve_1 = require("./resolve");
11
12
  const transpile_1 = require("./transpile");
12
13
  class Transpiler {
@@ -14,18 +15,27 @@ class Transpiler {
14
15
  this.emitHost = emitHost;
15
16
  }
16
17
  emit(emitOptions) {
17
- var _a;
18
+ var _a, _b;
18
19
  const { program, writeFile = this.emitHost.writeFile } = emitOptions;
19
- const verbose = program.getCompilerOptions().tstlVerbose;
20
- const { diagnostics, transpiledFiles: freshFiles } = (0, transpile_1.getProgramTranspileResult)(this.emitHost, writeFile, emitOptions);
20
+ const options = program.getCompilerOptions();
21
+ const { diagnostics: getPluginsDiagnostics, plugins } = (0, plugins_1.getPlugins)(program);
22
+ const { diagnostics, transpiledFiles: freshFiles } = (0, transpile_1.getProgramTranspileResult)(this.emitHost, writeFile, {
23
+ ...emitOptions,
24
+ plugins,
25
+ });
21
26
  const { emitPlan } = this.getEmitPlan(program, diagnostics, freshFiles);
22
- if (verbose) {
27
+ if (options.tstlVerbose) {
23
28
  console.log("Emitting output");
24
29
  }
25
- const options = program.getCompilerOptions();
26
- const emitBOM = (_a = options.emitBOM) !== null && _a !== void 0 ? _a : false;
30
+ for (const plugin of plugins) {
31
+ if (plugin.beforeEmit) {
32
+ const beforeEmitPluginDiagnostics = (_a = plugin.beforeEmit(program, options, this.emitHost, emitPlan)) !== null && _a !== void 0 ? _a : [];
33
+ diagnostics.push(...beforeEmitPluginDiagnostics);
34
+ }
35
+ }
36
+ const emitBOM = (_b = options.emitBOM) !== null && _b !== void 0 ? _b : false;
27
37
  for (const { outputPath, code, sourceMap, sourceFiles } of emitPlan) {
28
- if (verbose) {
38
+ if (options.tstlVerbose) {
29
39
  console.log(`Emitting ${(0, utils_1.normalizeSlashes)(outputPath)}`);
30
40
  }
31
41
  writeFile(outputPath, code, emitBOM, undefined, sourceFiles);
@@ -33,10 +43,10 @@ class Transpiler {
33
43
  writeFile(outputPath + ".map", sourceMap, emitBOM, undefined, sourceFiles);
34
44
  }
35
45
  }
36
- if (verbose) {
46
+ if (options.tstlVerbose) {
37
47
  console.log("Emit finished!");
38
48
  }
39
- return { diagnostics, emitSkipped: emitPlan.length === 0 };
49
+ return { diagnostics: getPluginsDiagnostics.concat(diagnostics), emitSkipped: emitPlan.length === 0 };
40
50
  }
41
51
  getEmitPlan(program, diagnostics, files) {
42
52
  const options = program.getCompilerOptions();
@@ -80,6 +90,7 @@ function getEmitPath(file, program) {
80
90
  }
81
91
  exports.getEmitPath = getEmitPath;
82
92
  function getEmitPathRelativeToOutDir(fileName, program) {
93
+ var _a;
83
94
  const sourceDir = getSourceDir(program);
84
95
  // Default output path is relative path in source dir
85
96
  let emitPathSplits = path.relative(sourceDir, fileName).split(path.sep);
@@ -89,8 +100,11 @@ function getEmitPathRelativeToOutDir(fileName, program) {
89
100
  if (emitPathSplits[0] === "node_modules") {
90
101
  emitPathSplits[0] = "lua_modules";
91
102
  }
92
- // Make extension lua
93
- emitPathSplits[emitPathSplits.length - 1] = (0, utils_1.trimExtension)(emitPathSplits[emitPathSplits.length - 1]) + ".lua";
103
+ // Set extension
104
+ const extension = ((_a = program.getCompilerOptions().extension) !== null && _a !== void 0 ? _a : "lua").trim();
105
+ const trimmedExtension = extension.startsWith(".") ? extension.substring(1) : extension;
106
+ emitPathSplits[emitPathSplits.length - 1] =
107
+ (0, utils_1.trimExtension)(emitPathSplits[emitPathSplits.length - 1]) + "." + trimmedExtension;
94
108
  return path.join(...emitPathSplits);
95
109
  }
96
110
  exports.getEmitPathRelativeToOutDir = getEmitPathRelativeToOutDir;
@@ -1,3 +1,4 @@
1
+ import { SourceNode } from "source-map";
1
2
  import * as ts from "typescript";
2
3
  import * as lua from "../LuaAST";
3
4
  export interface EmitHost {
@@ -15,6 +16,7 @@ interface BaseFile {
15
16
  export interface ProcessedFile extends BaseFile {
16
17
  fileName: string;
17
18
  luaAst?: lua.File;
19
+ sourceMapNode?: SourceNode;
18
20
  }
19
21
  export interface EmitFile extends BaseFile {
20
22
  outputPath: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typescript-to-lua",
3
- "version": "1.3.4",
3
+ "version": "1.4.2",
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/",
@@ -18,13 +18,14 @@
18
18
  "dist/**/*.js",
19
19
  "dist/**/*.lua",
20
20
  "dist/**/*.ts",
21
+ "dist/lualib/*.json",
21
22
  "language-extensions/**/*.ts"
22
23
  ],
23
24
  "main": "dist/index.js",
24
25
  "types": "dist/index.d.ts",
25
26
  "scripts": {
26
27
  "build": "tsc && npm run build-lualib",
27
- "build-lualib": "node build-lualib.js",
28
+ "build-lualib": "node dist/tstl.js -p src/lualib/tsconfig.json",
28
29
  "pretest": "npm run lint && npm run check:language-extensions && npm run build-lualib",
29
30
  "test": "jest",
30
31
  "lint": "npm run lint:eslint && npm run lint:prettier",
@@ -42,7 +43,7 @@
42
43
  "node": ">=12.13.0"
43
44
  },
44
45
  "peerDependencies": {
45
- "typescript": "~4.5.2"
46
+ "typescript": "~4.6.2"
46
47
  },
47
48
  "dependencies": {
48
49
  "enhanced-resolve": "^5.8.2",
@@ -52,14 +53,14 @@
52
53
  "devDependencies": {
53
54
  "@types/fs-extra": "^8.1.0",
54
55
  "@types/glob": "^7.1.1",
55
- "@types/jest": "^25.1.3",
56
+ "@types/jest": "^27.4.1",
56
57
  "@types/node": "^13.7.7",
57
58
  "@types/resolve": "1.14.0",
58
- "@typescript-eslint/eslint-plugin": "^5.4.0",
59
- "@typescript-eslint/parser": "^5.4.0",
60
- "eslint": "^7.32.0",
61
- "eslint-plugin-import": "^2.24.2",
62
- "eslint-plugin-jest": "^24.4.0",
59
+ "@typescript-eslint/eslint-plugin": "^5.13.0",
60
+ "@typescript-eslint/parser": "^5.13.0",
61
+ "eslint": "^8.10.0",
62
+ "eslint-plugin-import": "^2.25.4",
63
+ "eslint-plugin-jest": "^26.1.1",
63
64
  "fs-extra": "^8.1.0",
64
65
  "javascript-stringify": "^2.0.1",
65
66
  "jest": "^27.3.0",
@@ -67,8 +68,8 @@
67
68
  "lua-types": "2.10.1",
68
69
  "lua-wasm-bindings": "^0.2.2",
69
70
  "prettier": "^2.3.2",
70
- "ts-jest": "^27.0.7",
71
+ "ts-jest": "^27.1.3",
71
72
  "ts-node": "^10.3.0",
72
- "typescript": "~4.5.2"
73
+ "typescript": "~4.6.2"
73
74
  }
74
75
  }