typescript-to-lua 1.10.0 → 1.10.1
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.
- package/dist/lualib/5.0/Generator.lua +1 -1
- package/dist/lualib/5.0/SparseArraySpread.lua +1 -1
- package/dist/lualib/5.0/Unpack.lua +18 -1
- package/dist/lualib/5.0/lualib_bundle.lua +32 -15
- package/dist/lualib/5.0/lualib_module_info.json +3 -1
- package/dist/transformation/utils/diagnostics.js +1 -1
- package/dist/transformation/visitors/conditional.js +4 -0
- package/package.json +1 -1
|
@@ -25,7 +25,7 @@ do
|
|
|
25
25
|
local args = arg
|
|
26
26
|
local argsLength = __TS__CountVarargs(unpack(arg))
|
|
27
27
|
return {
|
|
28
|
-
____coroutine = coroutine.create(function() return fn(
|
|
28
|
+
____coroutine = coroutine.create(function() return fn(__TS__Unpack(args, 1, argsLength)) end),
|
|
29
29
|
[Symbol.iterator] = generatorIterator,
|
|
30
30
|
next = generatorNext
|
|
31
31
|
}
|
|
@@ -1 +1,18 @@
|
|
|
1
|
-
local __TS__Unpack
|
|
1
|
+
local function __TS__Unpack(list, i, j)
|
|
2
|
+
if i == 1 and j == nil then
|
|
3
|
+
return unpack(nil, list)
|
|
4
|
+
else
|
|
5
|
+
if j == nil then
|
|
6
|
+
j = table.getn(list)
|
|
7
|
+
end
|
|
8
|
+
local slice = {}
|
|
9
|
+
do
|
|
10
|
+
local n = i
|
|
11
|
+
while n <= j do
|
|
12
|
+
slice[n - i + 1] = list[n]
|
|
13
|
+
n = n + 1
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
return unpack(slice)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -1184,24 +1184,25 @@ local function __TS__DelegatedYield(iterable)
|
|
|
1184
1184
|
end
|
|
1185
1185
|
end
|
|
1186
1186
|
|
|
1187
|
-
local function
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
for i = 0, string.len(iterable) - 1 do
|
|
1191
|
-
arr[i + 1] = __TS__StringAccess(iterable, i)
|
|
1192
|
-
end
|
|
1187
|
+
local function __TS__Unpack(list, i, j)
|
|
1188
|
+
if i == 1 and j == nil then
|
|
1189
|
+
return unpack(nil, list)
|
|
1193
1190
|
else
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1191
|
+
if j == nil then
|
|
1192
|
+
j = table.getn(list)
|
|
1193
|
+
end
|
|
1194
|
+
local slice = {}
|
|
1195
|
+
do
|
|
1196
|
+
local n = i
|
|
1197
|
+
while n <= j do
|
|
1198
|
+
slice[n - i + 1] = list[n]
|
|
1199
|
+
n = n + 1
|
|
1200
|
+
end
|
|
1198
1201
|
end
|
|
1202
|
+
return unpack(slice)
|
|
1199
1203
|
end
|
|
1200
|
-
return unpack(arr)
|
|
1201
1204
|
end
|
|
1202
1205
|
|
|
1203
|
-
local __TS__Unpack = unpack
|
|
1204
|
-
|
|
1205
1206
|
local __TS__Generator
|
|
1206
1207
|
do
|
|
1207
1208
|
local function generatorIterator(self)
|
|
@@ -1229,7 +1230,7 @@ do
|
|
|
1229
1230
|
local args = arg
|
|
1230
1231
|
local argsLength = __TS__CountVarargs(unpack(arg))
|
|
1231
1232
|
return {
|
|
1232
|
-
____coroutine = coroutine.create(function() return fn(
|
|
1233
|
+
____coroutine = coroutine.create(function() return fn(__TS__Unpack(args, 1, argsLength)) end),
|
|
1233
1234
|
[Symbol.iterator] = generatorIterator,
|
|
1234
1235
|
next = generatorNext
|
|
1235
1236
|
}
|
|
@@ -2069,7 +2070,7 @@ local function __TS__SparseArrayPush(sparseArray, ...)
|
|
|
2069
2070
|
end
|
|
2070
2071
|
|
|
2071
2072
|
local function __TS__SparseArraySpread(sparseArray)
|
|
2072
|
-
return
|
|
2073
|
+
return __TS__Unpack(sparseArray, 1, sparseArray.sparseLength)
|
|
2073
2074
|
end
|
|
2074
2075
|
|
|
2075
2076
|
local WeakMap
|
|
@@ -2217,6 +2218,22 @@ local function __TS__SourceMapTraceBack(fileName, sourceMap)
|
|
|
2217
2218
|
end
|
|
2218
2219
|
end
|
|
2219
2220
|
|
|
2221
|
+
local function __TS__Spread(iterable)
|
|
2222
|
+
local arr = {}
|
|
2223
|
+
if type(iterable) == "string" then
|
|
2224
|
+
for i = 0, string.len(iterable) - 1 do
|
|
2225
|
+
arr[i + 1] = __TS__StringAccess(iterable, i)
|
|
2226
|
+
end
|
|
2227
|
+
else
|
|
2228
|
+
local len = 0
|
|
2229
|
+
for ____, item in __TS__Iterator(iterable) do
|
|
2230
|
+
len = len + 1
|
|
2231
|
+
arr[len] = item
|
|
2232
|
+
end
|
|
2233
|
+
end
|
|
2234
|
+
return unpack(arr)
|
|
2235
|
+
end
|
|
2236
|
+
|
|
2220
2237
|
local function __TS__StringCharAt(self, pos)
|
|
2221
2238
|
if pos ~= pos then
|
|
2222
2239
|
pos = 0
|
|
@@ -254,7 +254,6 @@
|
|
|
254
254
|
"__TS__Generator"
|
|
255
255
|
],
|
|
256
256
|
"dependencies": [
|
|
257
|
-
"Spread",
|
|
258
257
|
"Symbol",
|
|
259
258
|
"CountVarargs",
|
|
260
259
|
"Unpack"
|
|
@@ -518,6 +517,9 @@
|
|
|
518
517
|
"SparseArraySpread": {
|
|
519
518
|
"exports": [
|
|
520
519
|
"__TS__SparseArraySpread"
|
|
520
|
+
],
|
|
521
|
+
"dependencies": [
|
|
522
|
+
"Unpack"
|
|
521
523
|
]
|
|
522
524
|
},
|
|
523
525
|
"WeakMap": {
|
|
@@ -57,7 +57,7 @@ exports.annotationRemoved = createErrorDiagnosticFactory((kind) => `'@${kind}' h
|
|
|
57
57
|
`See https://typescripttolua.github.io/docs/advanced/compiler-annotations#${kind.toLowerCase()} for more information.`);
|
|
58
58
|
exports.annotationDeprecated = createWarningDiagnosticFactory((kind) => `'@${kind}' is deprecated and will be removed in a future update. Please update your code before upgrading to the next release, otherwise your project will no longer compile. ` +
|
|
59
59
|
`See https://typescripttolua.github.io/docs/advanced/compiler-annotations#${kind.toLowerCase()} for more information.`);
|
|
60
|
-
exports.truthyOnlyConditionalValue = createWarningDiagnosticFactory("
|
|
60
|
+
exports.truthyOnlyConditionalValue = createWarningDiagnosticFactory("Only false and nil evaluate to 'false' in Lua, everything else is considered 'true'. Explicitly compare the value with ===.");
|
|
61
61
|
exports.notAllowedOptionalAssignment = createErrorDiagnosticFactory("The left-hand side of an assignment expression may not be an optional property access.");
|
|
62
62
|
exports.awaitMustBeInAsyncFunction = createErrorDiagnosticFactory("Await can only be used inside async functions.");
|
|
63
63
|
exports.unsupportedBuiltinOptionalCall = createErrorDiagnosticFactory("Optional calls are not supported for builtin or language extension functions.");
|
|
@@ -76,6 +76,10 @@ function transformIfStatement(statement, context) {
|
|
|
76
76
|
}
|
|
77
77
|
exports.transformIfStatement = transformIfStatement;
|
|
78
78
|
function checkOnlyTruthyCondition(condition, context) {
|
|
79
|
+
if (context.options.strictNullChecks === false)
|
|
80
|
+
return; // This check is not valid if everything could implicitly be nil
|
|
81
|
+
if (ts.isElementAccessExpression(condition))
|
|
82
|
+
return; // Array index could always implicitly return nil
|
|
79
83
|
if (!(0, typescript_1.canBeFalsy)(context, context.checker.getTypeAtLocation(condition))) {
|
|
80
84
|
context.diagnostics.push((0, diagnostics_1.truthyOnlyConditionalValue)(condition));
|
|
81
85
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typescript-to-lua",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.1",
|
|
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/",
|