typescript-to-lua 1.28.0 → 1.28.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.
|
@@ -4,6 +4,7 @@ exports.tryTransformBuiltinGlobalCall = tryTransformBuiltinGlobalCall;
|
|
|
4
4
|
const lualib_1 = require("../utils/lualib");
|
|
5
5
|
const typescript_1 = require("../utils/typescript");
|
|
6
6
|
const call_1 = require("../visitors/call");
|
|
7
|
+
const string_1 = require("./string");
|
|
7
8
|
function tryTransformBuiltinGlobalCall(context, node, expressionType) {
|
|
8
9
|
function getParameters() {
|
|
9
10
|
const signature = context.checker.getResolvedSignature(node);
|
|
@@ -15,6 +16,8 @@ function tryTransformBuiltinGlobalCall(context, node, expressionType) {
|
|
|
15
16
|
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.Symbol, node, ...getParameters());
|
|
16
17
|
case "NumberConstructor":
|
|
17
18
|
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.Number, node, ...getParameters());
|
|
19
|
+
case "StringConstructor":
|
|
20
|
+
return (0, string_1.transformStringConstructorCall)(node, ...getParameters());
|
|
18
21
|
case "isNaN":
|
|
19
22
|
case "isFinite":
|
|
20
23
|
const numberParameters = (0, typescript_1.isNumberType)(context, expressionType)
|
|
@@ -90,7 +90,7 @@ function tryTransformBuiltinGlobalMethodCall(context, node, calledMethod) {
|
|
|
90
90
|
result = (0, math_1.transformMathCall)(context, node, calledMethod);
|
|
91
91
|
break;
|
|
92
92
|
case "StringConstructor":
|
|
93
|
-
result = (0, string_1.
|
|
93
|
+
result = (0, string_1.transformStringConstructorMethodCall)(context, node, calledMethod);
|
|
94
94
|
break;
|
|
95
95
|
case "ObjectConstructor":
|
|
96
96
|
result = (0, object_1.transformObjectConstructorCall)(context, node, calledMethod);
|
|
@@ -2,5 +2,6 @@ import * as ts from "typescript";
|
|
|
2
2
|
import * as lua from "../../LuaAST";
|
|
3
3
|
import { TransformationContext } from "../context";
|
|
4
4
|
export declare function transformStringPrototypeCall(context: TransformationContext, node: ts.CallExpression, calledMethod: ts.PropertyAccessExpression): lua.Expression | undefined;
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function transformStringConstructorMethodCall(context: TransformationContext, node: ts.CallExpression, calledMethod: ts.PropertyAccessExpression): lua.Expression | undefined;
|
|
6
6
|
export declare function transformStringProperty(context: TransformationContext, node: ts.PropertyAccessExpression): lua.Expression | undefined;
|
|
7
|
+
export declare function transformStringConstructorCall(originalNode: ts.CallExpression, ...args: lua.Expression[]): lua.Expression | undefined;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transformStringPrototypeCall = transformStringPrototypeCall;
|
|
4
|
-
exports.
|
|
4
|
+
exports.transformStringConstructorMethodCall = transformStringConstructorMethodCall;
|
|
5
5
|
exports.transformStringProperty = transformStringProperty;
|
|
6
|
+
exports.transformStringConstructorCall = transformStringConstructorCall;
|
|
6
7
|
const CompilerOptions_1 = require("../../CompilerOptions");
|
|
7
8
|
const lua = require("../../LuaAST");
|
|
8
9
|
const diagnostics_1 = require("../utils/diagnostics");
|
|
@@ -112,7 +113,7 @@ function transformStringPrototypeCall(context, node, calledMethod) {
|
|
|
112
113
|
context.diagnostics.push((0, diagnostics_1.unsupportedProperty)(calledMethod.name, "string", expressionName));
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
|
-
function
|
|
116
|
+
function transformStringConstructorMethodCall(context, node, calledMethod) {
|
|
116
117
|
const signature = context.checker.getResolvedSignature(node);
|
|
117
118
|
const params = (0, call_1.transformArguments)(context, node.arguments, signature);
|
|
118
119
|
const expressionName = calledMethod.name.text;
|
|
@@ -138,4 +139,8 @@ function transformStringProperty(context, node) {
|
|
|
138
139
|
context.diagnostics.push((0, diagnostics_1.unsupportedProperty)(node.name, "string", node.name.text));
|
|
139
140
|
}
|
|
140
141
|
}
|
|
142
|
+
function transformStringConstructorCall(originalNode, ...args) {
|
|
143
|
+
const tostring = lua.createIdentifier("tostring", originalNode.expression);
|
|
144
|
+
return lua.createCallExpression(tostring, args, originalNode);
|
|
145
|
+
}
|
|
141
146
|
//# sourceMappingURL=string.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typescript-to-lua",
|
|
3
|
-
"version": "1.28.
|
|
3
|
+
"version": "1.28.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/",
|