typescript-to-lua
Advanced tools
Comparing version 1.15.0 to 1.15.1
@@ -50,4 +50,17 @@ "use strict"; | ||
exports.parseConfigFileWithSystem = parseConfigFileWithSystem; | ||
function resolveNpmModuleConfig(moduleName, configRootDir, host) { | ||
const resolved = ts.nodeNextJsonConfigResolver(moduleName, path.join(configRootDir, "tsconfig.json"), host); | ||
if (resolved.resolvedModule) { | ||
return resolved.resolvedModule.resolvedFileName; | ||
} | ||
} | ||
function getExtendedTstlOptions(configFilePath, configRootDir, cycleCache, system) { | ||
const absolutePath = path.isAbsolute(configFilePath) ? configFilePath : path.resolve(configRootDir, configFilePath); | ||
const absolutePath = ts.pathIsAbsolute(configFilePath) | ||
? configFilePath | ||
: ts.pathIsRelative(configFilePath) | ||
? path.resolve(configRootDir, configFilePath) | ||
: resolveNpmModuleConfig(configFilePath, configRootDir, system); // if a path is neither relative nor absolute, it is probably a npm module | ||
if (!absolutePath) { | ||
return {}; | ||
} | ||
const newConfigRoot = path.dirname(absolutePath); | ||
@@ -54,0 +67,0 @@ if (cycleCache.has(absolutePath)) { |
@@ -78,2 +78,5 @@ "use strict"; | ||
result.push(constructorResult); | ||
const decoratingExpression = (0, method_1.createConstructorDecoratingExpression)(context, constructor, localClassName); | ||
if (decoratingExpression) | ||
result.push(decoratingExpression); | ||
} | ||
@@ -80,0 +83,0 @@ else if (!extendedType) { |
@@ -7,2 +7,4 @@ import * as ts from "typescript"; | ||
export declare function transformMethodDeclaration(context: TransformationContext, node: ts.MethodDeclaration, className: lua.Identifier): lua.Statement | undefined; | ||
export declare function getParameterDecorators(context: TransformationContext, node: ts.FunctionLikeDeclarationBase): lua.CallExpression[]; | ||
export declare function createConstructorDecoratingExpression(context: TransformationContext, node: ts.ConstructorDeclaration, className: lua.Identifier): lua.Statement | undefined; | ||
export declare function createMethodDecoratingExpression(context: TransformationContext, node: ts.MethodDeclaration, className: lua.Identifier): lua.Statement | undefined; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createMethodDecoratingExpression = exports.transformMethodDeclaration = exports.transformMethodName = exports.transformMemberExpressionOwnerName = void 0; | ||
exports.createMethodDecoratingExpression = exports.createConstructorDecoratingExpression = exports.getParameterDecorators = exports.transformMethodDeclaration = exports.transformMethodName = exports.transformMemberExpressionOwnerName = void 0; | ||
const ts = require("typescript"); | ||
@@ -35,7 +35,4 @@ const lua = require("../../../../LuaAST"); | ||
exports.transformMethodDeclaration = transformMethodDeclaration; | ||
function createMethodDecoratingExpression(context, node, className) { | ||
var _a, _b; | ||
const methodTable = transformMemberExpressionOwnerName(node, className); | ||
const methodName = transformMethodName(context, node); | ||
const parameterDecorators = node.parameters | ||
function getParameterDecorators(context, node) { | ||
return node.parameters | ||
.flatMap((parameter, index) => { | ||
@@ -47,2 +44,17 @@ var _a; | ||
.filter(utils_2.isNonNull); | ||
} | ||
exports.getParameterDecorators = getParameterDecorators; | ||
function createConstructorDecoratingExpression(context, node, className) { | ||
const parameterDecorators = getParameterDecorators(context, node); | ||
if (parameterDecorators.length > 0) { | ||
const decorateMethod = (0, decorators_1.createDecoratingExpression)(context, node.kind, parameterDecorators, className); | ||
return lua.createExpressionStatement(decorateMethod); | ||
} | ||
} | ||
exports.createConstructorDecoratingExpression = createConstructorDecoratingExpression; | ||
function createMethodDecoratingExpression(context, node, className) { | ||
var _a, _b; | ||
const methodTable = transformMemberExpressionOwnerName(node, className); | ||
const methodName = transformMethodName(context, node); | ||
const parameterDecorators = getParameterDecorators(context, node); | ||
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 : []; | ||
@@ -49,0 +61,0 @@ if (methodDecorators.length > 0 || parameterDecorators.length > 0) { |
{ | ||
"name": "typescript-to-lua", | ||
"version": "1.15.0", | ||
"version": "1.15.1", | ||
"description": "A generic TypeScript to Lua transpiler. Write your code in TypeScript and publish Lua!", | ||
@@ -73,4 +73,4 @@ "repository": "https://github.com/TypeScriptToLua/TypeScriptToLua", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.0.2" | ||
"typescript": "^5.0.4" | ||
} | ||
} |
1044977
14952