typescript-to-lua 1.4.3 → 1.4.4

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.
@@ -30,10 +30,23 @@ local function __TS__SourceMapTraceBack(fileName, sourceMap)
30
30
  "(%S+)%.lua:(%d+)",
31
31
  function(file, line) return replacer(nil, file .. ".lua", file .. ".ts", line) end
32
32
  )
33
+ local function stringReplacer(____, file, line)
34
+ local fileSourceMap = _G.__TS__sourcemap[file]
35
+ if fileSourceMap and fileSourceMap[line] then
36
+ local chunkName = string.match(file, "%[string \"([^\"]+)\"%]")
37
+ local sourceName = string.gsub(chunkName, ".lua$", ".ts")
38
+ local data = fileSourceMap[line]
39
+ if type(data) == "number" then
40
+ return (sourceName .. ":") .. tostring(data)
41
+ end
42
+ return (tostring(data.file) .. ":") .. tostring(data.line)
43
+ end
44
+ return (file .. ":") .. line
45
+ end
33
46
  result = string.gsub(
34
47
  result,
35
48
  "(%[string \"[^\"]+\"%]):(%d+)",
36
- function(file, line) return replacer(nil, file, "unknown", line) end
49
+ function(file, line) return stringReplacer(nil, file, line) end
37
50
  )
38
51
  return result
39
52
  end
@@ -2083,10 +2083,23 @@ local function __TS__SourceMapTraceBack(fileName, sourceMap)
2083
2083
  "(%S+)%.lua:(%d+)",
2084
2084
  function(file, line) return replacer(nil, file .. ".lua", file .. ".ts", line) end
2085
2085
  )
2086
+ local function stringReplacer(____, file, line)
2087
+ local fileSourceMap = _G.__TS__sourcemap[file]
2088
+ if fileSourceMap and fileSourceMap[line] then
2089
+ local chunkName = string.match(file, "%[string \"([^\"]+)\"%]")
2090
+ local sourceName = string.gsub(chunkName, ".lua$", ".ts")
2091
+ local data = fileSourceMap[line]
2092
+ if type(data) == "number" then
2093
+ return (sourceName .. ":") .. tostring(data)
2094
+ end
2095
+ return (tostring(data.file) .. ":") .. tostring(data.line)
2096
+ end
2097
+ return (file .. ":") .. line
2098
+ end
2086
2099
  result = string.gsub(
2087
2100
  result,
2088
2101
  "(%[string \"[^\"]+\"%]):(%d+)",
2089
- function(file, line) return replacer(nil, file, "unknown", line) end
2102
+ function(file, line) return stringReplacer(nil, file, line) end
2090
2103
  )
2091
2104
  return result
2092
2105
  end
@@ -39,9 +39,9 @@ function findFirstNodeAbove(node, callback) {
39
39
  }
40
40
  exports.findFirstNodeAbove = findFirstNodeAbove;
41
41
  function findFirstNonOuterParent(node) {
42
- let current = node.parent;
42
+ let current = ts.getOriginalNode(node).parent;
43
43
  while (ts.isOuterExpression(current)) {
44
- current = current.parent;
44
+ current = ts.getOriginalNode(current).parent;
45
45
  }
46
46
  return current;
47
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typescript-to-lua",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
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/",