typescript-to-lua 1.3.2 → 1.4.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 (135) hide show
  1. package/dist/CompilerOptions.d.ts +1 -1
  2. package/dist/CompilerOptions.js +0 -1
  3. package/dist/LuaLib.d.ts +12 -1
  4. package/dist/LuaLib.js +61 -65
  5. package/dist/LuaPrinter.js +9 -8
  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/ArrayIncludes.lua +1 -1
  19. package/dist/lualib/ArrayIndexOf.lua +1 -1
  20. package/dist/lualib/ArrayIsArray.lua +1 -1
  21. package/dist/lualib/ArrayJoin.lua +1 -1
  22. package/dist/lualib/ArrayMap.lua +2 -2
  23. package/dist/lualib/ArrayPush.lua +1 -1
  24. package/dist/lualib/ArrayReduce.lua +2 -2
  25. package/dist/lualib/ArrayReduceRight.lua +2 -2
  26. package/dist/lualib/ArrayReverse.lua +1 -1
  27. package/dist/lualib/ArraySetLength.lua +1 -1
  28. package/dist/lualib/ArrayShift.lua +1 -1
  29. package/dist/lualib/ArraySlice.lua +1 -1
  30. package/dist/lualib/ArraySome.lua +2 -2
  31. package/dist/lualib/ArraySort.lua +2 -2
  32. package/dist/lualib/ArraySplice.lua +1 -1
  33. package/dist/lualib/ArrayToObject.lua +1 -1
  34. package/dist/lualib/ArrayUnshift.lua +1 -1
  35. package/dist/lualib/Await.lua +13 -13
  36. package/dist/lualib/Class.lua +1 -1
  37. package/dist/lualib/ClassExtends.lua +1 -1
  38. package/dist/lualib/CloneDescriptor.lua +1 -1
  39. package/dist/lualib/Decorate.lua +5 -5
  40. package/dist/lualib/DecorateParam.lua +2 -2
  41. package/dist/lualib/DelegatedYield.lua +1 -1
  42. package/dist/lualib/Delete.lua +1 -1
  43. package/dist/lualib/Error.lua +68 -69
  44. package/dist/lualib/FunctionBind.lua +1 -1
  45. package/dist/lualib/Generator.lua +26 -23
  46. package/dist/lualib/InstanceOf.lua +1 -1
  47. package/dist/lualib/InstanceOfObject.lua +1 -1
  48. package/dist/lualib/Iterator.lua +35 -32
  49. package/dist/lualib/Map.lua +131 -129
  50. package/dist/lualib/MathAtan2.lua +1 -1
  51. package/dist/lualib/MathSign.lua +1 -1
  52. package/dist/lualib/New.lua +1 -1
  53. package/dist/lualib/Number.lua +1 -1
  54. package/dist/lualib/NumberIsFinite.lua +1 -1
  55. package/dist/lualib/NumberIsNaN.lua +1 -1
  56. package/dist/lualib/NumberToString.lua +42 -39
  57. package/dist/lualib/ObjectAssign.lua +1 -1
  58. package/dist/lualib/ObjectDefineProperty.lua +1 -1
  59. package/dist/lualib/ObjectEntries.lua +1 -1
  60. package/dist/lualib/ObjectFromEntries.lua +1 -1
  61. package/dist/lualib/ObjectGetOwnPropertyDescriptor.lua +1 -1
  62. package/dist/lualib/ObjectGetOwnPropertyDescriptors.lua +1 -1
  63. package/dist/lualib/ObjectKeys.lua +1 -1
  64. package/dist/lualib/ObjectRest.lua +1 -1
  65. package/dist/lualib/ObjectValues.lua +1 -1
  66. package/dist/lualib/ParseFloat.lua +1 -1
  67. package/dist/lualib/ParseInt.lua +39 -36
  68. package/dist/lualib/Promise.lua +148 -152
  69. package/dist/lualib/PromiseAll.lua +5 -5
  70. package/dist/lualib/PromiseAllSettled.lua +5 -5
  71. package/dist/lualib/PromiseAny.lua +5 -5
  72. package/dist/lualib/PromiseRace.lua +5 -5
  73. package/dist/lualib/Set.lua +120 -118
  74. package/dist/lualib/SetDescriptor.lua +67 -64
  75. package/dist/lualib/SourceMapTraceBack.lua +7 -6
  76. package/dist/lualib/SparseArrayNew.lua +1 -1
  77. package/dist/lualib/SparseArrayPush.lua +1 -1
  78. package/dist/lualib/SparseArraySpread.lua +1 -1
  79. package/dist/lualib/Spread.lua +1 -1
  80. package/dist/lualib/StringAccess.lua +1 -1
  81. package/dist/lualib/StringCharAt.lua +1 -1
  82. package/dist/lualib/StringCharCodeAt.lua +1 -1
  83. package/dist/lualib/StringConcat.lua +1 -1
  84. package/dist/lualib/StringEndsWith.lua +1 -1
  85. package/dist/lualib/StringIncludes.lua +1 -1
  86. package/dist/lualib/StringPadEnd.lua +1 -1
  87. package/dist/lualib/StringPadStart.lua +1 -1
  88. package/dist/lualib/StringReplace.lua +2 -2
  89. package/dist/lualib/StringReplaceAll.lua +4 -4
  90. package/dist/lualib/StringSlice.lua +1 -1
  91. package/dist/lualib/StringSplit.lua +1 -1
  92. package/dist/lualib/StringStartsWith.lua +1 -1
  93. package/dist/lualib/StringSubstr.lua +1 -1
  94. package/dist/lualib/StringSubstring.lua +1 -1
  95. package/dist/lualib/StringTrim.lua +1 -1
  96. package/dist/lualib/StringTrimEnd.lua +1 -1
  97. package/dist/lualib/StringTrimStart.lua +1 -1
  98. package/dist/lualib/Symbol.lua +14 -11
  99. package/dist/lualib/SymbolRegistry.lua +13 -10
  100. package/dist/lualib/TypeOf.lua +1 -1
  101. package/dist/lualib/Unpack.lua +1 -1
  102. package/dist/lualib/WeakMap.lua +41 -39
  103. package/dist/lualib/WeakSet.lua +37 -35
  104. package/dist/lualib/lualib_bundle.lua +1054 -924
  105. package/dist/lualib/lualib_module_info.json +619 -0
  106. package/dist/lualib-build/plugin.d.ts +23 -0
  107. package/dist/lualib-build/plugin.js +138 -0
  108. package/dist/lualib-build/util.d.ts +19 -0
  109. package/dist/lualib-build/util.js +43 -0
  110. package/dist/transformation/builtins/function.js +2 -1
  111. package/dist/transformation/builtins/index.d.ts +1 -0
  112. package/dist/transformation/builtins/index.js +63 -16
  113. package/dist/transformation/context/index.js +5 -1
  114. package/dist/transformation/utils/diagnostics.d.ts +3 -0
  115. package/dist/transformation/utils/diagnostics.js +2 -1
  116. package/dist/transformation/utils/typescript/index.js +5 -1
  117. package/dist/transformation/utils/typescript/types.d.ts +2 -0
  118. package/dist/transformation/utils/typescript/types.js +10 -1
  119. package/dist/transformation/visitors/class/index.js +1 -5
  120. package/dist/transformation/visitors/class/members/constructor.js +1 -3
  121. package/dist/transformation/visitors/class/members/fields.js +12 -8
  122. package/dist/transformation/visitors/class/new.d.ts +1 -2
  123. package/dist/transformation/visitors/class/new.js +1 -40
  124. package/dist/transformation/visitors/conditional.js +15 -14
  125. package/dist/transformation/visitors/identifier.js +5 -0
  126. package/dist/transformation/visitors/literal.js +22 -0
  127. package/dist/transformation/visitors/modules/import.js +4 -14
  128. package/dist/transpilation/bundle.js +1 -1
  129. package/dist/transpilation/index.js +5 -1
  130. package/dist/transpilation/plugins.d.ts +11 -0
  131. package/dist/transpilation/resolve.js +2 -2
  132. package/dist/transpilation/transpile.js +13 -0
  133. package/dist/transpilation/transpiler.js +6 -2
  134. package/package.json +12 -11
  135. package/CHANGELOG.md +0 -703
@@ -1,11 +1,11 @@
1
- function __TS__PromiseAny(iterable)
1
+ local function __TS__PromiseAny(iterable)
2
2
  local rejections = {}
3
3
  local pending = {}
4
4
  for ____, item in __TS__Iterator(iterable) do
5
5
  if __TS__InstanceOf(item, __TS__Promise) then
6
- if item.state == __TS__PromiseState.Fulfilled then
6
+ if item.state == 1 then
7
7
  return __TS__Promise.resolve(item.value)
8
- elseif item.state == __TS__PromiseState.Rejected then
8
+ elseif item.state == 2 then
9
9
  __TS__ArrayPush(rejections, item.rejectionReason)
10
10
  else
11
11
  __TS__ArrayPush(pending, item)
@@ -25,13 +25,13 @@ function __TS__PromiseAny(iterable)
25
25
  promise["then"](
26
26
  promise,
27
27
  function(____, data)
28
- resolve(_G, data)
28
+ resolve(nil, data)
29
29
  end,
30
30
  function(____, reason)
31
31
  __TS__ArrayPush(rejections, reason)
32
32
  numResolved = numResolved + 1
33
33
  if numResolved == #pending then
34
- reject(_G, {name = "AggregateError", message = "All Promises rejected", errors = rejections})
34
+ reject(nil, {name = "AggregateError", message = "All Promises rejected", errors = rejections})
35
35
  end
36
36
  end
37
37
  )
@@ -1,10 +1,10 @@
1
- function __TS__PromiseRace(iterable)
1
+ local function __TS__PromiseRace(iterable)
2
2
  local pending = {}
3
3
  for ____, item in __TS__Iterator(iterable) do
4
4
  if __TS__InstanceOf(item, __TS__Promise) then
5
- if item.state == __TS__PromiseState.Fulfilled then
5
+ if item.state == 1 then
6
6
  return __TS__Promise.resolve(item.value)
7
- elseif item.state == __TS__PromiseState.Rejected then
7
+ elseif item.state == 2 then
8
8
  return __TS__Promise.reject(item.rejectionReason)
9
9
  else
10
10
  __TS__ArrayPush(pending, item)
@@ -19,8 +19,8 @@ function __TS__PromiseRace(iterable)
19
19
  for ____, promise in ipairs(pending) do
20
20
  promise["then"](
21
21
  promise,
22
- function(____, value) return resolve(_G, value) end,
23
- function(____, reason) return reject(_G, reason) end
22
+ function(____, value) return resolve(nil, value) end,
23
+ function(____, reason) return reject(nil, reason) end
24
24
  )
25
25
  end
26
26
  end
@@ -1,128 +1,130 @@
1
- Set = __TS__Class()
2
- Set.name = "Set"
3
- function Set.prototype.____constructor(self, values)
4
- self[Symbol.toStringTag] = "Set"
5
- self.size = 0
6
- self.nextKey = {}
7
- self.previousKey = {}
8
- if values == nil then
9
- return
10
- end
11
- local iterable = values
12
- if iterable[Symbol.iterator] then
13
- local iterator = iterable[Symbol.iterator](iterable)
14
- while true do
15
- local result = iterator:next()
16
- if result.done then
17
- break
1
+ local Set
2
+ do
3
+ Set = __TS__Class()
4
+ Set.name = "Set"
5
+ function Set.prototype.____constructor(self, values)
6
+ self[Symbol.toStringTag] = "Set"
7
+ self.size = 0
8
+ self.nextKey = {}
9
+ self.previousKey = {}
10
+ if values == nil then
11
+ return
12
+ end
13
+ local iterable = values
14
+ if iterable[Symbol.iterator] then
15
+ local iterator = iterable[Symbol.iterator](iterable)
16
+ while true do
17
+ local result = iterator:next()
18
+ if result.done then
19
+ break
20
+ end
21
+ self:add(result.value)
22
+ end
23
+ else
24
+ local array = values
25
+ for ____, value in ipairs(array) do
26
+ self:add(value)
18
27
  end
19
- self:add(result.value)
20
28
  end
21
- else
22
- local array = values
23
- for ____, value in ipairs(array) do
24
- self:add(value)
29
+ end
30
+ function Set.prototype.add(self, value)
31
+ local isNewValue = not self:has(value)
32
+ if isNewValue then
33
+ self.size = self.size + 1
34
+ end
35
+ if self.firstKey == nil then
36
+ self.firstKey = value
37
+ self.lastKey = value
38
+ elseif isNewValue then
39
+ self.nextKey[self.lastKey] = value
40
+ self.previousKey[value] = self.lastKey
41
+ self.lastKey = value
25
42
  end
43
+ return self
26
44
  end
27
- end
28
- function Set.prototype.add(self, value)
29
- local isNewValue = not self:has(value)
30
- if isNewValue then
31
- self.size = self.size + 1
45
+ function Set.prototype.clear(self)
46
+ self.nextKey = {}
47
+ self.previousKey = {}
48
+ self.firstKey = nil
49
+ self.lastKey = nil
50
+ self.size = 0
32
51
  end
33
- if self.firstKey == nil then
34
- self.firstKey = value
35
- self.lastKey = value
36
- elseif isNewValue then
37
- self.nextKey[self.lastKey] = value
38
- self.previousKey[value] = self.lastKey
39
- self.lastKey = value
52
+ function Set.prototype.delete(self, value)
53
+ local contains = self:has(value)
54
+ if contains then
55
+ self.size = self.size - 1
56
+ local next = self.nextKey[value]
57
+ local previous = self.previousKey[value]
58
+ if next and previous then
59
+ self.nextKey[previous] = next
60
+ self.previousKey[next] = previous
61
+ elseif next then
62
+ self.firstKey = next
63
+ self.previousKey[next] = nil
64
+ elseif previous then
65
+ self.lastKey = previous
66
+ self.nextKey[previous] = nil
67
+ else
68
+ self.firstKey = nil
69
+ self.lastKey = nil
70
+ end
71
+ self.nextKey[value] = nil
72
+ self.previousKey[value] = nil
73
+ end
74
+ return contains
40
75
  end
41
- return self
42
- end
43
- function Set.prototype.clear(self)
44
- self.nextKey = {}
45
- self.previousKey = {}
46
- self.firstKey = nil
47
- self.lastKey = nil
48
- self.size = 0
49
- end
50
- function Set.prototype.delete(self, value)
51
- local contains = self:has(value)
52
- if contains then
53
- self.size = self.size - 1
54
- local next = self.nextKey[value]
55
- local previous = self.previousKey[value]
56
- if next and previous then
57
- self.nextKey[previous] = next
58
- self.previousKey[next] = previous
59
- elseif next then
60
- self.firstKey = next
61
- self.previousKey[next] = nil
62
- elseif previous then
63
- self.lastKey = previous
64
- self.nextKey[previous] = nil
65
- else
66
- self.firstKey = nil
67
- self.lastKey = nil
76
+ function Set.prototype.forEach(self, callback)
77
+ for ____, key in __TS__Iterator(self:keys()) do
78
+ callback(nil, key, key, self)
68
79
  end
69
- self.nextKey[value] = nil
70
- self.previousKey[value] = nil
71
80
  end
72
- return contains
73
- end
74
- function Set.prototype.forEach(self, callback)
75
- for ____, key in __TS__Iterator(self:keys()) do
76
- callback(_G, key, key, self)
81
+ function Set.prototype.has(self, value)
82
+ return self.nextKey[value] ~= nil or self.lastKey == value
77
83
  end
84
+ Set.prototype[Symbol.iterator] = function(self)
85
+ return self:values()
86
+ end
87
+ function Set.prototype.entries(self)
88
+ local nextKey = self.nextKey
89
+ local key = self.firstKey
90
+ return {
91
+ [Symbol.iterator] = function(self)
92
+ return self
93
+ end,
94
+ next = function(self)
95
+ local result = {done = not key, value = {key, key}}
96
+ key = nextKey[key]
97
+ return result
98
+ end
99
+ }
100
+ end
101
+ function Set.prototype.keys(self)
102
+ local nextKey = self.nextKey
103
+ local key = self.firstKey
104
+ return {
105
+ [Symbol.iterator] = function(self)
106
+ return self
107
+ end,
108
+ next = function(self)
109
+ local result = {done = not key, value = key}
110
+ key = nextKey[key]
111
+ return result
112
+ end
113
+ }
114
+ end
115
+ function Set.prototype.values(self)
116
+ local nextKey = self.nextKey
117
+ local key = self.firstKey
118
+ return {
119
+ [Symbol.iterator] = function(self)
120
+ return self
121
+ end,
122
+ next = function(self)
123
+ local result = {done = not key, value = key}
124
+ key = nextKey[key]
125
+ return result
126
+ end
127
+ }
128
+ end
129
+ Set[Symbol.species] = Set
78
130
  end
79
- function Set.prototype.has(self, value)
80
- return self.nextKey[value] ~= nil or self.lastKey == value
81
- end
82
- Set.prototype[Symbol.iterator] = function(self)
83
- return self:values()
84
- end
85
- function Set.prototype.entries(self)
86
- local nextKey = self.nextKey
87
- local key = self.firstKey
88
- return {
89
- [Symbol.iterator] = function(self)
90
- return self
91
- end,
92
- next = function(self)
93
- local result = {done = not key, value = {key, key}}
94
- key = nextKey[key]
95
- return result
96
- end
97
- }
98
- end
99
- function Set.prototype.keys(self)
100
- local nextKey = self.nextKey
101
- local key = self.firstKey
102
- return {
103
- [Symbol.iterator] = function(self)
104
- return self
105
- end,
106
- next = function(self)
107
- local result = {done = not key, value = key}
108
- key = nextKey[key]
109
- return result
110
- end
111
- }
112
- end
113
- function Set.prototype.values(self)
114
- local nextKey = self.nextKey
115
- local key = self.firstKey
116
- return {
117
- [Symbol.iterator] = function(self)
118
- return self
119
- end,
120
- next = function(self)
121
- local result = {done = not key, value = key}
122
- key = nextKey[key]
123
- return result
124
- end
125
- }
126
- end
127
- Set[Symbol.species] = Set
128
- Set = Set
@@ -1,76 +1,79 @@
1
- function ____descriptorIndex(self, key)
2
- local value = rawget(self, key)
3
- if value ~= nil then
4
- return value
5
- end
6
- local metatable = getmetatable(self)
7
- while metatable do
8
- local rawResult = rawget(metatable, key)
9
- if rawResult ~= nil then
10
- return rawResult
1
+ local __TS__SetDescriptor
2
+ do
3
+ local function descriptorIndex(self, key)
4
+ local value = rawget(self, key)
5
+ if value ~= nil then
6
+ return value
11
7
  end
12
- local descriptors = rawget(metatable, "_descriptors")
13
- if descriptors then
14
- local descriptor = descriptors[key]
15
- if descriptor then
16
- if descriptor.get then
17
- return descriptor.get(self)
8
+ local metatable = getmetatable(self)
9
+ while metatable do
10
+ local rawResult = rawget(metatable, key)
11
+ if rawResult ~= nil then
12
+ return rawResult
13
+ end
14
+ local descriptors = rawget(metatable, "_descriptors")
15
+ if descriptors then
16
+ local descriptor = descriptors[key]
17
+ if descriptor then
18
+ if descriptor.get then
19
+ return descriptor.get(self)
20
+ end
21
+ return descriptor.value
18
22
  end
19
- return descriptor.value
20
23
  end
24
+ metatable = getmetatable(metatable)
21
25
  end
22
- metatable = getmetatable(metatable)
23
26
  end
24
- end
25
- function ____descriptorNewindex(self, key, value)
26
- local metatable = getmetatable(self)
27
- while metatable do
28
- local descriptors = rawget(metatable, "_descriptors")
29
- if descriptors then
30
- local descriptor = descriptors[key]
31
- if descriptor then
32
- if descriptor.set then
33
- descriptor.set(self, value)
34
- else
35
- if descriptor.writable == false then
36
- error(
37
- ((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
38
- 0
39
- )
27
+ local function descriptorNewIndex(self, key, value)
28
+ local metatable = getmetatable(self)
29
+ while metatable do
30
+ local descriptors = rawget(metatable, "_descriptors")
31
+ if descriptors then
32
+ local descriptor = descriptors[key]
33
+ if descriptor then
34
+ if descriptor.set then
35
+ descriptor.set(self, value)
36
+ else
37
+ if descriptor.writable == false then
38
+ error(
39
+ ((("Cannot assign to read only property '" .. key) .. "' of object '") .. tostring(self)) .. "'",
40
+ 0
41
+ )
42
+ end
43
+ descriptor.value = value
40
44
  end
41
- descriptor.value = value
45
+ return
42
46
  end
43
- return
44
47
  end
48
+ metatable = getmetatable(metatable)
45
49
  end
46
- metatable = getmetatable(metatable)
47
- end
48
- rawset(self, key, value)
49
- end
50
- function __TS__SetDescriptor(target, key, desc, isPrototype)
51
- if isPrototype == nil then
52
- isPrototype = false
53
- end
54
- local ____isPrototype_0
55
- if isPrototype then
56
- ____isPrototype_0 = target
57
- else
58
- ____isPrototype_0 = getmetatable(target)
50
+ rawset(self, key, value)
59
51
  end
60
- local metatable = ____isPrototype_0
61
- if not metatable then
62
- metatable = {}
63
- setmetatable(target, metatable)
64
- end
65
- local value = rawget(target, key)
66
- if value ~= nil then
67
- rawset(target, key, nil)
68
- end
69
- if not rawget(metatable, "_descriptors") then
70
- metatable._descriptors = {}
52
+ function __TS__SetDescriptor(target, key, desc, isPrototype)
53
+ if isPrototype == nil then
54
+ isPrototype = false
55
+ end
56
+ local ____isPrototype_0
57
+ if isPrototype then
58
+ ____isPrototype_0 = target
59
+ else
60
+ ____isPrototype_0 = getmetatable(target)
61
+ end
62
+ local metatable = ____isPrototype_0
63
+ if not metatable then
64
+ metatable = {}
65
+ setmetatable(target, metatable)
66
+ end
67
+ local value = rawget(target, key)
68
+ if value ~= nil then
69
+ rawset(target, key, nil)
70
+ end
71
+ if not rawget(metatable, "_descriptors") then
72
+ metatable._descriptors = {}
73
+ end
74
+ local descriptor = __TS__CloneDescriptor(desc)
75
+ metatable._descriptors[key] = descriptor
76
+ metatable.__index = descriptorIndex
77
+ metatable.__newindex = descriptorNewIndex
71
78
  end
72
- local descriptor = __TS__CloneDescriptor(desc)
73
- metatable._descriptors[key] = descriptor
74
- metatable.__index = ____descriptorIndex
75
- metatable.__newindex = ____descriptorNewindex
76
79
  end
@@ -1,14 +1,15 @@
1
- function __TS__SourceMapTraceBack(fileName, sourceMap)
1
+ local function __TS__SourceMapTraceBack(fileName, sourceMap)
2
2
  _G.__TS__sourcemap = _G.__TS__sourcemap or ({})
3
3
  _G.__TS__sourcemap[fileName] = sourceMap
4
4
  if _G.__TS__originalTraceback == nil then
5
- _G.__TS__originalTraceback = debug.traceback
5
+ local originalTraceback = debug.traceback
6
+ _G.__TS__originalTraceback = originalTraceback
6
7
  debug.traceback = function(thread, message, level)
7
8
  local trace
8
9
  if thread == nil and message == nil and level == nil then
9
- trace = _G.__TS__originalTraceback()
10
+ trace = originalTraceback()
10
11
  else
11
- trace = _G.__TS__originalTraceback(thread, message, level)
12
+ trace = originalTraceback(thread, message, level)
12
13
  end
13
14
  if type(trace) ~= "string" then
14
15
  return trace
@@ -27,12 +28,12 @@ function __TS__SourceMapTraceBack(fileName, sourceMap)
27
28
  local result = string.gsub(
28
29
  trace,
29
30
  "(%S+)%.lua:(%d+)",
30
- function(file, line) return replacer(_G, file .. ".lua", file .. ".ts", line) end
31
+ function(file, line) return replacer(nil, file .. ".lua", file .. ".ts", line) end
31
32
  )
32
33
  result = string.gsub(
33
34
  result,
34
35
  "(%[string \"[^\"]+\"%]):(%d+)",
35
- function(file, line) return replacer(_G, file, "unknown", line) end
36
+ function(file, line) return replacer(nil, file, "unknown", line) end
36
37
  )
37
38
  return result
38
39
  end
@@ -1,4 +1,4 @@
1
- function __TS__SparseArrayNew(...)
1
+ local function __TS__SparseArrayNew(...)
2
2
  local sparseArray = {...}
3
3
  sparseArray.sparseLength = select("#", ...)
4
4
  return sparseArray
@@ -1,4 +1,4 @@
1
- function __TS__SparseArrayPush(sparseArray, ...)
1
+ local function __TS__SparseArrayPush(sparseArray, ...)
2
2
  local args = {...}
3
3
  local argsLen = select("#", ...)
4
4
  local listLen = sparseArray.sparseLength
@@ -1,4 +1,4 @@
1
- function __TS__SparseArraySpread(sparseArray)
1
+ local function __TS__SparseArraySpread(sparseArray)
2
2
  local _unpack = unpack or table.unpack
3
3
  return _unpack(sparseArray, 1, sparseArray.sparseLength)
4
4
  end
@@ -1,4 +1,4 @@
1
- function __TS__Spread(iterable)
1
+ local function __TS__Spread(iterable)
2
2
  local arr = {}
3
3
  if type(iterable) == "string" then
4
4
  do
@@ -1,4 +1,4 @@
1
- function __TS__StringAccess(self, index)
1
+ local function __TS__StringAccess(self, index)
2
2
  if index >= 0 and index < #self then
3
3
  return string.sub(self, index + 1, index + 1)
4
4
  end
@@ -1,4 +1,4 @@
1
- function __TS__StringCharAt(self, pos)
1
+ local function __TS__StringCharAt(self, pos)
2
2
  if pos ~= pos then
3
3
  pos = 0
4
4
  end
@@ -1,4 +1,4 @@
1
- function __TS__StringCharCodeAt(self, index)
1
+ local function __TS__StringCharCodeAt(self, index)
2
2
  if index ~= index then
3
3
  index = 0
4
4
  end
@@ -1,4 +1,4 @@
1
- function __TS__StringConcat(str1, ...)
1
+ local function __TS__StringConcat(str1, ...)
2
2
  local args = {...}
3
3
  local out = str1
4
4
  for ____, arg in ipairs(args) do
@@ -1,4 +1,4 @@
1
- function __TS__StringEndsWith(self, searchString, endPosition)
1
+ local function __TS__StringEndsWith(self, searchString, endPosition)
2
2
  if endPosition == nil or endPosition > #self then
3
3
  endPosition = #self
4
4
  end
@@ -1,4 +1,4 @@
1
- function __TS__StringIncludes(self, searchString, position)
1
+ local function __TS__StringIncludes(self, searchString, position)
2
2
  if not position then
3
3
  position = 1
4
4
  else
@@ -1,4 +1,4 @@
1
- function __TS__StringPadEnd(self, maxLength, fillString)
1
+ local function __TS__StringPadEnd(self, maxLength, fillString)
2
2
  if fillString == nil then
3
3
  fillString = " "
4
4
  end
@@ -1,4 +1,4 @@
1
- function __TS__StringPadStart(self, maxLength, fillString)
1
+ local function __TS__StringPadStart(self, maxLength, fillString)
2
2
  if fillString == nil then
3
3
  fillString = " "
4
4
  end
@@ -1,4 +1,4 @@
1
- function __TS__StringReplace(source, searchValue, replaceValue)
1
+ local function __TS__StringReplace(source, searchValue, replaceValue)
2
2
  local startPos, endPos = string.find(source, searchValue, nil, true)
3
3
  if not startPos then
4
4
  return source
@@ -9,7 +9,7 @@ function __TS__StringReplace(source, searchValue, replaceValue)
9
9
  if type(replaceValue) == "string" then
10
10
  ____temp_0 = replaceValue
11
11
  else
12
- ____temp_0 = replaceValue(_G, searchValue, startPos - 1, source)
12
+ ____temp_0 = replaceValue(nil, searchValue, startPos - 1, source)
13
13
  end
14
14
  local replacement = ____temp_0
15
15
  local after = sub(source, endPos + 1)
@@ -1,4 +1,4 @@
1
- function __TS__StringReplaceAll(source, searchValue, replaceValue)
1
+ local function __TS__StringReplaceAll(source, searchValue, replaceValue)
2
2
  local replacer
3
3
  if type(replaceValue) == "string" then
4
4
  replacer = function() return replaceValue end
@@ -9,11 +9,11 @@ function __TS__StringReplaceAll(source, searchValue, replaceValue)
9
9
  local partsIndex = 1
10
10
  local sub = string.sub
11
11
  if #searchValue == 0 then
12
- parts[1] = replacer(_G, "", 0, source)
12
+ parts[1] = replacer(nil, "", 0, source)
13
13
  partsIndex = 2
14
14
  for i = 1, #source do
15
15
  parts[partsIndex] = sub(source, i, i)
16
- parts[partsIndex + 1] = replacer(_G, "", i, source)
16
+ parts[partsIndex + 1] = replacer(nil, "", i, source)
17
17
  partsIndex = partsIndex + 2
18
18
  end
19
19
  else
@@ -25,7 +25,7 @@ function __TS__StringReplaceAll(source, searchValue, replaceValue)
25
25
  break
26
26
  end
27
27
  parts[partsIndex] = sub(source, currentPos, startPos - 1)
28
- parts[partsIndex + 1] = replacer(_G, searchValue, startPos - 1, source)
28
+ parts[partsIndex + 1] = replacer(nil, searchValue, startPos - 1, source)
29
29
  partsIndex = partsIndex + 2
30
30
  currentPos = endPos + 1
31
31
  end
@@ -1,4 +1,4 @@
1
- function __TS__StringSlice(self, start, ____end)
1
+ local function __TS__StringSlice(self, start, ____end)
2
2
  if start == nil or start ~= start then
3
3
  start = 0
4
4
  end
@@ -1,4 +1,4 @@
1
- function __TS__StringSplit(source, separator, limit)
1
+ local function __TS__StringSplit(source, separator, limit)
2
2
  if limit == nil then
3
3
  limit = 4294967295
4
4
  end
@@ -1,4 +1,4 @@
1
- function __TS__StringStartsWith(self, searchString, position)
1
+ local function __TS__StringStartsWith(self, searchString, position)
2
2
  if position == nil or position < 0 then
3
3
  position = 0
4
4
  end
@@ -1,4 +1,4 @@
1
- function __TS__StringSubstr(self, from, length)
1
+ local function __TS__StringSubstr(self, from, length)
2
2
  if from ~= from then
3
3
  from = 0
4
4
  end
@@ -1,4 +1,4 @@
1
- function __TS__StringSubstring(self, start, ____end)
1
+ local function __TS__StringSubstring(self, start, ____end)
2
2
  if ____end ~= ____end then
3
3
  ____end = 0
4
4
  end
@@ -1,4 +1,4 @@
1
- function __TS__StringTrim(self)
1
+ local function __TS__StringTrim(self)
2
2
  local result = string.gsub(self, "^[%s ]*(.-)[%s ]*$", "%1")
3
3
  return result
4
4
  end