Socket
Socket
Sign inDemoInstall

typescript-to-lua

Package Overview
Dependencies
Maintainers
2
Versions
157
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typescript-to-lua - npm Package Compare versions

Comparing version 0.37.1 to 0.38.0

dist/lualib/ArrayIsArray.lua

2

dist/LuaLib.d.ts

@@ -11,2 +11,3 @@ import { EmitHost } from "./transpilation";

ArrayIndexOf = "ArrayIndexOf",
ArrayIsArray = "ArrayIsArray",
ArrayJoin = "ArrayJoin",

@@ -70,2 +71,3 @@ ArrayMap = "ArrayMap",

StringEndsWith = "StringEndsWith",
StringIncludes = "StringIncludes",
StringPadEnd = "StringPadEnd",

@@ -72,0 +74,0 @@ StringPadStart = "StringPadStart",

8

dist/LuaLib.js

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

LuaLibFeature["ArrayIndexOf"] = "ArrayIndexOf";
LuaLibFeature["ArrayIsArray"] = "ArrayIsArray";
LuaLibFeature["ArrayJoin"] = "ArrayJoin";

@@ -74,2 +75,3 @@ LuaLibFeature["ArrayMap"] = "ArrayMap";

LuaLibFeature["StringEndsWith"] = "StringEndsWith";
LuaLibFeature["StringIncludes"] = "StringIncludes";
LuaLibFeature["StringPadEnd"] = "StringPadEnd";

@@ -92,4 +94,5 @@ LuaLibFeature["StringPadStart"] = "StringPadStart";

const luaLibDependencies = {
ArrayFlat: [LuaLibFeature.ArrayConcat],
ArrayFlatMap: [LuaLibFeature.ArrayConcat],
ArrayConcat: [LuaLibFeature.ArrayIsArray],
ArrayFlat: [LuaLibFeature.ArrayConcat, LuaLibFeature.ArrayIsArray],
ArrayFlatMap: [LuaLibFeature.ArrayConcat, LuaLibFeature.ArrayIsArray],
Decorate: [LuaLibFeature.CloneDescriptor],

@@ -109,2 +112,3 @@ Delete: [LuaLibFeature.ObjectGetOwnPropertyDescriptors],

Spread: [LuaLibFeature.Iterator, LuaLibFeature.Unpack],
StringSplit: [LuaLibFeature.StringSubstring],
SymbolRegistry: [LuaLibFeature.Symbol],

@@ -111,0 +115,0 @@ };

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

import { PropertyCallExpression } from "../visitors/call";
export declare function transformArrayConstructorCall(context: TransformationContext, node: PropertyCallExpression): lua.CallExpression | undefined;
export declare function transformArrayPrototypeCall(context: TransformationContext, node: PropertyCallExpression): lua.CallExpression | 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 = void 0;
exports.transformArrayProperty = exports.transformArrayPrototypeCall = exports.transformArrayConstructorCall = void 0;
const lua = require("../../LuaAST");

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

const typescript_1 = require("../utils/typescript");
function transformArrayConstructorCall(context, node) {
const expression = node.expression;
const signature = context.checker.getResolvedSignature(node);
const params = call_1.transformArguments(context, node.arguments, signature);
const expressionName = expression.name.text;
switch (expressionName) {
case "isArray":
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.ArrayIsArray, node, ...params);
default:
context.diagnostics.push(diagnostics_1.unsupportedProperty(expression.name, "Array", expressionName));
}
}
exports.transformArrayConstructorCall = transformArrayConstructorCall;
function transformArrayPrototypeCall(context, node) {

@@ -11,0 +24,0 @@ const expression = node.expression;

@@ -61,2 +61,4 @@ "use strict";

switch (symbol === null || symbol === void 0 ? void 0 : symbol.name) {
case "ArrayConstructor":
return array_1.transformArrayConstructorCall(context, node);
case "Console":

@@ -63,0 +65,0 @@ return console_1.transformConsoleCall(context, node);

@@ -92,2 +92,4 @@ "use strict";

return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.StringEndsWith, node, caller, ...params);
case "includes":
return lualib_1.transformLuaLibFunction(context, lualib_1.LuaLibFeature.StringIncludes, node, caller, ...params);
case "repeat":

@@ -94,0 +96,0 @@ const math = lua.createIdentifier("math");

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

};
export declare const invalidRangeUse: ((node: ts.Node, ...args: any[]) => ts.Diagnostic) & {
code: number;
};
export declare const invalidRangeControlVariable: ((node: ts.Node, ...args: any[]) => ts.Diagnostic) & {
code: number;
};
export declare const luaTableMustBeAmbient: ((node: ts.Node, ...args: any[]) => ts.Diagnostic) & {

@@ -89,3 +95,3 @@ code: number;

};
export declare const invalidMultiTypeToNonArrayBindingPattern: ((node: ts.Node, ...args: any[]) => ts.Diagnostic) & {
export declare const invalidMultiFunctionReturnType: ((node: ts.Node, ...args: any[]) => ts.Diagnostic) & {
code: number;

@@ -99,16 +105,13 @@ };

};
export declare const invalidMultiTypeArrayBindingPatternElementInitializer: ((node: ts.Node, ...args: any[]) => ts.Diagnostic) & {
export declare const invalidMultiReturnAccess: ((node: ts.Node, ...args: any[]) => ts.Diagnostic) & {
code: number;
};
export declare const invalidMultiTypeArrayLiteralElementInitializer: ((node: ts.Node, ...args: any[]) => ts.Diagnostic) & {
export declare const invalidOperatorMappingUse: ((node: ts.Node, ...args: any[]) => ts.Diagnostic) & {
code: number;
};
export declare const invalidMultiReturnAccess: ((node: ts.Node, ...args: any[]) => ts.Diagnostic) & {
export declare const annotationDeprecated: ((node: ts.Node, kind: AnnotationKind) => ts.Diagnostic) & {
code: number;
};
export declare const unsupportedMultiFunctionAssignment: ((node: ts.Node, ...args: any[]) => ts.Diagnostic) & {
export declare const optionalChainingNotSupported: ((node: ts.Node, ...args: any[]) => ts.Diagnostic) & {
code: number;
};
export declare const annotationDeprecated: ((node: ts.Node, kind: AnnotationKind) => ts.Diagnostic) & {
code: number;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.annotationDeprecated = exports.unsupportedMultiFunctionAssignment = exports.invalidMultiReturnAccess = exports.invalidMultiTypeArrayLiteralElementInitializer = exports.invalidMultiTypeArrayBindingPatternElementInitializer = exports.invalidMultiTypeToEmptyPatternOrArrayLiteral = exports.invalidMultiTypeToNonArrayLiteral = exports.invalidMultiTypeToNonArrayBindingPattern = exports.invalidMultiFunctionUse = exports.unsupportedVarDeclaration = exports.unresolvableRequirePath = exports.invalidAmbientIdentifierName = exports.unsupportedProperty = exports.unsupportedForTarget = exports.unsupportedRightShiftOperator = exports.unsupportedAccessorInObjectLiteral = exports.luaIteratorForbiddenUsage = exports.luaTableForbiddenUsage = exports.luaTableCannotBeAccessedDynamically = exports.luaTableInvalidInstanceOf = exports.luaTableCannotBeExtended = exports.luaTableMustBeAmbient = exports.invalidForRangeCall = exports.metaExtensionMissingExtends = exports.extensionAndMetaExtensionConflict = exports.extensionInvalidInstanceOf = exports.extensionCannotExport = exports.extensionCannotExtend = exports.extensionCannotConstruct = exports.annotationInvalidArgumentCount = exports.decoratorInvalidContext = exports.unsupportedOverloadAssignment = exports.unsupportedSelfFunctionConversion = exports.unsupportedNoSelfFunctionConversion = exports.forbiddenForIn = exports.unsupportedNodeKind = void 0;
exports.optionalChainingNotSupported = exports.annotationDeprecated = exports.invalidOperatorMappingUse = exports.invalidMultiReturnAccess = exports.invalidMultiTypeToEmptyPatternOrArrayLiteral = exports.invalidMultiTypeToNonArrayLiteral = exports.invalidMultiFunctionReturnType = exports.invalidMultiFunctionUse = exports.unsupportedVarDeclaration = exports.unresolvableRequirePath = exports.invalidAmbientIdentifierName = exports.unsupportedProperty = exports.unsupportedForTarget = exports.unsupportedRightShiftOperator = exports.unsupportedAccessorInObjectLiteral = exports.luaIteratorForbiddenUsage = exports.luaTableForbiddenUsage = exports.luaTableCannotBeAccessedDynamically = exports.luaTableInvalidInstanceOf = exports.luaTableCannotBeExtended = exports.luaTableMustBeAmbient = exports.invalidRangeControlVariable = exports.invalidRangeUse = exports.invalidForRangeCall = exports.metaExtensionMissingExtends = exports.extensionAndMetaExtensionConflict = exports.extensionInvalidInstanceOf = exports.extensionCannotExport = exports.extensionCannotExtend = exports.extensionCannotConstruct = exports.annotationInvalidArgumentCount = exports.decoratorInvalidContext = exports.unsupportedOverloadAssignment = exports.unsupportedSelfFunctionConversion = exports.unsupportedNoSelfFunctionConversion = exports.forbiddenForIn = exports.unsupportedNodeKind = void 0;
const ts = require("typescript");

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

exports.invalidForRangeCall = createErrorDiagnosticFactory((message) => `Invalid @forRange call: ${message}.`);
exports.invalidRangeUse = createErrorDiagnosticFactory("$range can only be used in a for...of loop.");
exports.invalidRangeControlVariable = createErrorDiagnosticFactory("For loop using $range must declare a single control variable.");
exports.luaTableMustBeAmbient = createErrorDiagnosticFactory("Classes with the '@luaTable' annotation must be ambient.");

@@ -59,12 +61,11 @@ exports.luaTableCannotBeExtended = createErrorDiagnosticFactory("Cannot extend classes with the '@luaTable' annotation.");

exports.unsupportedVarDeclaration = createErrorDiagnosticFactory("`var` declarations are not supported. Use `let` or `const` instead.");
exports.invalidMultiFunctionUse = createErrorDiagnosticFactory("The $multi function must be called in an expression that is returned.");
exports.invalidMultiTypeToNonArrayBindingPattern = createErrorDiagnosticFactory("Expected an array destructuring pattern.");
exports.invalidMultiFunctionUse = createErrorDiagnosticFactory("The $multi function must be called in a return statement.");
exports.invalidMultiFunctionReturnType = createErrorDiagnosticFactory("The $multi function cannot be cast to a non-LuaMultiReturn type.");
exports.invalidMultiTypeToNonArrayLiteral = createErrorDiagnosticFactory("Expected an array literal.");
exports.invalidMultiTypeToEmptyPatternOrArrayLiteral = createErrorDiagnosticFactory("There must be one or more elements specified here.");
exports.invalidMultiTypeArrayBindingPatternElementInitializer = createErrorDiagnosticFactory("This array binding pattern cannot have initializers.");
exports.invalidMultiTypeArrayLiteralElementInitializer = createErrorDiagnosticFactory("This array literal pattern cannot have initializers.");
exports.invalidMultiReturnAccess = createErrorDiagnosticFactory("The MultiReturn type can only be accessed via an element access expression of a numeric type.");
exports.unsupportedMultiFunctionAssignment = createErrorDiagnosticFactory("Omitted expressions and BindingElements are expected here.");
exports.invalidMultiReturnAccess = createErrorDiagnosticFactory("The LuaMultiReturn type can only be accessed via an element access expression of a numeric type.");
exports.invalidOperatorMappingUse = createErrorDiagnosticFactory("This function must always be directly called and cannot be referred to.");
exports.annotationDeprecated = createWarningDiagnosticFactory((kind) => `'@${kind}' is deprecated and will be removed in a future update. Please update your code before upgrading to the next release, otherwise your project will no longer compile. ` +
`See https://typescripttolua.github.io/docs/advanced/compiler-annotations#${kind.toLowerCase()} for more information.`);
exports.optionalChainingNotSupported = createErrorDiagnosticFactory("Optional chaining is not supported yet.");
//# sourceMappingURL=diagnostics.js.map
import * as ts from "typescript";
export declare enum ExtensionKind {
MultiFunction = "MultiFunction",
MultiType = "MultiType"
MultiType = "MultiType",
RangeFunction = "RangeFunction",
AdditionOperatorType = "AdditionOperatorType",
AdditionOperatorMethodType = "AdditionOperatorMethodType",
SubtractionOperatorType = "SubtractionOperatorType",
SubtractionOperatorMethodType = "SubtractionOperatorMethodType",
MultiplicationOperatorType = "MultiplicationOperatorType",
MultiplicationOperatorMethodType = "MultiplicationOperatorMethodType",
DivisionOperatorType = "DivisionOperatorType",
DivisionOperatorMethodType = "DivisionOperatorMethodType",
ModuloOperatorType = "ModuloOperatorType",
ModuloOperatorMethodType = "ModuloOperatorMethodType",
PowerOperatorType = "PowerOperatorType",
PowerOperatorMethodType = "PowerOperatorMethodType",
FloorDivisionOperatorType = "FloorDivisionOperatorType",
FloorDivisionOperatorMethodType = "FloorDivisionOperatorMethodType",
BitwiseAndOperatorType = "BitwiseAndOperatorType",
BitwiseAndOperatorMethodType = "BitwiseAndOperatorMethodType",
BitwiseOrOperatorType = "BitwiseOrOperatorType",
BitwiseOrOperatorMethodType = "BitwiseOrOperatorMethodType",
BitwiseExclusiveOrOperatorType = "BitwiseExclusiveOrOperatorType",
BitwiseExclusiveOrOperatorMethodType = "BitwiseExclusiveOrOperatorMethodType",
BitwiseLeftShiftOperatorType = "BitwiseLeftShiftOperatorType",
BitwiseLeftShiftOperatorMethodType = "BitwiseLeftShiftOperatorMethodType",
BitwiseRightShiftOperatorType = "BitwiseRightShiftOperatorType",
BitwiseRightShiftOperatorMethodType = "BitwiseRightShiftOperatorMethodType",
ConcatOperatorType = "ConcatOperatorType",
ConcatOperatorMethodType = "ConcatOperatorMethodType",
LessThanOperatorType = "LessThanOperatorType",
LessThanOperatorMethodType = "LessThanOperatorMethodType",
GreaterThanOperatorType = "GreaterThanOperatorType",
GreaterThanOperatorMethodType = "GreaterThanOperatorMethodType",
NegationOperatorType = "NegationOperatorType",
NegationOperatorMethodType = "NegationOperatorMethodType",
BitwiseNotOperatorType = "BitwiseNotOperatorType",
BitwiseNotOperatorMethodType = "BitwiseNotOperatorMethodType",
LengthOperatorType = "LengthOperatorType",
LengthOperatorMethodType = "LengthOperatorMethodType"
}
export declare function getExtensionKind(declaration: ts.Declaration): ExtensionKind | undefined;

@@ -10,3 +10,83 @@ "use strict";

ExtensionKind["MultiType"] = "MultiType";
ExtensionKind["RangeFunction"] = "RangeFunction";
ExtensionKind["AdditionOperatorType"] = "AdditionOperatorType";
ExtensionKind["AdditionOperatorMethodType"] = "AdditionOperatorMethodType";
ExtensionKind["SubtractionOperatorType"] = "SubtractionOperatorType";
ExtensionKind["SubtractionOperatorMethodType"] = "SubtractionOperatorMethodType";
ExtensionKind["MultiplicationOperatorType"] = "MultiplicationOperatorType";
ExtensionKind["MultiplicationOperatorMethodType"] = "MultiplicationOperatorMethodType";
ExtensionKind["DivisionOperatorType"] = "DivisionOperatorType";
ExtensionKind["DivisionOperatorMethodType"] = "DivisionOperatorMethodType";
ExtensionKind["ModuloOperatorType"] = "ModuloOperatorType";
ExtensionKind["ModuloOperatorMethodType"] = "ModuloOperatorMethodType";
ExtensionKind["PowerOperatorType"] = "PowerOperatorType";
ExtensionKind["PowerOperatorMethodType"] = "PowerOperatorMethodType";
ExtensionKind["FloorDivisionOperatorType"] = "FloorDivisionOperatorType";
ExtensionKind["FloorDivisionOperatorMethodType"] = "FloorDivisionOperatorMethodType";
ExtensionKind["BitwiseAndOperatorType"] = "BitwiseAndOperatorType";
ExtensionKind["BitwiseAndOperatorMethodType"] = "BitwiseAndOperatorMethodType";
ExtensionKind["BitwiseOrOperatorType"] = "BitwiseOrOperatorType";
ExtensionKind["BitwiseOrOperatorMethodType"] = "BitwiseOrOperatorMethodType";
ExtensionKind["BitwiseExclusiveOrOperatorType"] = "BitwiseExclusiveOrOperatorType";
ExtensionKind["BitwiseExclusiveOrOperatorMethodType"] = "BitwiseExclusiveOrOperatorMethodType";
ExtensionKind["BitwiseLeftShiftOperatorType"] = "BitwiseLeftShiftOperatorType";
ExtensionKind["BitwiseLeftShiftOperatorMethodType"] = "BitwiseLeftShiftOperatorMethodType";
ExtensionKind["BitwiseRightShiftOperatorType"] = "BitwiseRightShiftOperatorType";
ExtensionKind["BitwiseRightShiftOperatorMethodType"] = "BitwiseRightShiftOperatorMethodType";
ExtensionKind["ConcatOperatorType"] = "ConcatOperatorType";
ExtensionKind["ConcatOperatorMethodType"] = "ConcatOperatorMethodType";
ExtensionKind["LessThanOperatorType"] = "LessThanOperatorType";
ExtensionKind["LessThanOperatorMethodType"] = "LessThanOperatorMethodType";
ExtensionKind["GreaterThanOperatorType"] = "GreaterThanOperatorType";
ExtensionKind["GreaterThanOperatorMethodType"] = "GreaterThanOperatorMethodType";
ExtensionKind["NegationOperatorType"] = "NegationOperatorType";
ExtensionKind["NegationOperatorMethodType"] = "NegationOperatorMethodType";
ExtensionKind["BitwiseNotOperatorType"] = "BitwiseNotOperatorType";
ExtensionKind["BitwiseNotOperatorMethodType"] = "BitwiseNotOperatorMethodType";
ExtensionKind["LengthOperatorType"] = "LengthOperatorType";
ExtensionKind["LengthOperatorMethodType"] = "LengthOperatorMethodType";
})(ExtensionKind = exports.ExtensionKind || (exports.ExtensionKind = {}));
const functionNameToExtensionKind = {
$multi: ExtensionKind.MultiFunction,
$range: ExtensionKind.RangeFunction,
};
const typeNameToExtensionKind = {
LuaMultiReturn: ExtensionKind.MultiType,
LuaAddition: ExtensionKind.AdditionOperatorType,
LuaAdditionMethod: ExtensionKind.AdditionOperatorMethodType,
LuaSubtraction: ExtensionKind.SubtractionOperatorType,
LuaSubtractionMethod: ExtensionKind.SubtractionOperatorMethodType,
LuaMultiplication: ExtensionKind.MultiplicationOperatorType,
LuaMultiplicationMethod: ExtensionKind.MultiplicationOperatorMethodType,
LuaDivision: ExtensionKind.DivisionOperatorType,
LuaDivisionMethod: ExtensionKind.DivisionOperatorMethodType,
LuaModulo: ExtensionKind.ModuloOperatorType,
LuaModuloMethod: ExtensionKind.ModuloOperatorMethodType,
LuaPower: ExtensionKind.PowerOperatorType,
LuaPowerMethod: ExtensionKind.PowerOperatorMethodType,
LuaFloorDivision: ExtensionKind.FloorDivisionOperatorType,
LuaFloorDivisionMethod: ExtensionKind.FloorDivisionOperatorMethodType,
LuaBitwiseAnd: ExtensionKind.BitwiseAndOperatorType,
LuaBitwiseAndMethod: ExtensionKind.BitwiseAndOperatorMethodType,
LuaBitwiseOr: ExtensionKind.BitwiseOrOperatorType,
LuaBitwiseOrMethod: ExtensionKind.BitwiseOrOperatorMethodType,
LuaBitwiseExclusiveOr: ExtensionKind.BitwiseExclusiveOrOperatorType,
LuaBitwiseExclusiveOrMethod: ExtensionKind.BitwiseExclusiveOrOperatorMethodType,
LuaBitwiseLeftShift: ExtensionKind.BitwiseLeftShiftOperatorType,
LuaBitwiseLeftShiftMethod: ExtensionKind.BitwiseLeftShiftOperatorMethodType,
LuaBitwiseRightShift: ExtensionKind.BitwiseRightShiftOperatorType,
LuaBitwiseRightShiftMethod: ExtensionKind.BitwiseRightShiftOperatorMethodType,
LuaConcat: ExtensionKind.ConcatOperatorType,
LuaConcatMethod: ExtensionKind.ConcatOperatorMethodType,
LuaLessThan: ExtensionKind.LessThanOperatorType,
LuaLessThanMethod: ExtensionKind.LessThanOperatorMethodType,
LuaGreaterThan: ExtensionKind.GreaterThanOperatorType,
LuaGreaterThanMethod: ExtensionKind.GreaterThanOperatorMethodType,
LuaNegation: ExtensionKind.NegationOperatorType,
LuaNegationMethod: ExtensionKind.NegationOperatorMethodType,
LuaBitwiseNot: ExtensionKind.BitwiseNotOperatorType,
LuaBitwiseNotMethod: ExtensionKind.BitwiseNotOperatorMethodType,
LuaLength: ExtensionKind.LengthOperatorType,
LuaLengthMethod: ExtensionKind.LengthOperatorMethodType,
};
function isSourceFileFromLanguageExtensions(sourceFile) {

@@ -21,7 +101,13 @@ const extensionDirectory = path.resolve(__dirname, "../../../language-extensions");

if (isSourceFileFromLanguageExtensions(sourceFile)) {
if (ts.isFunctionDeclaration(declaration) && ((_a = declaration === null || declaration === void 0 ? void 0 : declaration.name) === null || _a === void 0 ? void 0 : _a.text) === "$multi") {
return ExtensionKind.MultiFunction;
if (ts.isFunctionDeclaration(declaration) && ((_a = declaration.name) === null || _a === void 0 ? void 0 : _a.text)) {
const extensionKind = functionNameToExtensionKind[declaration.name.text];
if (extensionKind) {
return extensionKind;
}
}
if (ts.isTypeAliasDeclaration(declaration) && declaration.name.text === "MultiReturn") {
return ExtensionKind.MultiType;
if (ts.isTypeAliasDeclaration(declaration)) {
const extensionKind = typeNameToExtensionKind[declaration.name.text];
if (extensionKind) {
return extensionKind;
}
}

@@ -28,0 +114,0 @@ throw new Error("Unknown extension kind");

import * as ts from "typescript";
import { TransformationContext } from "../../context";
export declare function isAssignmentPattern(node: ts.Node): node is ts.AssignmentPattern;

@@ -6,1 +7,6 @@ export declare function isDestructuringAssignment(node: ts.Node): node is ts.DestructuringAssignment;

export declare function isInDestructingAssignment(node: ts.Node): boolean;
/**
* Quite hacky, avoid unless absolutely necessary!
*/
export declare function getSymbolOfNode(context: TransformationContext, node: ts.Node): ts.Symbol | undefined;
export declare function isFirstDeclaration(context: TransformationContext, node: ts.Node): boolean;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isInDestructingAssignment = exports.isAmbientNode = exports.isDestructuringAssignment = exports.isAssignmentPattern = void 0;
exports.isFirstDeclaration = exports.getSymbolOfNode = exports.isInDestructingAssignment = exports.isAmbientNode = exports.isDestructuringAssignment = exports.isAssignmentPattern = void 0;
const ts = require("typescript");

@@ -25,2 +25,15 @@ function isAssignmentPattern(node) {

exports.isInDestructingAssignment = isInDestructingAssignment;
/**
* Quite hacky, avoid unless absolutely necessary!
*/
function getSymbolOfNode(context, node) {
var _a;
return (_a = node.symbol) !== null && _a !== void 0 ? _a : context.checker.getSymbolAtLocation(node);
}
exports.getSymbolOfNode = getSymbolOfNode;
function isFirstDeclaration(context, node) {
const symbol = getSymbolOfNode(context, node);
return symbol ? symbol.valueDeclaration === node : true;
}
exports.isFirstDeclaration = isFirstDeclaration;
//# sourceMappingURL=nodes.js.map

@@ -51,2 +51,5 @@ "use strict";

exports.transformPropertyAccessExpression = (expression, context) => {
if (ts.isOptionalChain(expression)) {
context.diagnostics.push(diagnostics_1.optionalChainingNotSupported(expression));
}
const constEnumValue = enum_1.tryGetConstEnumValue(context, expression);

@@ -53,0 +56,0 @@ if (constEnumValue) {

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

const destructuring_assignments_1 = require("./destructuring-assignments");
const multi_1 = require("../language-extensions/multi");
function transformAssignmentLeftHandSideExpression(context, node) {

@@ -62,3 +63,3 @@ var _a;

let right = context.transformExpression(expression.right);
if (annotations_1.isTupleReturnCall(context, expression.right)) {
if (annotations_1.isTupleReturnCall(context, expression.right) || multi_1.isMultiReturnCall(context, expression.right)) {
right = lua_ast_1.wrapInTable(right);

@@ -137,3 +138,4 @@ }

let right = context.transformExpression(expression.right);
if (!annotations_1.isTupleReturnCall(context, expression.right) && typescript_1.isArrayType(context, rightType)) {
if (!(annotations_1.isTupleReturnCall(context, expression.right) || multi_1.isMultiReturnCall(context, expression.right)) &&
typescript_1.isArrayType(context, rightType)) {
right = lua_ast_1.createUnpackCall(context, right, expression.right);

@@ -145,3 +147,3 @@ }

let right = context.transformExpression(expression.right);
if (annotations_1.isTupleReturnCall(context, expression.right)) {
if (annotations_1.isTupleReturnCall(context, expression.right) || multi_1.isMultiReturnCall(context, expression.right)) {
right = lua_ast_1.wrapInTable(right);

@@ -148,0 +150,0 @@ }

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

const multi_1 = require("./language-extensions/multi");
const operators_1 = require("./language-extensions/operators");
function getExpressionsBeforeAndAfterFirstSpread(expressions) {

@@ -166,3 +167,4 @@ // [a, b, ...c, d, ...e] --> [a, b] and [...c, d, ...e]

const returnValueIsUsed = node.parent && !ts.isExpressionStatement(node.parent);
const wrapResult = isTupleReturn && !isTupleReturnForward && !typescript_1.isInDestructingAssignment(node) && !isInSpread && returnValueIsUsed;
const wrapTupleReturn = isTupleReturn && !isTupleReturnForward && !typescript_1.isInDestructingAssignment(node) && !isInSpread && returnValueIsUsed;
const wrapResult = wrapTupleReturn || multi_1.shouldMultiReturnCallBeWrapped(context, node);
const builtinResult = builtins_1.transformBuiltinCallExpression(context, node);

@@ -172,2 +174,5 @@ if (builtinResult) {

}
if (operators_1.isOperatorMapping(context, node)) {
return operators_1.transformOperatorMappingExpression(context, node);
}
if (ts.isPropertyAccessExpression(node.expression)) {

@@ -174,0 +179,0 @@ const result = transformPropertyCall(context, node);

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

const lua_ast_1 = require("../utils/lua-ast");
const typescript_1 = require("../utils/typescript");
const identifier_1 = require("./identifier");

@@ -29,5 +30,5 @@ const literal_1 = require("./literal");

const result = [];
if (!membersOnly) {
if (!membersOnly && typescript_1.isFirstDeclaration(context, node)) {
const name = identifier_1.transformIdentifier(context, node.name);
const table = lua.createTableExpression();
const table = lua.createBinaryExpression(lua.cloneIdentifier(name), lua.createTableExpression(), lua.SyntaxKind.OrOperator);
result.push(...lua_ast_1.createLocalOrExportedOrGlobalDeclaration(context, name, table, node));

@@ -34,0 +35,0 @@ }

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

const identifier_1 = require("./identifier");
const multi_1 = require("./language-extensions/multi");
exports.transformTryStatement = (statement, context) => {

@@ -74,3 +75,3 @@ const [tryBlock, tryScope] = block_1.transformScopeBlock(context, statement.tryBlock, scope_1.ScopeType.Try);

}
if (annotations_1.isInTupleReturnFunction(context, statement)) {
if (annotations_1.isInTupleReturnFunction(context, statement) || multi_1.isInMultiReturnFunction(context, statement)) {
returnValues.push(lua_ast_1.createUnpackCall(context, lua.cloneIdentifier(returnValueIdentifier)));

@@ -77,0 +78,0 @@ }

@@ -9,10 +9,3 @@ "use strict";

const unary_expression_1 = require("./unary-expression");
const multi_1 = require("./language-extensions/multi");
exports.transformExpressionStatement = (node, context) => {
if (ts.isBinaryExpression(node.expression) &&
node.expression.operatorToken.kind === ts.SyntaxKind.EqualsToken &&
ts.isCallExpression(node.expression.right) &&
multi_1.returnsMultiType(context, node.expression.right)) {
return multi_1.transformMultiDestructuringAssignmentStatement(context, node);
}
const luaTableResult = lua_table_1.transformLuaTableExpressionStatement(context, node);

@@ -19,0 +12,0 @@ if (luaTableResult) {

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

const identifier_1 = require("./identifier");
const multi_1 = require("./language-extensions/multi");
const return_1 = require("./return");

@@ -41,5 +40,2 @@ const variable_declaration_1 = require("./variable-declaration");

if (!ts.isBlock(body)) {
if (ts.isCallExpression(body) && multi_1.isMultiFunction(context, body)) {
return [multi_1.transformMultiCallExpressionToReturnStatement(context, body)];
}
const returnStatement = return_1.transformExpressionBodyToReturnStatement(context, body);

@@ -46,0 +42,0 @@ return [returnStatement];

@@ -14,2 +14,4 @@ "use strict";

const multi_1 = require("./language-extensions/multi");
const operators_1 = require("./language-extensions/operators");
const range_1 = require("./language-extensions/range");
function transformIdentifier(context, identifier) {

@@ -20,2 +22,9 @@ if (multi_1.isMultiFunctionNode(context, identifier)) {

}
if (operators_1.isOperatorMapping(context, identifier)) {
context.diagnostics.push(diagnostics_1.invalidOperatorMappingUse(identifier));
}
if (range_1.isRangeFunctionNode(context, identifier)) {
context.diagnostics.push(diagnostics_1.invalidRangeUse(identifier));
return lua.createAnonymousIdentifier(identifier);
}
if (annotations_1.isForRangeType(context, identifier)) {

@@ -22,0 +31,0 @@ const callExpression = typescript_1.findFirstNodeAbove(identifier, ts.isCallExpression);

import * as ts from "typescript";
import * as lua from "../../../LuaAST";
import { TransformationContext } from "../../context";
export declare function isMultiFunction(context: TransformationContext, expression: ts.CallExpression): boolean;
export declare function isMultiReturnType(type: ts.Type): boolean;
export declare function isMultiFunctionCall(context: TransformationContext, expression: ts.CallExpression): boolean;
export declare function returnsMultiType(context: TransformationContext, node: ts.CallExpression): boolean;
export declare function isMultiReturnCall(context: TransformationContext, expression: ts.Expression): boolean;
export declare function isMultiFunctionNode(context: TransformationContext, node: ts.Node): boolean;
export declare function transformMultiCallExpressionToReturnStatement(context: TransformationContext, expression: ts.Expression): lua.Statement;
export declare function transformMultiReturnStatement(context: TransformationContext, statement: ts.ReturnStatement): lua.Statement;
export declare function transformMultiVariableDeclaration(context: TransformationContext, declaration: ts.VariableDeclaration): lua.Statement[];
export declare function transformMultiDestructuringAssignmentStatement(context: TransformationContext, statement: ts.ExpressionStatement): lua.Statement[] | undefined;
export declare function isInMultiReturnFunction(context: TransformationContext, node: ts.Node): boolean;
export declare function shouldMultiReturnCallBeWrapped(context: TransformationContext, node: ts.CallExpression): boolean;
export declare function findMultiAssignmentViolations(context: TransformationContext, node: ts.ObjectLiteralExpression): ts.Node[];
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findMultiAssignmentViolations = exports.transformMultiDestructuringAssignmentStatement = exports.transformMultiVariableDeclaration = exports.transformMultiReturnStatement = exports.transformMultiCallExpressionToReturnStatement = exports.isMultiFunctionNode = exports.returnsMultiType = exports.isMultiFunction = void 0;
exports.findMultiAssignmentViolations = exports.shouldMultiReturnCallBeWrapped = exports.isInMultiReturnFunction = exports.isMultiFunctionNode = exports.isMultiReturnCall = exports.returnsMultiType = exports.isMultiFunctionCall = exports.isMultiReturnType = void 0;
const ts = require("typescript");
const lua = require("../../../LuaAST");
const extensions = require("../../utils/language-extensions");
const assignments_1 = require("../binary-expression/assignments");
const identifier_1 = require("../identifier");
const call_1 = require("../call");
const export_1 = require("../../utils/export");
const lua_ast_1 = require("../../utils/lua-ast");
const diagnostics_1 = require("../../utils/diagnostics");
const utils_1 = require("../../../utils");
const typescript_1 = require("../../utils/typescript");
const isMultiFunctionDeclaration = (declaration) => extensions.getExtensionKind(declaration) === extensions.ExtensionKind.MultiFunction;
const isMultiTypeDeclaration = (declaration) => extensions.getExtensionKind(declaration) === extensions.ExtensionKind.MultiType;
function isMultiFunction(context, expression) {
function isMultiReturnType(type) {
var _a, _b, _c;
return (_c = (_b = (_a = type.aliasSymbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b.some(isMultiTypeDeclaration)) !== null && _c !== void 0 ? _c : false;
}
exports.isMultiReturnType = isMultiReturnType;
function isMultiFunctionCall(context, expression) {
var _a, _b, _c;
const type = context.checker.getTypeAtLocation(expression.expression);
return (_c = (_b = (_a = type.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b.some(isMultiFunctionDeclaration)) !== null && _c !== void 0 ? _c : false;
}
exports.isMultiFunction = isMultiFunction;
exports.isMultiFunctionCall = isMultiFunctionCall;
function returnsMultiType(context, node) {
var _a, _b, _c;
const signature = context.checker.getResolvedSignature(node);
return (_c = (_b = (_a = signature === null || signature === void 0 ? void 0 : signature.getReturnType().aliasSymbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b.some(isMultiTypeDeclaration)) !== null && _c !== void 0 ? _c : false;
const type = signature === null || signature === void 0 ? void 0 : signature.getReturnType();
return type ? isMultiReturnType(type) : false;
}
exports.returnsMultiType = returnsMultiType;
function isMultiReturnCall(context, expression) {
return ts.isCallExpression(expression) && returnsMultiType(context, expression);
}
exports.isMultiReturnCall = isMultiReturnCall;
function isMultiFunctionNode(context, node) {

@@ -34,94 +37,46 @@ var _a, _b, _c;

exports.isMultiFunctionNode = isMultiFunctionNode;
function transformMultiCallExpressionToReturnStatement(context, expression) {
utils_1.assert(ts.isCallExpression(expression));
const expressions = call_1.transformArguments(context, expression.arguments);
return lua.createReturnStatement(expressions, expression);
}
exports.transformMultiCallExpressionToReturnStatement = transformMultiCallExpressionToReturnStatement;
function transformMultiReturnStatement(context, statement) {
utils_1.assert(statement.expression);
return transformMultiCallExpressionToReturnStatement(context, statement.expression);
}
exports.transformMultiReturnStatement = transformMultiReturnStatement;
function transformMultiFunctionArguments(context, expression) {
if (!isMultiFunction(context, expression)) {
return context.transformExpression(expression);
function isInMultiReturnFunction(context, node) {
const declaration = typescript_1.findFirstNodeAbove(node, ts.isFunctionLike);
if (!declaration) {
return false;
}
if (expression.arguments.length === 0) {
return lua.createNilLiteral(expression);
}
return expression.arguments.map(e => context.transformExpression(e));
const signature = context.checker.getSignatureFromDeclaration(declaration);
const type = signature === null || signature === void 0 ? void 0 : signature.getReturnType();
return type ? isMultiReturnType(type) : false;
}
function transformMultiVariableDeclaration(context, declaration) {
utils_1.assert(declaration.initializer);
utils_1.assert(ts.isCallExpression(declaration.initializer));
if (!ts.isArrayBindingPattern(declaration.name)) {
context.diagnostics.push(diagnostics_1.invalidMultiTypeToNonArrayBindingPattern(declaration.name));
return [];
exports.isInMultiReturnFunction = isInMultiReturnFunction;
function shouldMultiReturnCallBeWrapped(context, node) {
if (!returnsMultiType(context, node)) {
return false;
}
if (declaration.name.elements.length < 1) {
context.diagnostics.push(diagnostics_1.invalidMultiTypeToEmptyPatternOrArrayLiteral(declaration.name));
return [];
// Variable declaration with destructuring
if (ts.isVariableDeclaration(node.parent) && ts.isArrayBindingPattern(node.parent.name)) {
return false;
}
if (declaration.name.elements.some(e => ts.isBindingElement(e) && e.initializer)) {
context.diagnostics.push(diagnostics_1.invalidMultiTypeArrayBindingPatternElementInitializer(declaration.name));
return [];
// Variable assignment with destructuring
if (ts.isBinaryExpression(node.parent) &&
node.parent.operatorToken.kind === ts.SyntaxKind.EqualsToken &&
ts.isArrayLiteralExpression(node.parent.left)) {
return false;
}
if (isMultiFunction(context, declaration.initializer)) {
context.diagnostics.push(diagnostics_1.invalidMultiFunctionUse(declaration.initializer));
return [];
// Spread operator
if (ts.isSpreadElement(node.parent)) {
return false;
}
const leftIdentifiers = [];
for (const element of declaration.name.elements) {
if (ts.isBindingElement(element)) {
if (ts.isIdentifier(element.name)) {
leftIdentifiers.push(identifier_1.transformIdentifier(context, element.name));
}
else {
context.diagnostics.push(diagnostics_1.unsupportedMultiFunctionAssignment(element));
}
}
else if (ts.isOmittedExpression(element)) {
leftIdentifiers.push(lua.createAnonymousIdentifier(element));
}
// Stand-alone expression
if (ts.isExpressionStatement(node.parent)) {
return false;
}
const rightExpressions = transformMultiFunctionArguments(context, declaration.initializer);
return lua_ast_1.createLocalOrExportedOrGlobalDeclaration(context, leftIdentifiers, rightExpressions, declaration);
}
exports.transformMultiVariableDeclaration = transformMultiVariableDeclaration;
function transformMultiDestructuringAssignmentStatement(context, statement) {
utils_1.assert(ts.isBinaryExpression(statement.expression));
utils_1.assert(ts.isCallExpression(statement.expression.right));
if (!ts.isArrayLiteralExpression(statement.expression.left)) {
context.diagnostics.push(diagnostics_1.invalidMultiTypeToNonArrayLiteral(statement.expression.left));
return [];
// Forwarded multi-return call
if ((ts.isReturnStatement(node.parent) || ts.isArrowFunction(node.parent)) && // Body-less arrow func
isInMultiReturnFunction(context, node)) {
return false;
}
if (statement.expression.left.elements.some(ts.isBinaryExpression)) {
context.diagnostics.push(diagnostics_1.invalidMultiTypeArrayLiteralElementInitializer(statement.expression.left));
return [];
// Element access expression 'foo()[0]' will be optimized using 'select'
if (ts.isElementAccessExpression(node.parent)) {
return false;
}
if (statement.expression.left.elements.length < 1) {
context.diagnostics.push(diagnostics_1.invalidMultiTypeToEmptyPatternOrArrayLiteral(statement.expression.left));
return [];
}
if (isMultiFunction(context, statement.expression.right)) {
context.diagnostics.push(diagnostics_1.invalidMultiFunctionUse(statement.expression.right));
return [];
}
const transformLeft = (expression) => ts.isOmittedExpression(expression)
? lua.createAnonymousIdentifier(expression)
: assignments_1.transformAssignmentLeftHandSideExpression(context, expression);
const leftIdentifiers = statement.expression.left.elements.map(transformLeft);
const rightExpressions = transformMultiFunctionArguments(context, statement.expression.right);
const trailingStatements = statement.expression.left.elements.flatMap(expression => {
const symbol = context.checker.getSymbolAtLocation(expression);
const dependentSymbols = symbol ? export_1.getDependenciesOfSymbol(context, symbol) : [];
return dependentSymbols.map(symbol => {
const identifierToAssign = export_1.createExportedIdentifier(context, lua.createIdentifier(symbol.name));
return lua.createAssignmentStatement(identifierToAssign, transformLeft(expression));
});
});
return [lua.createAssignmentStatement(leftIdentifiers, rightExpressions, statement), ...trailingStatements];
return true;
}
exports.transformMultiDestructuringAssignmentStatement = transformMultiDestructuringAssignmentStatement;
exports.shouldMultiReturnCallBeWrapped = shouldMultiReturnCallBeWrapped;
function findMultiAssignmentViolations(context, node) {

@@ -128,0 +83,0 @@ const result = [];

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

const identifier_1 = require("../identifier");
const range_1 = require("../language-extensions/range");
const variable_declaration_1 = require("../variable-declaration");

@@ -19,2 +20,3 @@ const utils_2 = require("./utils");

utils_1.assert(ts.isCallExpression(statement.expression));
context.diagnostics.push(diagnostics_1.annotationDeprecated(statement.expression, annotations_1.AnnotationKind.ForRange));
const callArguments = statement.expression.arguments;

@@ -100,3 +102,6 @@ if (callArguments.length !== 2 && callArguments.length !== 3) {

const body = lua.createBlock(utils_2.transformLoopBody(context, node));
if (ts.isCallExpression(node.expression) && annotations_1.isForRangeType(context, node.expression.expression)) {
if (ts.isCallExpression(node.expression) && range_1.isRangeFunction(context, node.expression)) {
return range_1.transformRangeStatement(context, node, body);
}
else if (ts.isCallExpression(node.expression) && annotations_1.isForRangeType(context, node.expression.expression)) {
return transformForRangeStatement(context, node, body);

@@ -103,0 +108,0 @@ }

@@ -11,4 +11,25 @@ "use strict";

const typescript_1 = require("../utils/typescript");
const call_1 = require("./call");
const multi_1 = require("./language-extensions/multi");
const diagnostics_1 = require("../utils/diagnostics");
function transformExpressionsInReturn(context, node, insideTryCatch) {
if (ts.isCallExpression(node)) {
// $multi(...)
if (multi_1.isMultiFunctionCall(context, node)) {
// Don't allow $multi to be implicitly cast to something other than LuaMultiReturn
const type = context.checker.getContextualType(node);
if (type && !multi_1.isMultiReturnType(type)) {
context.diagnostics.push(diagnostics_1.invalidMultiFunctionReturnType(node));
}
let returnValues = call_1.transformArguments(context, node.arguments);
if (insideTryCatch) {
returnValues = [lua_ast_1.wrapInTable(...returnValues)]; // Wrap results when returning inside try/catch
}
return returnValues;
}
// Force-wrap LuaMultiReturn when returning inside try/catch
if (insideTryCatch && multi_1.returnsMultiType(context, node) && !multi_1.shouldMultiReturnCallBeWrapped(context, node)) {
return [lua_ast_1.wrapInTable(context.transformExpression(node))];
}
}
if (!annotations_1.isInTupleReturnFunction(context, node)) {

@@ -52,7 +73,2 @@ return [context.transformExpression(node)];

}
if (statement.expression &&
ts.isCallExpression(statement.expression) &&
multi_1.isMultiFunction(context, statement.expression)) {
return multi_1.transformMultiReturnStatement(context, statement);
}
let results;

@@ -59,0 +75,0 @@ if (statement.expression) {

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

const identifier_1 = require("./identifier");
const multi_1 = require("./language-extensions/multi");
const literal_1 = require("./literal");
const multi_1 = require("./language-extensions/multi");
function transformArrayBindingElement(context, name) {

@@ -127,4 +127,4 @@ if (ts.isOmittedExpression(name)) {

if (initializer) {
if (annotations_1.isTupleReturnCall(context, initializer)) {
// Don't unpack @tupleReturn annotated functions
if (annotations_1.isTupleReturnCall(context, initializer) || multi_1.isMultiReturnCall(context, initializer)) {
// Don't unpack @tupleReturn or LuaMultiReturn functions
statements.push(...lua_ast_1.createLocalOrExportedOrGlobalDeclaration(context, vars, context.transformExpression(initializer), initializer));

@@ -162,7 +162,2 @@ }

function transformVariableDeclaration(context, statement) {
if (statement.initializer &&
ts.isCallExpression(statement.initializer) &&
multi_1.returnsMultiType(context, statement.initializer)) {
return multi_1.transformMultiVariableDeclaration(context, statement);
}
if (statement.initializer && statement.type) {

@@ -169,0 +164,0 @@ const initializerType = context.checker.getTypeAtLocation(statement.initializer);

@@ -1,2 +0,428 @@

declare function $multi<T extends any[]>(...values: T): MultiReturn<T>;
declare type MultiReturn<T extends any[]> = T & { readonly " __multiBrand": unique symbol };
/**
* Returns multiple values from a function, by wrapping them in a LuaMultiReturn tuple.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param T A tuple type with each element type representing a return value's type.
* @param values Return values.
*/
declare function $multi<T extends any[]>(...values: T): LuaMultiReturn<T>;
/**
* Represents multiple return values as a tuple.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param T A tuple type with each element type representing a return value's type.
*/
declare type LuaMultiReturn<T extends any[]> = T & { readonly __luaMultiReturnBrand: unique symbol };
/**
* Creates a Lua-style numeric for loop (for i=start,limit,step) when used in for...of. Not valid in any other context.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param start The first number in the sequence to iterate over.
* @param limit The last number in the sequence to iterate over.
* @param step The amount to increment each iteration.
*/
declare function $range(start: number, limit: number, step?: number): Iterable<number>;
/**
* Calls to functions with this type are translated to `left + right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaAddition<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & {
readonly __luaAdditionBrand: unique symbol;
};
/**
* Calls to methods with this type are translated to `left + right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaAdditionMethod<TRight, TReturn> = ((right: TRight) => TReturn) & {
readonly __luaAdditionMethodBrand: unique symbol;
};
/**
* Calls to functions with this type are translated to `left - right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaSubtraction<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & {
readonly __luaSubtractionBrand: unique symbol;
};
/**
* Calls to methods with this type are translated to `left - right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaSubtractionMethod<TRight, TReturn> = ((right: TRight) => TReturn) & {
readonly __luaSubtractionMethodBrand: unique symbol;
};
/**
* Calls to functions with this type are translated to `left * right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaMultiplication<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & {
readonly __luaMultiplicationBrand: unique symbol;
};
/**
* Calls to methods with this type are translated to `left * right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaMultiplicationMethod<TRight, TReturn> = ((right: TRight) => TReturn) & {
readonly __luaMultiplicationMethodBrand: unique symbol;
};
/**
* Calls to functions with this type are translated to `left / right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaDivision<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & {
readonly __luaDivisionBrand: unique symbol;
};
/**
* Calls to methods with this type are translated to `left / right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaDivisionMethod<TRight, TReturn> = ((right: TRight) => TReturn) & {
readonly __luaDivisionMethodBrand: unique symbol;
};
/**
* Calls to functions with this type are translated to `left % right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaModulo<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & {
readonly __luaModuloBrand: unique symbol;
};
/**
* Calls to methods with this type are translated to `left % right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaModuloMethod<TRight, TReturn> = ((right: TRight) => TReturn) & {
readonly __luaModuloMethodBrand: unique symbol;
};
/**
* Calls to functions with this type are translated to `left ^ right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaPower<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & {
readonly __luaPowerBrand: unique symbol;
};
/**
* Calls to methods with this type are translated to `left ^ right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaPowerMethod<TRight, TReturn> = ((right: TRight) => TReturn) & {
readonly __luaPowerMethodBrand: unique symbol;
};
/**
* Calls to functions with this type are translated to `left // right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaFloorDivision<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & {
readonly __luaFloorDivisionBrand: unique symbol;
};
/**
* Calls to methods with this type are translated to `left // right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaFloorDivisionMethod<TRight, TReturn> = ((right: TRight) => TReturn) & {
readonly __luaFloorDivisionMethodBrand: unique symbol;
};
/**
* Calls to functions with this type are translated to `left & right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseAnd<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & {
readonly __luaBitwiseAndBrand: unique symbol;
};
/**
* Calls to methods with this type are translated to `left & right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseAndMethod<TRight, TReturn> = ((right: TRight) => TReturn) & {
readonly __luaBitwiseAndMethodBrand: unique symbol;
};
/**
* Calls to functions with this type are translated to `left | right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseOr<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & {
readonly __luaBitwiseOrBrand: unique symbol;
};
/**
* Calls to methods with this type are translated to `left | right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseOrMethod<TRight, TReturn> = ((right: TRight) => TReturn) & {
readonly __luaBitwiseOrMethodBrand: unique symbol;
};
/**
* Calls to functions with this type are translated to `left ~ right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseExclusiveOr<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & {
readonly __luaBitwiseExclusiveOrBrand: unique symbol;
};
/**
* Calls to methods with this type are translated to `left ~ right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseExclusiveOrMethod<TRight, TReturn> = ((right: TRight) => TReturn) & {
readonly __luaBitwiseExclusiveOrMethodBrand: unique symbol;
};
/**
* Calls to functions with this type are translated to `left << right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseLeftShift<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & {
readonly __luaBitwiseLeftShiftBrand: unique symbol;
};
/**
* Calls to methods with this type are translated to `left << right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseLeftShiftMethod<TRight, TReturn> = ((right: TRight) => TReturn) & {
readonly __luaBitwiseLeftShiftMethodBrand: unique symbol;
};
/**
* Calls to functions with this type are translated to `left >> right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseRightShift<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & {
readonly __luaBitwiseRightShiftBrand: unique symbol;
};
/**
* Calls to methods with this type are translated to `left >> right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseRightShiftMethod<TRight, TReturn> = ((right: TRight) => TReturn) & {
readonly __luaBitwiseRightShiftMethodBrand: unique symbol;
};
/**
* Calls to functions with this type are translated to `left .. right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaConcat<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & {
readonly __luaConcatBrand: unique symbol;
};
/**
* Calls to methods with this type are translated to `left .. right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaConcatMethod<TRight, TReturn> = ((right: TRight) => TReturn) & {
readonly __luaConcatMethodBrand: unique symbol;
};
/**
* Calls to functions with this type are translated to `left < right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaLessThan<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & {
readonly __luaLessThanBrand: unique symbol;
};
/**
* Calls to methods with this type are translated to `left < right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaLessThanMethod<TRight, TReturn> = ((right: TRight) => TReturn) & {
readonly __luaLessThanMethodBrand: unique symbol;
};
/**
* Calls to functions with this type are translated to `left > right`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TLeft The type of the left-hand-side of the operation.
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaGreaterThan<TLeft, TRight, TReturn> = ((left: TLeft, right: TRight) => TReturn) & {
readonly __luaGreaterThanBrand: unique symbol;
};
/**
* Calls to methods with this type are translated to `left > right`, where `left` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TRight The type of the right-hand-side of the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaGreaterThanMethod<TRight, TReturn> = ((right: TRight) => TReturn) & {
readonly __luaGreaterThanMethodBrand: unique symbol;
};
/**
* Calls to functions with this type are translated to `-operand`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TOperand The type of the value in the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaNegation<TOperand, TReturn> = ((operand: TOperand) => TReturn) & {
readonly __luaNegationBrand: unique symbol;
};
/**
* Calls to method with this type are translated to `-operand`, where `operand` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaNegationMethod<TReturn> = (() => TReturn) & { readonly __luaNegationMethodBrand: unique symbol };
/**
* Calls to functions with this type are translated to `~operand`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TOperand The type of the value in the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseNot<TOperand, TReturn> = ((operand: TOperand) => TReturn) & {
readonly __luaBitwiseNotBrand: unique symbol;
};
/**
* Calls to method with this type are translated to `~operand`, where `operand` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaBitwiseNotMethod<TReturn> = (() => TReturn) & { readonly __luaBitwiseNotMethodBrand: unique symbol };
/**
* Calls to functions with this type are translated to `#operand`.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TOperand The type of the value in the operation.
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaLength<TOperand, TReturn> = ((operand: TOperand) => TReturn) & {
readonly __luaLengthBrand: unique symbol;
};
/**
* Calls to method with this type are translated to `#operand`, where `operand` is the object with the method.
* For more information see: https://typescripttolua.github.io/docs/advanced/language-extensions
*
* @param TReturn The resulting (return) type of the operation.
*/
declare type LuaLengthMethod<TReturn> = (() => TReturn) & { readonly __luaLengthMethodBrand: unique symbol };
{
"name": "typescript-to-lua",
"version": "0.37.1",
"version": "0.38.0",
"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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc