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
@@ -1,176 +1,172 @@
1
- __TS__PromiseState = __TS__PromiseState or ({})
2
- __TS__PromiseState.Pending = 0
3
- __TS__PromiseState[__TS__PromiseState.Pending] = "Pending"
4
- __TS__PromiseState.Fulfilled = 1
5
- __TS__PromiseState[__TS__PromiseState.Fulfilled] = "Fulfilled"
6
- __TS__PromiseState.Rejected = 2
7
- __TS__PromiseState[__TS__PromiseState.Rejected] = "Rejected"
8
- function __TS__PromiseDeferred(self)
9
- local resolve
10
- local reject
11
- local promise = __TS__New(
12
- __TS__Promise,
13
- function(____, res, rej)
14
- resolve = res
15
- reject = rej
16
- end
17
- )
18
- return {promise = promise, resolve = resolve, reject = reject}
19
- end
20
- function __TS__IsPromiseLike(self, thing)
21
- return __TS__InstanceOf(thing, __TS__Promise)
22
- end
23
- __TS__Promise = __TS__Class()
24
- __TS__Promise.name = "__TS__Promise"
25
- function __TS__Promise.prototype.____constructor(self, executor)
26
- self.state = __TS__PromiseState.Pending
27
- self.fulfilledCallbacks = {}
28
- self.rejectedCallbacks = {}
29
- self.finallyCallbacks = {}
30
- do
31
- local function ____catch(e)
32
- self:reject(e)
33
- end
34
- local ____try, ____hasReturned = pcall(function()
35
- executor(
36
- _G,
37
- __TS__FunctionBind(self.resolve, self),
38
- __TS__FunctionBind(self.reject, self)
39
- )
40
- end)
41
- if not ____try then
42
- ____catch(____hasReturned)
1
+ local __TS__Promise
2
+ do
3
+ local function promiseDeferred(self)
4
+ local resolve
5
+ local reject
6
+ local promise = __TS__New(
7
+ __TS__Promise,
8
+ function(____, res, rej)
9
+ resolve = res
10
+ reject = rej
11
+ end
12
+ )
13
+ return {promise = promise, resolve = resolve, reject = reject}
14
+ end
15
+ local function isPromiseLike(self, thing)
16
+ return __TS__InstanceOf(thing, __TS__Promise)
17
+ end
18
+ __TS__Promise = __TS__Class()
19
+ __TS__Promise.name = "__TS__Promise"
20
+ function __TS__Promise.prototype.____constructor(self, executor)
21
+ self.state = 0
22
+ self.fulfilledCallbacks = {}
23
+ self.rejectedCallbacks = {}
24
+ self.finallyCallbacks = {}
25
+ do
26
+ local function ____catch(e)
27
+ self:reject(e)
28
+ end
29
+ local ____try, ____hasReturned = pcall(function()
30
+ executor(
31
+ nil,
32
+ __TS__FunctionBind(self.resolve, self),
33
+ __TS__FunctionBind(self.reject, self)
34
+ )
35
+ end)
36
+ if not ____try then
37
+ ____catch(____hasReturned)
38
+ end
43
39
  end
44
40
  end
45
- end
46
- function __TS__Promise.resolve(data)
47
- local promise = __TS__New(
48
- __TS__Promise,
49
- function()
41
+ function __TS__Promise.resolve(data)
42
+ local promise = __TS__New(
43
+ __TS__Promise,
44
+ function()
45
+ end
46
+ )
47
+ promise.state = 1
48
+ promise.value = data
49
+ return promise
50
+ end
51
+ function __TS__Promise.reject(reason)
52
+ local promise = __TS__New(
53
+ __TS__Promise,
54
+ function()
55
+ end
56
+ )
57
+ promise.state = 2
58
+ promise.rejectionReason = reason
59
+ return promise
60
+ end
61
+ __TS__Promise.prototype["then"] = function(self, onFulfilled, onRejected)
62
+ local ____promiseDeferred_result_0 = promiseDeferred(nil)
63
+ local promise = ____promiseDeferred_result_0.promise
64
+ local resolve = ____promiseDeferred_result_0.resolve
65
+ local reject = ____promiseDeferred_result_0.reject
66
+ local isFulfilled = self.state == 1
67
+ local isRejected = self.state == 2
68
+ if onFulfilled then
69
+ local internalCallback = self:createPromiseResolvingCallback(onFulfilled, resolve, reject)
70
+ __TS__ArrayPush(self.fulfilledCallbacks, internalCallback)
71
+ if isFulfilled then
72
+ internalCallback(nil, self.value)
73
+ end
74
+ else
75
+ __TS__ArrayPush(
76
+ self.fulfilledCallbacks,
77
+ function() return resolve(nil, nil) end
78
+ )
50
79
  end
51
- )
52
- promise.state = __TS__PromiseState.Fulfilled
53
- promise.value = data
54
- return promise
55
- end
56
- function __TS__Promise.reject(reason)
57
- local promise = __TS__New(
58
- __TS__Promise,
59
- function()
80
+ if onRejected then
81
+ local internalCallback = self:createPromiseResolvingCallback(onRejected, resolve, reject)
82
+ __TS__ArrayPush(self.rejectedCallbacks, internalCallback)
83
+ if isRejected then
84
+ internalCallback(nil, self.rejectionReason)
85
+ end
60
86
  end
61
- )
62
- promise.state = __TS__PromiseState.Rejected
63
- promise.rejectionReason = reason
64
- return promise
65
- end
66
- __TS__Promise.prototype["then"] = function(self, onFulfilled, onRejected)
67
- local ____TS__PromiseDeferred_result_0 = __TS__PromiseDeferred(_G)
68
- local promise = ____TS__PromiseDeferred_result_0.promise
69
- local resolve = ____TS__PromiseDeferred_result_0.resolve
70
- local reject = ____TS__PromiseDeferred_result_0.reject
71
- local isFulfilled = self.state == __TS__PromiseState.Fulfilled
72
- local isRejected = self.state == __TS__PromiseState.Rejected
73
- if onFulfilled then
74
- local internalCallback = self:createPromiseResolvingCallback(onFulfilled, resolve, reject)
75
- __TS__ArrayPush(self.fulfilledCallbacks, internalCallback)
76
87
  if isFulfilled then
77
- internalCallback(_G, self.value)
88
+ resolve(nil, self.value)
78
89
  end
79
- else
80
- __TS__ArrayPush(
81
- self.fulfilledCallbacks,
82
- function() return resolve(_G, nil) end
83
- )
84
- end
85
- if onRejected then
86
- local internalCallback = self:createPromiseResolvingCallback(onRejected, resolve, reject)
87
- __TS__ArrayPush(self.rejectedCallbacks, internalCallback)
88
90
  if isRejected then
89
- internalCallback(_G, self.rejectionReason)
91
+ reject(nil, self.rejectionReason)
90
92
  end
93
+ return promise
91
94
  end
92
- if isFulfilled then
93
- resolve(_G, self.value)
95
+ function __TS__Promise.prototype.catch(self, onRejected)
96
+ return self["then"](self, nil, onRejected)
94
97
  end
95
- if isRejected then
96
- reject(_G, self.rejectionReason)
97
- end
98
- return promise
99
- end
100
- function __TS__Promise.prototype.catch(self, onRejected)
101
- return self["then"](self, nil, onRejected)
102
- end
103
- function __TS__Promise.prototype.finally(self, onFinally)
104
- if onFinally then
105
- __TS__ArrayPush(self.finallyCallbacks, onFinally)
106
- if self.state ~= __TS__PromiseState.Pending then
107
- onFinally(_G)
98
+ function __TS__Promise.prototype.finally(self, onFinally)
99
+ if onFinally then
100
+ __TS__ArrayPush(self.finallyCallbacks, onFinally)
101
+ if self.state ~= 0 then
102
+ onFinally(nil)
103
+ end
108
104
  end
105
+ return self
109
106
  end
110
- return self
111
- end
112
- function __TS__Promise.prototype.resolve(self, data)
113
- if __TS__InstanceOf(data, __TS__Promise) then
114
- data["then"](
115
- data,
116
- function(____, v) return self:resolve(v) end,
117
- function(____, err) return self:reject(err) end
118
- )
119
- return
120
- end
121
- if self.state == __TS__PromiseState.Pending then
122
- self.state = __TS__PromiseState.Fulfilled
123
- self.value = data
124
- for ____, callback in ipairs(self.fulfilledCallbacks) do
125
- callback(_G, data)
107
+ function __TS__Promise.prototype.resolve(self, data)
108
+ if __TS__InstanceOf(data, __TS__Promise) then
109
+ data["then"](
110
+ data,
111
+ function(____, v) return self:resolve(v) end,
112
+ function(____, err) return self:reject(err) end
113
+ )
114
+ return
126
115
  end
127
- for ____, callback in ipairs(self.finallyCallbacks) do
128
- callback(_G)
116
+ if self.state == 0 then
117
+ self.state = 1
118
+ self.value = data
119
+ for ____, callback in ipairs(self.fulfilledCallbacks) do
120
+ callback(nil, data)
121
+ end
122
+ for ____, callback in ipairs(self.finallyCallbacks) do
123
+ callback(nil)
124
+ end
129
125
  end
130
126
  end
131
- end
132
- function __TS__Promise.prototype.reject(self, reason)
133
- if self.state == __TS__PromiseState.Pending then
134
- self.state = __TS__PromiseState.Rejected
135
- self.rejectionReason = reason
136
- for ____, callback in ipairs(self.rejectedCallbacks) do
137
- callback(_G, reason)
138
- end
139
- for ____, callback in ipairs(self.finallyCallbacks) do
140
- callback(_G)
127
+ function __TS__Promise.prototype.reject(self, reason)
128
+ if self.state == 0 then
129
+ self.state = 2
130
+ self.rejectionReason = reason
131
+ for ____, callback in ipairs(self.rejectedCallbacks) do
132
+ callback(nil, reason)
133
+ end
134
+ for ____, callback in ipairs(self.finallyCallbacks) do
135
+ callback(nil)
136
+ end
141
137
  end
142
138
  end
143
- end
144
- function __TS__Promise.prototype.createPromiseResolvingCallback(self, f, resolve, reject)
145
- return function(____, value)
146
- do
147
- local function ____catch(e)
148
- reject(_G, e)
149
- end
150
- local ____try, ____hasReturned = pcall(function()
151
- self:handleCallbackData(
152
- f(_G, value),
153
- resolve,
154
- reject
155
- )
156
- end)
157
- if not ____try then
158
- ____catch(____hasReturned)
139
+ function __TS__Promise.prototype.createPromiseResolvingCallback(self, f, resolve, reject)
140
+ return function(____, value)
141
+ do
142
+ local function ____catch(e)
143
+ reject(nil, e)
144
+ end
145
+ local ____try, ____hasReturned = pcall(function()
146
+ self:handleCallbackData(
147
+ f(nil, value),
148
+ resolve,
149
+ reject
150
+ )
151
+ end)
152
+ if not ____try then
153
+ ____catch(____hasReturned)
154
+ end
159
155
  end
160
156
  end
161
157
  end
162
- end
163
- function __TS__Promise.prototype.handleCallbackData(self, data, resolve, reject)
164
- if __TS__IsPromiseLike(_G, data) then
165
- local nextpromise = data
166
- if nextpromise.state == __TS__PromiseState.Fulfilled then
167
- resolve(_G, nextpromise.value)
168
- elseif nextpromise.state == __TS__PromiseState.Rejected then
169
- reject(_G, nextpromise.rejectionReason)
158
+ function __TS__Promise.prototype.handleCallbackData(self, data, resolve, reject)
159
+ if isPromiseLike(nil, data) then
160
+ local nextpromise = data
161
+ if nextpromise.state == 1 then
162
+ resolve(nil, nextpromise.value)
163
+ elseif nextpromise.state == 2 then
164
+ reject(nil, nextpromise.rejectionReason)
165
+ else
166
+ data["then"](data, resolve, reject)
167
+ end
170
168
  else
171
- data["then"](data, resolve, reject)
169
+ resolve(nil, data)
172
170
  end
173
- else
174
- resolve(_G, data)
175
171
  end
176
172
  end
@@ -1,13 +1,13 @@
1
- function __TS__PromiseAll(iterable)
1
+ local function __TS__PromiseAll(iterable)
2
2
  local results = {}
3
3
  local toResolve = {}
4
4
  local numToResolve = 0
5
5
  local i = 0
6
6
  for ____, item in __TS__Iterator(iterable) do
7
7
  if __TS__InstanceOf(item, __TS__Promise) then
8
- if item.state == __TS__PromiseState.Fulfilled then
8
+ if item.state == 1 then
9
9
  results[i + 1] = item.value
10
- elseif item.state == __TS__PromiseState.Rejected then
10
+ elseif item.state == 2 then
11
11
  return __TS__Promise.reject(item.rejectionReason)
12
12
  else
13
13
  numToResolve = numToResolve + 1
@@ -31,11 +31,11 @@ function __TS__PromiseAll(iterable)
31
31
  results[index + 1] = data
32
32
  numToResolve = numToResolve - 1
33
33
  if numToResolve == 0 then
34
- resolve(_G, results)
34
+ resolve(nil, results)
35
35
  end
36
36
  end,
37
37
  function(____, reason)
38
- reject(_G, reason)
38
+ reject(nil, reason)
39
39
  end
40
40
  )
41
41
  end
@@ -1,13 +1,13 @@
1
- function __TS__PromiseAllSettled(iterable)
1
+ local function __TS__PromiseAllSettled(iterable)
2
2
  local results = {}
3
3
  local toResolve = {}
4
4
  local numToResolve = 0
5
5
  local i = 0
6
6
  for ____, item in __TS__Iterator(iterable) do
7
7
  if __TS__InstanceOf(item, __TS__Promise) then
8
- if item.state == __TS__PromiseState.Fulfilled then
8
+ if item.state == 1 then
9
9
  results[i + 1] = {status = "fulfilled", value = item.value}
10
- elseif item.state == __TS__PromiseState.Rejected then
10
+ elseif item.state == 2 then
11
11
  results[i + 1] = {status = "rejected", reason = item.rejectionReason}
12
12
  else
13
13
  numToResolve = numToResolve + 1
@@ -31,14 +31,14 @@ function __TS__PromiseAllSettled(iterable)
31
31
  results[index + 1] = {status = "fulfilled", value = data}
32
32
  numToResolve = numToResolve - 1
33
33
  if numToResolve == 0 then
34
- resolve(_G, results)
34
+ resolve(nil, results)
35
35
  end
36
36
  end,
37
37
  function(____, reason)
38
38
  results[index + 1] = {status = "rejected", reason = reason}
39
39
  numToResolve = numToResolve - 1
40
40
  if numToResolve == 0 then
41
- resolve(_G, results)
41
+ resolve(nil, results)
42
42
  end
43
43
  end
44
44
  )
@@ -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