typescript-to-lua 1.15.0 → 1.15.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/cli/tsconfig.js
CHANGED
|
@@ -47,8 +47,21 @@ function parseConfigFileWithSystem(configFileName, commandLineOptions, system =
|
|
|
47
47
|
return (0, parse_1.updateParsedConfigFile)(parsedConfigFile);
|
|
48
48
|
}
|
|
49
49
|
exports.parseConfigFileWithSystem = parseConfigFileWithSystem;
|
|
50
|
+
function resolveNpmModuleConfig(moduleName, configRootDir, host) {
|
|
51
|
+
const resolved = ts.nodeNextJsonConfigResolver(moduleName, path.join(configRootDir, "tsconfig.json"), host);
|
|
52
|
+
if (resolved.resolvedModule) {
|
|
53
|
+
return resolved.resolvedModule.resolvedFileName;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
50
56
|
function getExtendedTstlOptions(configFilePath, configRootDir, cycleCache, system) {
|
|
51
|
-
const absolutePath =
|
|
57
|
+
const absolutePath = ts.pathIsAbsolute(configFilePath)
|
|
58
|
+
? configFilePath
|
|
59
|
+
: ts.pathIsRelative(configFilePath)
|
|
60
|
+
? path.resolve(configRootDir, configFilePath)
|
|
61
|
+
: resolveNpmModuleConfig(configFilePath, configRootDir, system); // if a path is neither relative nor absolute, it is probably a npm module
|
|
62
|
+
if (!absolutePath) {
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
52
65
|
const newConfigRoot = path.dirname(absolutePath);
|
|
53
66
|
if (cycleCache.has(absolutePath)) {
|
|
54
67
|
return {};
|
|
@@ -75,6 +75,9 @@ function transformClassLikeDeclaration(classDeclaration, context, nameOverride)
|
|
|
75
75
|
const constructorResult = (0, constructor_1.transformConstructorDeclaration)(context, constructor, localClassName, instanceFields, classDeclaration);
|
|
76
76
|
if (constructorResult)
|
|
77
77
|
result.push(constructorResult);
|
|
78
|
+
const decoratingExpression = (0, method_1.createConstructorDecoratingExpression)(context, constructor, localClassName);
|
|
79
|
+
if (decoratingExpression)
|
|
80
|
+
result.push(decoratingExpression);
|
|
78
81
|
}
|
|
79
82
|
else if (!extendedType) {
|
|
80
83
|
// Generate a constructor if none was defined in a base class
|
|
@@ -4,4 +4,6 @@ import { TransformationContext } from "../../../context";
|
|
|
4
4
|
export declare function transformMemberExpressionOwnerName(node: ts.PropertyDeclaration | ts.MethodDeclaration | ts.AccessorDeclaration, className: lua.Identifier): lua.Expression;
|
|
5
5
|
export declare function transformMethodName(context: TransformationContext, node: ts.MethodDeclaration): lua.Expression;
|
|
6
6
|
export declare function transformMethodDeclaration(context: TransformationContext, node: ts.MethodDeclaration, className: lua.Identifier): lua.Statement | undefined;
|
|
7
|
+
export declare function getParameterDecorators(context: TransformationContext, node: ts.FunctionLikeDeclarationBase): lua.CallExpression[];
|
|
8
|
+
export declare function createConstructorDecoratingExpression(context: TransformationContext, node: ts.ConstructorDeclaration, className: lua.Identifier): lua.Statement | undefined;
|
|
7
9
|
export declare function createMethodDecoratingExpression(context: TransformationContext, node: ts.MethodDeclaration, className: lua.Identifier): lua.Statement | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createMethodDecoratingExpression = exports.transformMethodDeclaration = exports.transformMethodName = exports.transformMemberExpressionOwnerName = void 0;
|
|
3
|
+
exports.createMethodDecoratingExpression = exports.createConstructorDecoratingExpression = exports.getParameterDecorators = exports.transformMethodDeclaration = exports.transformMethodName = exports.transformMemberExpressionOwnerName = void 0;
|
|
4
4
|
const ts = require("typescript");
|
|
5
5
|
const lua = require("../../../../LuaAST");
|
|
6
6
|
const function_1 = require("../../function");
|
|
@@ -32,17 +32,29 @@ function transformMethodDeclaration(context, node, className) {
|
|
|
32
32
|
return lua.createAssignmentStatement(lua.createTableIndexExpression(methodTable, methodName), functionExpression, node);
|
|
33
33
|
}
|
|
34
34
|
exports.transformMethodDeclaration = transformMethodDeclaration;
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
const methodTable = transformMemberExpressionOwnerName(node, className);
|
|
38
|
-
const methodName = transformMethodName(context, node);
|
|
39
|
-
const parameterDecorators = node.parameters
|
|
35
|
+
function getParameterDecorators(context, node) {
|
|
36
|
+
return node.parameters
|
|
40
37
|
.flatMap((parameter, index) => {
|
|
41
38
|
var _a;
|
|
42
39
|
return (_a = ts
|
|
43
40
|
.getDecorators(parameter)) === null || _a === void 0 ? void 0 : _a.map(decorator => (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.DecorateParam, node, lua.createNumericLiteral(index), (0, decorators_1.transformDecoratorExpression)(context, decorator)));
|
|
44
41
|
})
|
|
45
42
|
.filter(utils_2.isNonNull);
|
|
43
|
+
}
|
|
44
|
+
exports.getParameterDecorators = getParameterDecorators;
|
|
45
|
+
function createConstructorDecoratingExpression(context, node, className) {
|
|
46
|
+
const parameterDecorators = getParameterDecorators(context, node);
|
|
47
|
+
if (parameterDecorators.length > 0) {
|
|
48
|
+
const decorateMethod = (0, decorators_1.createDecoratingExpression)(context, node.kind, parameterDecorators, className);
|
|
49
|
+
return lua.createExpressionStatement(decorateMethod);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.createConstructorDecoratingExpression = createConstructorDecoratingExpression;
|
|
53
|
+
function createMethodDecoratingExpression(context, node, className) {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
const methodTable = transformMemberExpressionOwnerName(node, className);
|
|
56
|
+
const methodName = transformMethodName(context, node);
|
|
57
|
+
const parameterDecorators = getParameterDecorators(context, node);
|
|
46
58
|
const methodDecorators = (_b = (_a = ts.getDecorators(node)) === null || _a === void 0 ? void 0 : _a.map(d => (0, decorators_1.transformDecoratorExpression)(context, d))) !== null && _b !== void 0 ? _b : [];
|
|
47
59
|
if (methodDecorators.length > 0 || parameterDecorators.length > 0) {
|
|
48
60
|
const decorateMethod = (0, decorators_1.createDecoratingExpression)(context, node.kind, [...methodDecorators, ...parameterDecorators], methodTable, methodName);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typescript-to-lua",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.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/",
|
|
@@ -70,6 +70,6 @@
|
|
|
70
70
|
"prettier": "^2.8.4",
|
|
71
71
|
"ts-jest": "^29.1.0",
|
|
72
72
|
"ts-node": "^10.9.1",
|
|
73
|
-
"typescript": "^5.0.
|
|
73
|
+
"typescript": "^5.0.4"
|
|
74
74
|
}
|
|
75
75
|
}
|