typescript-to-lua 1.27.0 → 1.28.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.
- package/dist/lualib/5.0/ObjectDefineProperty.lua +12 -18
- package/dist/lualib/5.0/lualib_bundle.lua +12 -18
- package/dist/lualib/universal/ObjectDefineProperty.lua +12 -18
- package/dist/lualib/universal/lualib_bundle.lua +12 -18
- package/dist/lualib-build/plugin.js +0 -1
- package/dist/transformation/context/context.js +3 -1
- package/dist/transformation/visitors/class/members/constructor.js +7 -10
- package/dist/transformation/visitors/language-extensions/iterable.js +5 -3
- package/dist/utils.js +1 -4
- package/package.json +13 -14
|
@@ -15,23 +15,17 @@ local function __TS__ObjectDefineProperty(target, key, desc)
|
|
|
15
15
|
local valueExists = value ~= nil
|
|
16
16
|
local ____desc_set_4 = desc.set
|
|
17
17
|
local ____desc_get_5 = desc.get
|
|
18
|
-
local
|
|
19
|
-
if
|
|
20
|
-
|
|
21
|
-
else
|
|
22
|
-
____temp_0 = valueExists
|
|
18
|
+
local ____desc_configurable_0 = desc.configurable
|
|
19
|
+
if ____desc_configurable_0 == nil then
|
|
20
|
+
____desc_configurable_0 = valueExists
|
|
23
21
|
end
|
|
24
|
-
local
|
|
25
|
-
if
|
|
26
|
-
|
|
27
|
-
else
|
|
28
|
-
____temp_1 = valueExists
|
|
22
|
+
local ____desc_enumerable_1 = desc.enumerable
|
|
23
|
+
if ____desc_enumerable_1 == nil then
|
|
24
|
+
____desc_enumerable_1 = valueExists
|
|
29
25
|
end
|
|
30
|
-
local
|
|
31
|
-
if
|
|
32
|
-
|
|
33
|
-
else
|
|
34
|
-
____temp_2 = valueExists
|
|
26
|
+
local ____desc_writable_2 = desc.writable
|
|
27
|
+
if ____desc_writable_2 == nil then
|
|
28
|
+
____desc_writable_2 = valueExists
|
|
35
29
|
end
|
|
36
30
|
local ____temp_3
|
|
37
31
|
if desc.value ~= nil then
|
|
@@ -42,9 +36,9 @@ local function __TS__ObjectDefineProperty(target, key, desc)
|
|
|
42
36
|
descriptor = {
|
|
43
37
|
set = ____desc_set_4,
|
|
44
38
|
get = ____desc_get_5,
|
|
45
|
-
configurable =
|
|
46
|
-
enumerable =
|
|
47
|
-
writable =
|
|
39
|
+
configurable = ____desc_configurable_0,
|
|
40
|
+
enumerable = ____desc_enumerable_1,
|
|
41
|
+
writable = ____desc_writable_2,
|
|
48
42
|
value = ____temp_3
|
|
49
43
|
}
|
|
50
44
|
end
|
|
@@ -1703,23 +1703,17 @@ local function __TS__ObjectDefineProperty(target, key, desc)
|
|
|
1703
1703
|
local valueExists = value ~= nil
|
|
1704
1704
|
local ____desc_set_4 = desc.set
|
|
1705
1705
|
local ____desc_get_5 = desc.get
|
|
1706
|
-
local
|
|
1707
|
-
if
|
|
1708
|
-
|
|
1709
|
-
else
|
|
1710
|
-
____temp_0 = valueExists
|
|
1706
|
+
local ____desc_configurable_0 = desc.configurable
|
|
1707
|
+
if ____desc_configurable_0 == nil then
|
|
1708
|
+
____desc_configurable_0 = valueExists
|
|
1711
1709
|
end
|
|
1712
|
-
local
|
|
1713
|
-
if
|
|
1714
|
-
|
|
1715
|
-
else
|
|
1716
|
-
____temp_1 = valueExists
|
|
1710
|
+
local ____desc_enumerable_1 = desc.enumerable
|
|
1711
|
+
if ____desc_enumerable_1 == nil then
|
|
1712
|
+
____desc_enumerable_1 = valueExists
|
|
1717
1713
|
end
|
|
1718
|
-
local
|
|
1719
|
-
if
|
|
1720
|
-
|
|
1721
|
-
else
|
|
1722
|
-
____temp_2 = valueExists
|
|
1714
|
+
local ____desc_writable_2 = desc.writable
|
|
1715
|
+
if ____desc_writable_2 == nil then
|
|
1716
|
+
____desc_writable_2 = valueExists
|
|
1723
1717
|
end
|
|
1724
1718
|
local ____temp_3
|
|
1725
1719
|
if desc.value ~= nil then
|
|
@@ -1730,9 +1724,9 @@ local function __TS__ObjectDefineProperty(target, key, desc)
|
|
|
1730
1724
|
descriptor = {
|
|
1731
1725
|
set = ____desc_set_4,
|
|
1732
1726
|
get = ____desc_get_5,
|
|
1733
|
-
configurable =
|
|
1734
|
-
enumerable =
|
|
1735
|
-
writable =
|
|
1727
|
+
configurable = ____desc_configurable_0,
|
|
1728
|
+
enumerable = ____desc_enumerable_1,
|
|
1729
|
+
writable = ____desc_writable_2,
|
|
1736
1730
|
value = ____temp_3
|
|
1737
1731
|
}
|
|
1738
1732
|
end
|
|
@@ -15,23 +15,17 @@ local function __TS__ObjectDefineProperty(target, key, desc)
|
|
|
15
15
|
local valueExists = value ~= nil
|
|
16
16
|
local ____desc_set_4 = desc.set
|
|
17
17
|
local ____desc_get_5 = desc.get
|
|
18
|
-
local
|
|
19
|
-
if
|
|
20
|
-
|
|
21
|
-
else
|
|
22
|
-
____temp_0 = valueExists
|
|
18
|
+
local ____desc_configurable_0 = desc.configurable
|
|
19
|
+
if ____desc_configurable_0 == nil then
|
|
20
|
+
____desc_configurable_0 = valueExists
|
|
23
21
|
end
|
|
24
|
-
local
|
|
25
|
-
if
|
|
26
|
-
|
|
27
|
-
else
|
|
28
|
-
____temp_1 = valueExists
|
|
22
|
+
local ____desc_enumerable_1 = desc.enumerable
|
|
23
|
+
if ____desc_enumerable_1 == nil then
|
|
24
|
+
____desc_enumerable_1 = valueExists
|
|
29
25
|
end
|
|
30
|
-
local
|
|
31
|
-
if
|
|
32
|
-
|
|
33
|
-
else
|
|
34
|
-
____temp_2 = valueExists
|
|
26
|
+
local ____desc_writable_2 = desc.writable
|
|
27
|
+
if ____desc_writable_2 == nil then
|
|
28
|
+
____desc_writable_2 = valueExists
|
|
35
29
|
end
|
|
36
30
|
local ____temp_3
|
|
37
31
|
if desc.value ~= nil then
|
|
@@ -42,9 +36,9 @@ local function __TS__ObjectDefineProperty(target, key, desc)
|
|
|
42
36
|
descriptor = {
|
|
43
37
|
set = ____desc_set_4,
|
|
44
38
|
get = ____desc_get_5,
|
|
45
|
-
configurable =
|
|
46
|
-
enumerable =
|
|
47
|
-
writable =
|
|
39
|
+
configurable = ____desc_configurable_0,
|
|
40
|
+
enumerable = ____desc_enumerable_1,
|
|
41
|
+
writable = ____desc_writable_2,
|
|
48
42
|
value = ____temp_3
|
|
49
43
|
}
|
|
50
44
|
end
|
|
@@ -1634,23 +1634,17 @@ local function __TS__ObjectDefineProperty(target, key, desc)
|
|
|
1634
1634
|
local valueExists = value ~= nil
|
|
1635
1635
|
local ____desc_set_4 = desc.set
|
|
1636
1636
|
local ____desc_get_5 = desc.get
|
|
1637
|
-
local
|
|
1638
|
-
if
|
|
1639
|
-
|
|
1640
|
-
else
|
|
1641
|
-
____temp_0 = valueExists
|
|
1637
|
+
local ____desc_configurable_0 = desc.configurable
|
|
1638
|
+
if ____desc_configurable_0 == nil then
|
|
1639
|
+
____desc_configurable_0 = valueExists
|
|
1642
1640
|
end
|
|
1643
|
-
local
|
|
1644
|
-
if
|
|
1645
|
-
|
|
1646
|
-
else
|
|
1647
|
-
____temp_1 = valueExists
|
|
1641
|
+
local ____desc_enumerable_1 = desc.enumerable
|
|
1642
|
+
if ____desc_enumerable_1 == nil then
|
|
1643
|
+
____desc_enumerable_1 = valueExists
|
|
1648
1644
|
end
|
|
1649
|
-
local
|
|
1650
|
-
if
|
|
1651
|
-
|
|
1652
|
-
else
|
|
1653
|
-
____temp_2 = valueExists
|
|
1645
|
+
local ____desc_writable_2 = desc.writable
|
|
1646
|
+
if ____desc_writable_2 == nil then
|
|
1647
|
+
____desc_writable_2 = valueExists
|
|
1654
1648
|
end
|
|
1655
1649
|
local ____temp_3
|
|
1656
1650
|
if desc.value ~= nil then
|
|
@@ -1661,9 +1655,9 @@ local function __TS__ObjectDefineProperty(target, key, desc)
|
|
|
1661
1655
|
descriptor = {
|
|
1662
1656
|
set = ____desc_set_4,
|
|
1663
1657
|
get = ____desc_get_5,
|
|
1664
|
-
configurable =
|
|
1665
|
-
enumerable =
|
|
1666
|
-
writable =
|
|
1658
|
+
configurable = ____desc_configurable_0,
|
|
1659
|
+
enumerable = ____desc_enumerable_1,
|
|
1660
|
+
writable = ____desc_writable_2,
|
|
1667
1661
|
value = ____temp_3
|
|
1668
1662
|
}
|
|
1669
1663
|
end
|
|
@@ -21,7 +21,9 @@ class TransformationContext {
|
|
|
21
21
|
this.options = this.program.getCompilerOptions();
|
|
22
22
|
this.luaTarget = (_a = this.options.luaTarget) !== null && _a !== void 0 ? _a : CompilerOptions_1.LuaTarget.Universal;
|
|
23
23
|
this.isModule = ts.isExternalModule(this.sourceFile);
|
|
24
|
-
this.isStrict =
|
|
24
|
+
this.isStrict =
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
26
|
+
((_b = this.options.alwaysStrict) !== null && _b !== void 0 ? _b : this.options.strict) ||
|
|
25
27
|
(this.isModule && this.options.target !== undefined && this.options.target >= ts.ScriptTarget.ES2015);
|
|
26
28
|
this.currentNodeVisitors = [];
|
|
27
29
|
this.currentNodeVisitorsIndex = 0;
|
|
@@ -30,19 +30,16 @@ function transformConstructorDeclaration(context, statement, className, instance
|
|
|
30
30
|
// Check for field declarations in constructor
|
|
31
31
|
const constructorFieldsDeclarations = statement.parameters.filter(p => p.modifiers !== undefined);
|
|
32
32
|
const classInstanceFields = (0, fields_1.transformClassInstanceFields)(context, instanceFields);
|
|
33
|
-
// If there are field initializers and
|
|
34
|
-
// move super call between default assignments and initializers
|
|
33
|
+
// If there are field initializers and there is a super call somewhere,
|
|
34
|
+
// move super call and everything before it to between default assignments and initializers
|
|
35
35
|
if ((constructorFieldsDeclarations.length > 0 || classInstanceFields.length > 0) &&
|
|
36
36
|
statement.body &&
|
|
37
37
|
statement.body.statements.length > 0) {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
ts.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (superCall) {
|
|
44
|
-
bodyWithFieldInitializers.push(superCall);
|
|
45
|
-
}
|
|
38
|
+
const superIndex = statement.body.statements.findIndex(s => ts.isExpressionStatement(s) &&
|
|
39
|
+
ts.isCallExpression(s.expression) &&
|
|
40
|
+
s.expression.expression.kind === ts.SyntaxKind.SuperKeyword);
|
|
41
|
+
if (superIndex !== -1) {
|
|
42
|
+
bodyWithFieldInitializers.push(...body.splice(0, superIndex + 1));
|
|
46
43
|
}
|
|
47
44
|
}
|
|
48
45
|
// Add in instance field declarations
|
|
@@ -43,9 +43,11 @@ function transformForOfMultiIterableStatement(context, statement, block, luaIter
|
|
|
43
43
|
return lua.createForInStatement(block, identifiers, [luaIterator], statement);
|
|
44
44
|
}
|
|
45
45
|
function transformForOfIterableStatement(context, statement, block) {
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
46
|
+
const iteratedExpressionType = context.checker.getTypeAtLocation(statement.expression);
|
|
47
|
+
const iterableType = iteratedExpressionType.isIntersection() &&
|
|
48
|
+
iteratedExpressionType.types.find(t => t.symbol.escapedName === "Iterable");
|
|
49
|
+
const iterableTypeArguments = iterableType === null || iterableType === void 0 ? void 0 : iterableType.typeArguments;
|
|
50
|
+
if (iterableTypeArguments && iterableTypeArguments.length > 0 && (0, multi_1.isMultiReturnType)(iterableTypeArguments[0])) {
|
|
49
51
|
const luaIterator = context.transformExpression(statement.expression);
|
|
50
52
|
return transformForOfMultiIterableStatement(context, statement, block, luaIterator, diagnostics_1.invalidMultiIterableWithoutDestructuring);
|
|
51
53
|
}
|
package/dist/utils.js
CHANGED
|
@@ -46,15 +46,12 @@ function formatPathToLuaPath(filePath) {
|
|
|
46
46
|
}
|
|
47
47
|
return filePath.replace(/\.\//g, "").replace(/\//g, ".");
|
|
48
48
|
}
|
|
49
|
-
function getOrUpdate(
|
|
50
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
51
|
-
map, key, getDefaultValue) {
|
|
49
|
+
function getOrUpdate(map, key, getDefaultValue) {
|
|
52
50
|
if (!map.has(key)) {
|
|
53
51
|
map.set(key, getDefaultValue());
|
|
54
52
|
}
|
|
55
53
|
return map.get(key);
|
|
56
54
|
}
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
58
55
|
function isNonNull(value) {
|
|
59
56
|
return value != null;
|
|
60
57
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typescript-to-lua",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.0",
|
|
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/",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"test": "jest",
|
|
30
30
|
"lint": "npm run lint:eslint && npm run lint:prettier",
|
|
31
31
|
"lint:prettier": "prettier --check . || (echo 'Run `npm run fix:prettier` to fix it.' && exit 1)",
|
|
32
|
-
"lint:eslint": "eslint .
|
|
32
|
+
"lint:eslint": "eslint .",
|
|
33
33
|
"fix:prettier": "prettier --write .",
|
|
34
34
|
"check:language-extensions": "tsc --strict language-extensions/index.d.ts",
|
|
35
35
|
"preversion": "npm run build && npm test",
|
|
@@ -42,35 +42,34 @@
|
|
|
42
42
|
"node": ">=16.10.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"typescript": "5.
|
|
45
|
+
"typescript": "5.7.2"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@typescript-to-lua/language-extensions": "1.19.0",
|
|
49
|
-
"enhanced-resolve": "
|
|
49
|
+
"enhanced-resolve": "5.8.2",
|
|
50
50
|
"picomatch": "^2.3.1",
|
|
51
51
|
"resolve": "^1.15.1",
|
|
52
52
|
"source-map": "^0.7.3"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/fs-extra": "^8.1.0",
|
|
56
|
-
"@types/glob": "^7.
|
|
56
|
+
"@types/glob": "^7.2.0",
|
|
57
57
|
"@types/jest": "^27.5.2",
|
|
58
|
-
"@types/node": "^
|
|
58
|
+
"@types/node": "^22.10.0",
|
|
59
59
|
"@types/picomatch": "^2.3.0",
|
|
60
60
|
"@types/resolve": "1.14.0",
|
|
61
|
-
"eslint": "^
|
|
62
|
-
"eslint-plugin-
|
|
63
|
-
"eslint-plugin-jest": "^26.9.0",
|
|
61
|
+
"eslint": "^9.11.0",
|
|
62
|
+
"eslint-plugin-jest": "^28.8.3",
|
|
64
63
|
"fs-extra": "^8.1.0",
|
|
65
64
|
"javascript-stringify": "^2.0.1",
|
|
66
65
|
"jest": "^29.5.0",
|
|
67
|
-
"jest-circus": "^29.
|
|
66
|
+
"jest-circus": "^29.7.0",
|
|
68
67
|
"lua-types": "^2.13.0",
|
|
69
68
|
"lua-wasm-bindings": "^0.3.1",
|
|
70
69
|
"prettier": "^2.8.8",
|
|
71
|
-
"ts-jest": "^29.
|
|
72
|
-
"ts-node": "^10.9.
|
|
73
|
-
"typescript": "
|
|
74
|
-
"typescript-eslint": "^
|
|
70
|
+
"ts-jest": "^29.2.5",
|
|
71
|
+
"ts-node": "^10.9.2",
|
|
72
|
+
"typescript": "5.7.2",
|
|
73
|
+
"typescript-eslint": "^8.16.0"
|
|
75
74
|
}
|
|
76
75
|
}
|