You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

typescript-to-lua

Package Overview
Dependencies
Maintainers
2
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.2 to 1.4.3

dist/lualib/ArrayPushArray.lua

5

dist/cli/parse.js

@@ -72,2 +72,7 @@ "use strict";

},
{
name: "lua51AllowTryCatchInAsyncAwait",
description: "Always allow try/catch in async/await functions for Lua 5.1.",
type: "boolean",
},
];

@@ -74,0 +79,0 @@ function updateParsedConfigFile(parsedConfigFile) {

5

dist/CompilerOptions.d.ts

@@ -18,3 +18,3 @@ import * as ts from "typescript";

}
export declare type CompilerOptions = OmitIndexSignature<ts.CompilerOptions> & {
export interface TypeScriptToLuaOptions {
buildMode?: BuildMode;

@@ -33,2 +33,5 @@ extension?: string;

tstlVerbose?: boolean;
lua51AllowTryCatchInAsyncAwait?: boolean;
}
export declare type CompilerOptions = OmitIndexSignature<ts.CompilerOptions> & TypeScriptToLuaOptions & {
[option: string]: any;

@@ -35,0 +38,0 @@ };

16

dist/LuaAST.d.ts

@@ -68,2 +68,8 @@ import * as ts from "typescript";

};
export declare enum NodeFlags {
None = 0,
Inline = 1,
Declaration = 2,
TableUnpackCall = 4
}
export interface TextRange {

@@ -75,2 +81,3 @@ line?: number;

kind: SyntaxKind;
flags: NodeFlags;
}

@@ -83,2 +90,3 @@ export declare function createNode(kind: SyntaxKind, tsOriginal?: ts.Node): Node;

export declare function getOriginalPos(node: Node): TextRange;
export declare function setNodeFlags<T extends Node>(node: T, flags: NodeFlags): T;
export interface File extends Node {

@@ -223,7 +231,2 @@ kind: SyntaxKind.File;

export declare function isLiteral(node: Node): node is NilLiteral | DotsLiteral | BooleanLiteral | NumericLiteral | StringLiteral;
export declare enum FunctionExpressionFlags {
None = 1,
Inline = 2,
Declaration = 4
}
export interface FunctionExpression extends Expression {

@@ -234,6 +237,5 @@ kind: SyntaxKind.FunctionExpression;

body: Block;
flags: FunctionExpressionFlags;
}
export declare function isFunctionExpression(node: Node): node is FunctionExpression;
export declare function createFunctionExpression(body: Block, params?: Identifier[], dots?: DotsLiteral, flags?: FunctionExpressionFlags, tsOriginal?: ts.Node): FunctionExpression;
export declare function createFunctionExpression(body: Block, params?: Identifier[], dots?: DotsLiteral, flags?: NodeFlags, tsOriginal?: ts.Node): FunctionExpression;
export interface TableFieldExpression extends Expression {

@@ -240,0 +242,0 @@ kind: SyntaxKind.TableFieldExpression;

@@ -5,4 +5,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.isFunctionExpression = exports.FunctionExpressionFlags = exports.isLiteral = exports.createStringLiteral = exports.isStringLiteral = exports.createNumericLiteral = exports.isNumericLiteral = exports.createDotsLiteral = exports.isDotsLiteral = exports.createBooleanLiteral = exports.isBooleanLiteral = exports.createNilLiteral = exports.isNilLiteral = exports.createExpressionStatement = exports.isExpressionStatement = exports.createBreakStatement = exports.isBreakStatement = exports.createReturnStatement = exports.isReturnStatement = exports.createLabelStatement = exports.isLabelStatement = exports.createGotoStatement = exports.isGotoStatement = exports.createForInStatement = exports.isForInStatement = exports.createForStatement = exports.isForStatement = exports.createRepeatStatement = exports.isRepeatStatement = exports.createWhileStatement = exports.isWhileStatement = exports.isIterationStatement = exports.createIfStatement = exports.isIfStatement = exports.createAssignmentStatement = exports.isAssignmentStatement = exports.createVariableDeclarationStatement = exports.isVariableDeclarationStatement = exports.createDoStatement = exports.isDoStatement = exports.createBlock = exports.isBlock = exports.createFile = exports.isFile = exports.getOriginalPos = exports.setNodeOriginal = exports.setNodePosition = exports.cloneNode = exports.createNode = exports.SyntaxKind = void 0;
exports.isInlineFunctionExpression = exports.isFunctionDefinition = exports.isAssignmentLeftHandSideExpression = exports.createTableIndexExpression = exports.isTableIndexExpression = exports.createAnonymousIdentifier = exports.cloneIdentifier = exports.createIdentifier = exports.isIdentifier = exports.createMethodCallExpression = exports.isMethodCallExpression = exports.createCallExpression = exports.isCallExpression = exports.createBinaryExpression = exports.isBinaryExpression = exports.createUnaryExpression = exports.isUnaryExpression = exports.createTableExpression = exports.isTableExpression = exports.createTableFieldExpression = exports.isTableFieldExpression = exports.createFunctionExpression = void 0;
exports.isLiteral = exports.createStringLiteral = exports.isStringLiteral = exports.createNumericLiteral = exports.isNumericLiteral = exports.createDotsLiteral = exports.isDotsLiteral = exports.createBooleanLiteral = exports.isBooleanLiteral = exports.createNilLiteral = exports.isNilLiteral = exports.createExpressionStatement = exports.isExpressionStatement = exports.createBreakStatement = exports.isBreakStatement = exports.createReturnStatement = exports.isReturnStatement = exports.createLabelStatement = exports.isLabelStatement = exports.createGotoStatement = exports.isGotoStatement = exports.createForInStatement = exports.isForInStatement = exports.createForStatement = exports.isForStatement = exports.createRepeatStatement = exports.isRepeatStatement = exports.createWhileStatement = exports.isWhileStatement = exports.isIterationStatement = exports.createIfStatement = exports.isIfStatement = exports.createAssignmentStatement = exports.isAssignmentStatement = exports.createVariableDeclarationStatement = exports.isVariableDeclarationStatement = exports.createDoStatement = exports.isDoStatement = exports.createBlock = exports.isBlock = exports.createFile = exports.isFile = exports.setNodeFlags = exports.getOriginalPos = exports.setNodeOriginal = exports.setNodePosition = exports.cloneNode = exports.createNode = exports.NodeFlags = exports.SyntaxKind = void 0;
exports.isInlineFunctionExpression = exports.isFunctionDefinition = exports.isAssignmentLeftHandSideExpression = exports.createTableIndexExpression = exports.isTableIndexExpression = exports.createAnonymousIdentifier = exports.cloneIdentifier = exports.createIdentifier = exports.isIdentifier = exports.createMethodCallExpression = exports.isMethodCallExpression = exports.createCallExpression = exports.isCallExpression = exports.createBinaryExpression = exports.isBinaryExpression = exports.createUnaryExpression = exports.isUnaryExpression = exports.createTableExpression = exports.isTableExpression = exports.createTableFieldExpression = exports.isTableFieldExpression = exports.createFunctionExpression = exports.isFunctionExpression = void 0;
// We can elide a lot of nodes especially tokens and keywords

@@ -81,12 +81,19 @@ // because we don't create the AST from text

})(SyntaxKind = exports.SyntaxKind || (exports.SyntaxKind = {}));
var NodeFlags;
(function (NodeFlags) {
NodeFlags[NodeFlags["None"] = 0] = "None";
NodeFlags[NodeFlags["Inline"] = 1] = "Inline";
NodeFlags[NodeFlags["Declaration"] = 2] = "Declaration";
NodeFlags[NodeFlags["TableUnpackCall"] = 4] = "TableUnpackCall";
})(NodeFlags = exports.NodeFlags || (exports.NodeFlags = {}));
function createNode(kind, tsOriginal) {
if (tsOriginal === undefined) {
return { kind };
return { kind, flags: NodeFlags.None };
}
const sourcePosition = getSourcePosition(tsOriginal);
if (sourcePosition) {
return { kind, line: sourcePosition.line, column: sourcePosition.column };
return { kind, line: sourcePosition.line, column: sourcePosition.column, flags: NodeFlags.None };
}
else {
return { kind };
return { kind, flags: NodeFlags.None };
}

@@ -129,2 +136,7 @@ }

exports.getOriginalPos = getOriginalPos;
function setNodeFlags(node, flags) {
node.flags = flags;
return node;
}
exports.setNodeFlags = setNodeFlags;
function isFile(node) {

@@ -352,8 +364,2 @@ return node.kind === SyntaxKind.File;

exports.isLiteral = isLiteral;
var FunctionExpressionFlags;
(function (FunctionExpressionFlags) {
FunctionExpressionFlags[FunctionExpressionFlags["None"] = 1] = "None";
FunctionExpressionFlags[FunctionExpressionFlags["Inline"] = 2] = "Inline";
FunctionExpressionFlags[FunctionExpressionFlags["Declaration"] = 4] = "Declaration";
})(FunctionExpressionFlags = exports.FunctionExpressionFlags || (exports.FunctionExpressionFlags = {}));
function isFunctionExpression(node) {

@@ -363,3 +369,3 @@ return node.kind === SyntaxKind.FunctionExpression;

exports.isFunctionExpression = isFunctionExpression;
function createFunctionExpression(body, params, dots, flags = FunctionExpressionFlags.None, tsOriginal) {
function createFunctionExpression(body, params, dots, flags = NodeFlags.None, tsOriginal) {
const expression = createNode(SyntaxKind.FunctionExpression, tsOriginal);

@@ -489,5 +495,5 @@ expression.body = body;

expression.body.statements[0].expressions !== undefined &&
(expression.flags & FunctionExpressionFlags.Inline) !== 0);
(expression.flags & NodeFlags.Inline) !== 0);
}
exports.isInlineFunctionExpression = isInlineFunctionExpression;
//# sourceMappingURL=LuaAST.js.map

@@ -18,6 +18,6 @@ import { EmitHost } from "./transpilation";

ArrayPush = "ArrayPush",
ArrayPushArray = "ArrayPushArray",
ArrayReduce = "ArrayReduce",
ArrayReduceRight = "ArrayReduceRight",
ArrayReverse = "ArrayReverse",
ArrayShift = "ArrayShift",
ArrayUnshift = "ArrayUnshift",

@@ -82,3 +82,2 @@ ArraySort = "ArraySort",

StringCharCodeAt = "StringCharCodeAt",
StringConcat = "StringConcat",
StringEndsWith = "StringEndsWith",

@@ -85,0 +84,0 @@ StringIncludes = "StringIncludes",

@@ -22,6 +22,6 @@ "use strict";

LuaLibFeature["ArrayPush"] = "ArrayPush";
LuaLibFeature["ArrayPushArray"] = "ArrayPushArray";
LuaLibFeature["ArrayReduce"] = "ArrayReduce";
LuaLibFeature["ArrayReduceRight"] = "ArrayReduceRight";
LuaLibFeature["ArrayReverse"] = "ArrayReverse";
LuaLibFeature["ArrayShift"] = "ArrayShift";
LuaLibFeature["ArrayUnshift"] = "ArrayUnshift";

@@ -86,3 +86,2 @@ LuaLibFeature["ArraySort"] = "ArraySort";

LuaLibFeature["StringCharCodeAt"] = "StringCharCodeAt";
LuaLibFeature["StringConcat"] = "StringConcat";
LuaLibFeature["StringEndsWith"] = "StringEndsWith";

@@ -89,0 +88,0 @@ LuaLibFeature["StringIncludes"] = "StringIncludes";

@@ -48,3 +48,2 @@ {

"dependencies": [
"ArrayPush",
"Iterator"

@@ -83,2 +82,7 @@ ]

},
"ArrayPushArray": {
"exports": [
"__TS__ArrayPushArray"
]
},
"ArrayReduce": {

@@ -99,7 +103,2 @@ "exports": [

},
"ArrayShift": {
"exports": [
"__TS__ArrayShift"
]
},
"ArrayUnshift": {

@@ -141,3 +140,3 @@ "exports": [

"ArrayIsArray",
"ArrayConcat"
"ArrayFlat"
]

@@ -150,4 +149,3 @@ },

"dependencies": [
"ArrayIsArray",
"ArrayConcat"
"ArrayIsArray"
]

@@ -241,3 +239,4 @@ },

"dependencies": [
"Unpack"
"Unpack",
"ArrayUnshift"
]

@@ -399,4 +398,3 @@ },

"Class",
"FunctionBind",
"ArrayPush"
"FunctionBind"
]

@@ -433,3 +431,2 @@ },

"Promise",
"ArrayPush",
"Iterator",

@@ -446,3 +443,2 @@ "New"

"Promise",
"ArrayPush",
"Iterator",

@@ -533,7 +529,2 @@ "New"

},
"StringConcat": {
"exports": [
"__TS__StringConcat"
]
},
"StringEndsWith": {

@@ -567,2 +558,5 @@ "exports": [

"__TS__StringReplaceAll"
],
"dependencies": [
"StringSplit"
]

@@ -578,6 +572,2 @@ },

"__TS__StringSplit"
],
"dependencies": [
"StringAccess",
"StringSubstring"
]

@@ -584,0 +574,0 @@ },

@@ -294,4 +294,3 @@ "use strict";

chunks.push(this.indent());
if (lua.isFunctionDefinition(statement) &&
(statement.right[0].flags & lua.FunctionExpressionFlags.Declaration) !== 0) {
if (lua.isFunctionDefinition(statement) && (statement.right[0].flags & lua.NodeFlags.Declaration) !== 0) {
// Use `function foo()` instead of `foo = function()`

@@ -298,0 +297,0 @@ const name = this.printExpression(statement.left[0]);

@@ -6,3 +6,3 @@ import * as ts from "typescript";

export declare function transformArrayConstructorCall(context: TransformationContext, node: PropertyCallExpression): lua.Expression | undefined;
export declare function transformArrayPrototypeCall(context: TransformationContext, node: PropertyCallExpression): lua.CallExpression | undefined;
export declare function transformArrayPrototypeCall(context: TransformationContext, node: PropertyCallExpression): lua.Expression | undefined;
export declare function transformArrayProperty(context: TransformationContext, node: ts.PropertyAccessExpression): lua.UnaryExpression | undefined;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformArrayProperty = exports.transformArrayPrototypeCall = exports.transformArrayConstructorCall = void 0;
const ts = require("typescript");
const lua = require("../../LuaAST");

@@ -9,2 +10,3 @@ const diagnostics_1 = require("../utils/diagnostics");

const typescript_1 = require("../utils/typescript");
const expression_list_1 = require("../visitors/expression-list");
const lua_ast_1 = require("../utils/lua-ast");

@@ -28,2 +30,21 @@ function transformArrayConstructorCall(context, node) {

exports.transformArrayConstructorCall = transformArrayConstructorCall;
/**
* Optimized single element Array.push
*
* array[#array+1] = el
* return (#array + 1)
*/
function transformSingleElementArrayPush(context, node, caller, param) {
const expressionIsUsed = !ts.isExpressionStatement((0, typescript_1.findFirstNonOuterParent)(node));
const arrayIdentifier = lua.isIdentifier(caller) ? caller : (0, expression_list_1.moveToPrecedingTemp)(context, caller);
// #array + 1
let lengthExpression = lua.createBinaryExpression(lua.createUnaryExpression(arrayIdentifier, lua.SyntaxKind.LengthOperator), lua.createNumericLiteral(1), lua.SyntaxKind.AdditionOperator);
if (expressionIsUsed) {
// store length in a temp
lengthExpression = (0, expression_list_1.moveToPrecedingTemp)(context, lengthExpression);
}
const pushStatement = lua.createAssignmentStatement(lua.createTableIndexExpression(arrayIdentifier, lengthExpression), param, node);
context.addPrecedingStatements(pushStatement);
return expressionIsUsed ? lengthExpression : lua.createNilLiteral();
}
function transformArrayPrototypeCall(context, node) {

@@ -40,2 +61,11 @@ const expression = node.expression;

case "push":
if (node.arguments.length === 1) {
const param = params[0];
if ((0, lua_ast_1.isUnpackCall)(param)) {
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayPushArray, node, caller, param.params[0]);
}
if (!lua.isDotsLiteral(param)) {
return transformSingleElementArrayPush(context, node, caller, param);
}
}
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayPush, node, caller, ...params);

@@ -45,3 +75,3 @@ case "reverse":

case "shift":
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayShift, node, caller);
return lua.createCallExpression(lua.createTableIndexExpression(lua.createIdentifier("table"), lua.createStringLiteral("remove")), [caller, lua.createNumericLiteral(1)], node);
case "unshift":

@@ -84,2 +114,3 @@ return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.ArrayUnshift, node, caller, ...params);

const defaultSeparatorLiteral = lua.createStringLiteral(",");
const param = params[0];
const parameters = [

@@ -89,3 +120,5 @@ caller,

? defaultSeparatorLiteral
: lua.createBinaryExpression(params[0], defaultSeparatorLiteral, lua.SyntaxKind.OrOperator),
: lua.isStringLiteral(param)
? param
: lua.createBinaryExpression(param, defaultSeparatorLiteral, lua.SyntaxKind.OrOperator),
];

@@ -92,0 +125,0 @@ return lua.createCallExpression(lua.createTableIndexExpression(lua.createIdentifier("table"), lua.createStringLiteral("concat")), parameters, node);

@@ -8,1 +8,2 @@ import * as ts from "typescript";

export declare function transformPromiseConstructorCall(context: TransformationContext, node: PropertyCallExpression): lua.Expression | undefined;
export declare function createStaticPromiseFunctionAccessor(functionName: string, node: ts.Node): lua.TableIndexExpression;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformPromiseConstructorCall = exports.createPromiseIdentifier = exports.isPromiseClass = void 0;
exports.createStaticPromiseFunctionAccessor = exports.transformPromiseConstructorCall = exports.createPromiseIdentifier = exports.isPromiseClass = void 0;
const lua = require("../../LuaAST");

@@ -46,2 +46,3 @@ const diagnostics_1 = require("../utils/diagnostics");

}
exports.createStaticPromiseFunctionAccessor = createStaticPromiseFunctionAccessor;
//# sourceMappingURL=promise.js.map

@@ -24,3 +24,3 @@ "use strict";

case "concat":
return (0, lualib_1.transformLuaLibFunction)(context, lualib_1.LuaLibFeature.StringConcat, node, caller, ...params);
return lua.createCallExpression(lua.createTableIndexExpression(lua.createIdentifier("table"), lua.createStringLiteral("concat")), [(0, lua_ast_1.wrapInTable)(caller, ...params)], node);
case "indexOf": {

@@ -27,0 +27,0 @@ const stringExpression = createStringCall("find", node, caller, params[0], params[1]

import * as ts from "typescript";
import { LuaTarget } from "../../CompilerOptions";
import { LuaTarget, TypeScriptToLuaOptions } from "../../CompilerOptions";
import { AnnotationKind } from "./annotations";

@@ -46,5 +46,9 @@ export declare const unsupportedNodeKind: ((node: ts.Node, kind: ts.SyntaxKind) => ts.Diagnostic) & {

};
export declare const unsupportedForTarget: ((node: ts.Node, functionality: string, version: LuaTarget.Lua51 | LuaTarget.Lua52 | LuaTarget.Lua53 | LuaTarget.Lua54 | LuaTarget.LuaJIT) => ts.Diagnostic) & {
declare type NonUniversalTarget = Exclude<LuaTarget, LuaTarget.Universal>;
export declare const unsupportedForTarget: ((node: ts.Node, functionality: string, version: NonUniversalTarget) => ts.Diagnostic) & {
code: number;
};
export declare const unsupportedForTargetButOverrideAvailable: ((node: ts.Node, functionality: string, version: NonUniversalTarget, optionName: keyof TypeScriptToLuaOptions) => ts.Diagnostic) & {
code: number;
};
export declare const unsupportedProperty: ((node: ts.Node, parentName: string, property: string) => ts.Diagnostic) & {

@@ -101,1 +105,2 @@ code: number;

};
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.undefinedInArrayLiteral = exports.unsupportedOptionalCompileMembersOnly = exports.unsupportedBuiltinOptionalCall = exports.awaitMustBeInAsyncFunction = exports.notAllowedOptionalAssignment = exports.annotationDeprecated = exports.annotationRemoved = exports.invalidTableExtensionUse = exports.invalidOperatorMappingUse = exports.invalidMultiReturnAccess = exports.invalidMultiTypeToEmptyPatternOrArrayLiteral = exports.invalidMultiTypeToNonArrayLiteral = exports.invalidMultiFunctionReturnType = exports.invalidMultiFunctionUse = exports.unsupportedVarDeclaration = exports.invalidAmbientIdentifierName = exports.unsupportedProperty = exports.unsupportedForTarget = exports.unsupportedRightShiftOperator = exports.unsupportedAccessorInObjectLiteral = exports.invalidPairsIterableWithoutDestructuring = exports.invalidMultiIterableWithoutDestructuring = exports.invalidRangeControlVariable = exports.invalidVarargUse = exports.invalidRangeUse = exports.annotationInvalidArgumentCount = exports.decoratorInvalidContext = exports.unsupportedOverloadAssignment = exports.unsupportedSelfFunctionConversion = exports.unsupportedNoSelfFunctionConversion = exports.forbiddenForIn = exports.unsupportedNodeKind = void 0;
exports.undefinedInArrayLiteral = exports.unsupportedOptionalCompileMembersOnly = exports.unsupportedBuiltinOptionalCall = exports.awaitMustBeInAsyncFunction = exports.notAllowedOptionalAssignment = exports.annotationDeprecated = exports.annotationRemoved = exports.invalidTableExtensionUse = exports.invalidOperatorMappingUse = exports.invalidMultiReturnAccess = exports.invalidMultiTypeToEmptyPatternOrArrayLiteral = exports.invalidMultiTypeToNonArrayLiteral = exports.invalidMultiFunctionReturnType = exports.invalidMultiFunctionUse = exports.unsupportedVarDeclaration = exports.invalidAmbientIdentifierName = exports.unsupportedProperty = exports.unsupportedForTargetButOverrideAvailable = exports.unsupportedForTarget = exports.unsupportedRightShiftOperator = exports.unsupportedAccessorInObjectLiteral = exports.invalidPairsIterableWithoutDestructuring = exports.invalidMultiIterableWithoutDestructuring = exports.invalidRangeControlVariable = exports.invalidVarargUse = exports.invalidRangeUse = exports.annotationInvalidArgumentCount = exports.decoratorInvalidContext = exports.unsupportedOverloadAssignment = exports.unsupportedSelfFunctionConversion = exports.unsupportedNoSelfFunctionConversion = exports.forbiddenForIn = exports.unsupportedNodeKind = void 0;
const ts = require("typescript");

@@ -44,2 +44,5 @@ const CompilerOptions_1 = require("../../CompilerOptions");

exports.unsupportedForTarget = createErrorDiagnosticFactory((functionality, version) => `${functionality} is/are not supported for target ${getLuaTargetName(version)}.`);
exports.unsupportedForTargetButOverrideAvailable = createErrorDiagnosticFactory((functionality, version, optionName) => `As a precaution, ${functionality} is/are not supported for target ${getLuaTargetName(version)} due to language features/limitations. ` +
`However "--${optionName}" can be used to bypass this precaution. ` +
"See https://typescripttolua.github.io/docs/configuration for more information.");
exports.unsupportedProperty = createErrorDiagnosticFactory((parentName, property) => `${parentName}.${property} is unsupported.`);

@@ -46,0 +49,0 @@ exports.invalidAmbientIdentifierName = createErrorDiagnosticFactory((text) => `Invalid ambient identifier name '${text}'. Ambient identifiers must be valid lua identifiers.`);

@@ -11,2 +11,3 @@ import * as ts from "typescript";

export declare function createUnpackCall(context: TransformationContext, expression: lua.Expression, tsOriginal?: ts.Node): lua.Expression;
export declare function isUnpackCall(node: lua.Node): boolean;
export declare function wrapInTable(...expressions: lua.Expression[]): lua.TableExpression;

@@ -13,0 +14,0 @@ export declare function wrapInToStringForConcat(expression: lua.Expression): lua.Expression;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createNaN = exports.createLocalOrExportedOrGlobalDeclaration = exports.createHoistableVariableDeclarationStatement = exports.wrapInToStringForConcat = exports.wrapInTable = exports.createUnpackCall = exports.getNumberLiteralValue = exports.addToNumericExpression = exports.createExportsIdentifier = exports.createSelfIdentifier = exports.unwrapVisitorResult = void 0;
exports.createNaN = exports.createLocalOrExportedOrGlobalDeclaration = exports.createHoistableVariableDeclarationStatement = exports.wrapInToStringForConcat = exports.wrapInTable = exports.isUnpackCall = exports.createUnpackCall = exports.getNumberLiteralValue = exports.addToNumericExpression = exports.createExportsIdentifier = exports.createSelfIdentifier = exports.unwrapVisitorResult = void 0;
const ts = require("typescript");

@@ -65,5 +65,9 @@ const CompilerOptions_1 = require("../../CompilerOptions");

: lua.createTableIndexExpression(lua.createIdentifier("table"), lua.createStringLiteral("unpack"));
return lua.createCallExpression(unpack, [expression], tsOriginal);
return lua.setNodeFlags(lua.createCallExpression(unpack, [expression], tsOriginal), lua.NodeFlags.TableUnpackCall);
}
exports.createUnpackCall = createUnpackCall;
function isUnpackCall(node) {
return lua.isCallExpression(node) && (node.flags & lua.NodeFlags.TableUnpackCall) !== 0;
}
exports.isUnpackCall = isUnpackCall;
function wrapInTable(...expressions) {

@@ -70,0 +74,0 @@ const fields = expressions.map(e => lua.createTableFieldExpression(e));

@@ -10,2 +10,3 @@ import * as ts from "typescript";

export declare function findFirstNodeAbove<T extends ts.Node>(node: ts.Node, callback: (n: ts.Node) => n is T): T | undefined;
export declare function findFirstNonOuterParent(node: ts.Node): ts.Node;
export declare function getFirstDeclarationInFile(symbol: ts.Symbol, sourceFile: ts.SourceFile): ts.Declaration | undefined;

@@ -12,0 +13,0 @@ export declare function isStandardLibraryType(context: TransformationContext, type: ts.Type, name: string | undefined): boolean;

@@ -17,3 +17,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.isConstIdentifier = exports.getFunctionTypeForCall = exports.isExpressionWithEvaluationEffect = exports.getAllCallSignatures = exports.inferAssignedType = exports.hasStandardLibrarySignature = exports.isStandardLibraryType = exports.getFirstDeclarationInFile = exports.findFirstNodeAbove = exports.hasExportEquals = void 0;
exports.isConstIdentifier = exports.getFunctionTypeForCall = exports.isExpressionWithEvaluationEffect = exports.getAllCallSignatures = exports.inferAssignedType = exports.hasStandardLibrarySignature = exports.isStandardLibraryType = exports.getFirstDeclarationInFile = exports.findFirstNonOuterParent = exports.findFirstNodeAbove = exports.hasExportEquals = void 0;
const ts = require("typescript");

@@ -42,2 +42,10 @@ __exportStar(require("./nodes"), exports);

exports.findFirstNodeAbove = findFirstNodeAbove;
function findFirstNonOuterParent(node) {
let current = node.parent;
while (ts.isOuterExpression(current)) {
current = current.parent;
}
return current;
}
exports.findFirstNonOuterParent = findFirstNonOuterParent;
function getFirstDeclarationInFile(symbol, sourceFile) {

@@ -44,0 +52,0 @@ var _a, _b;

@@ -20,2 +20,3 @@ "use strict";

const language_extensions_1 = require("./language-extensions");
const import_1 = require("./modules/import");
function validateArguments(context, params, signature) {

@@ -149,2 +150,5 @@ if (!signature || signature.parameters.length < params.length) {

var _a;
if (node.expression.kind === ts.SyntaxKind.ImportKeyword) {
return (0, import_1.transformImportExpression)(node, context);
}
if (ts.isOptionalChain(node)) {

@@ -151,0 +155,0 @@ return (0, optional_chaining_1.transformOptionalChain)(context, node);

@@ -99,3 +99,3 @@ "use strict";

constructorBody.unshift(superCall);
const constructorFunction = lua.createFunctionExpression(lua.createBlock(constructorBody), [(0, lua_ast_1.createSelfIdentifier)()], lua.createDotsLiteral(), lua.FunctionExpressionFlags.Declaration);
const constructorFunction = lua.createFunctionExpression(lua.createBlock(constructorBody), [(0, lua_ast_1.createSelfIdentifier)()], lua.createDotsLiteral(), lua.NodeFlags.Declaration);
result.push(lua.createAssignmentStatement((0, constructor_1.createConstructorName)(localClassName), constructorFunction, classDeclaration));

@@ -102,0 +102,0 @@ }

@@ -14,3 +14,3 @@ "use strict";

const body = node.body ? (0, function_1.transformFunctionBody)(context, node.parameters, node.body, restParam)[0] : [];
return lua.createFunctionExpression(lua.createBlock(body), params, dot, lua.FunctionExpressionFlags.Declaration);
return lua.createFunctionExpression(lua.createBlock(body), params, dot, lua.NodeFlags.Declaration);
}

@@ -17,0 +17,0 @@ function transformAccessorDeclarations(context, { firstAccessor, getAccessor, setAccessor }, className) {

@@ -62,5 +62,5 @@ "use strict";

(0, scope_1.popScope)(context);
return lua.createAssignmentStatement(createConstructorName(className), lua.createFunctionExpression(block, params, dotsLiteral, lua.FunctionExpressionFlags.Declaration), constructorWasGenerated ? classDeclaration : statement);
return lua.createAssignmentStatement(createConstructorName(className), lua.createFunctionExpression(block, params, dotsLiteral, lua.NodeFlags.Declaration), constructorWasGenerated ? classDeclaration : statement);
}
exports.transformConstructorDeclaration = transformConstructorDeclaration;
//# sourceMappingURL=constructor.js.map

@@ -17,4 +17,6 @@ "use strict";

const [tryBlock, tryScope] = (0, block_1.transformScopeBlock)(context, statement.tryBlock, scope_1.ScopeType.Try);
if (context.options.luaTarget === __1.LuaTarget.Lua51 && (0, typescript_1.isInAsyncFunction)(statement)) {
context.diagnostics.push((0, diagnostics_1.unsupportedForTarget)(statement, "try/catch inside async functions", __1.LuaTarget.Lua51));
if (context.options.luaTarget === __1.LuaTarget.Lua51 &&
(0, typescript_1.isInAsyncFunction)(statement) &&
!context.options.lua51AllowTryCatchInAsyncAwait) {
context.diagnostics.push((0, diagnostics_1.unsupportedForTargetButOverrideAvailable)(statement, "try/catch inside async functions", __1.LuaTarget.Lua51, "lua51AllowTryCatchInAsyncAwait"));
return tryBlock.statements;

@@ -21,0 +23,0 @@ }

@@ -49,3 +49,3 @@ "use strict";

lua.createReturnStatement([lua.createCallExpression(functionExpression, [lua.createDotsLiteral()])]),
]), [lua.createAnonymousIdentifier()], lua.createDotsLiteral(), lua.FunctionExpressionFlags.Inline);
]), [lua.createAnonymousIdentifier()], lua.createDotsLiteral(), lua.NodeFlags.Inline);
}

@@ -173,7 +173,7 @@ return lua.createCallExpression(lua.createIdentifier("setmetatable"), [

}
let flags = lua.FunctionExpressionFlags.None;
let flags = lua.NodeFlags.None;
if (!ts.isBlock(node.body))
flags |= lua.FunctionExpressionFlags.Inline;
flags |= lua.NodeFlags.Inline;
if (ts.isFunctionDeclaration(node) || ts.isMethodDeclaration(node)) {
flags |= lua.FunctionExpressionFlags.Declaration;
flags |= lua.NodeFlags.Declaration;
}

@@ -180,0 +180,0 @@ const [paramNames, dotsLiteral, spreadIdentifier] = transformParameters(context, node.parameters, functionContext);

@@ -8,1 +8,2 @@ import * as ts from "typescript";

export declare const transformImportEqualsDeclaration: FunctionVisitor<ts.ImportEqualsDeclaration>;
export declare const transformImportExpression: FunctionVisitor<ts.CallExpression>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformImportEqualsDeclaration = exports.transformExternalModuleReference = exports.transformImportDeclaration = exports.createModuleRequire = void 0;
exports.transformImportExpression = exports.transformImportEqualsDeclaration = exports.transformExternalModuleReference = exports.transformImportDeclaration = exports.createModuleRequire = void 0;
const path = require("path");
const ts = require("typescript");
const lua = require("../../../LuaAST");
const promise_1 = require("../../builtins/promise");
const annotations_1 = require("../../utils/annotations");
const export_1 = require("../../utils/export");
const lua_ast_1 = require("../../utils/lua-ast");
const lualib_1 = require("../../utils/lualib");
const safe_names_1 = require("../../utils/safe-names");

@@ -116,2 +118,8 @@ const scope_1 = require("../../utils/scope");

exports.transformImportEqualsDeclaration = transformImportEqualsDeclaration;
const transformImportExpression = (node, context) => {
(0, lualib_1.importLuaLibFeature)(context, lualib_1.LuaLibFeature.Promise);
const importPath = node.arguments.map(a => context.transformExpression(a));
return lua.createCallExpression((0, promise_1.createStaticPromiseFunctionAccessor)("resolve", node), importPath, node);
};
exports.transformImportExpression = transformImportExpression;
//# sourceMappingURL=import.js.map

@@ -14,11 +14,5 @@ "use strict";

const vararg_1 = require("./language-extensions/vararg");
function skipOuterExpressionParents(node) {
while (ts.isOuterExpression(node)) {
node = node.parent;
}
return node;
}
function isOptimizedVarArgSpread(context, symbol, identifier) {
var _a;
if (!ts.isSpreadElement(skipOuterExpressionParents(identifier.parent))) {
if (!ts.isSpreadElement((0, typescript_1.findFirstNonOuterParent)(identifier))) {
return false;

@@ -25,0 +19,0 @@ }

{
"name": "typescript-to-lua",
"version": "1.4.2",
"version": "1.4.3",
"description": "A generic TypeScript to Lua transpiler. Write your code in TypeScript and publish Lua!",

@@ -5,0 +5,0 @@ "repository": "https://github.com/TypeScriptToLua/TypeScriptToLua",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc