Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typescript-to-lua

Package Overview
Dependencies
Maintainers
2
Versions
158
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 1.8.1 to 1.8.2

24

dist/transformation/builtins/index.js

@@ -70,5 +70,3 @@ "use strict";

const ownerType = context.checker.getTypeAtLocation(calledMethod.expression);
if (!(0, typescript_1.isStandardLibraryType)(context, ownerType, undefined))
return;
const ownerSymbol = ownerType.symbol;
const ownerSymbol = tryGetStandardLibrarySymbolOfType(context, ownerType);
if (!ownerSymbol || ownerSymbol.parent)

@@ -110,7 +108,6 @@ return;

function tryTransformBuiltinPropertyCall(context, node, calledMethod) {
var _a;
const signatureDeclaration = (_a = context.checker.getResolvedSignature(node)) === null || _a === void 0 ? void 0 : _a.declaration;
if (!signatureDeclaration || !(0, typescript_1.isStandardLibraryDeclaration)(context, signatureDeclaration))
const functionType = context.checker.getTypeAtLocation(node.expression);
const callSymbol = tryGetStandardLibrarySymbolOfType(context, functionType);
if (!callSymbol)
return;
const callSymbol = context.checker.getTypeAtLocation(signatureDeclaration).symbol;
const ownerSymbol = callSymbol.parent;

@@ -192,2 +189,15 @@ if (!ownerSymbol || ownerSymbol.parent)

exports.checkForLuaLibType = checkForLuaLibType;
function tryGetStandardLibrarySymbolOfType(context, type) {
if (type.isUnionOrIntersection()) {
for (const subType of type.types) {
const symbol = tryGetStandardLibrarySymbolOfType(context, subType);
if (symbol)
return symbol;
}
}
else if ((0, typescript_1.isStandardLibraryType)(context, type, undefined)) {
return type.symbol;
}
return undefined;
}
//# sourceMappingURL=index.js.map

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

function canBeMultiReturnType(type) {
return isMultiReturnType(type) || (type.isUnion() && type.types.some(t => canBeMultiReturnType(t)));
return ((type.flags & ts.TypeFlags.Any) !== 0 ||
isMultiReturnType(type) ||
(type.isUnion() && type.types.some(t => canBeMultiReturnType(t))));
}

@@ -17,0 +19,0 @@ exports.canBeMultiReturnType = canBeMultiReturnType;

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

const expressionType = context.checker.getTypeAtLocation(node);
if (ts.isCallExpression(node)) {
// skip type assertions
// don't skip parenthesis as it may arise confusion with lua behavior (where parenthesis are significant)
const innerNode = ts.skipOuterExpressions(node, ts.OuterExpressionKinds.Assertions);
if (ts.isCallExpression(innerNode)) {
// $multi(...)
if ((0, multi_1.isMultiFunctionCall)(context, node)) {
if ((0, multi_1.isMultiFunctionCall)(context, innerNode)) {
// Don't allow $multi to be implicitly cast to something other than LuaMultiReturn
const type = context.checker.getContextualType(node);
if (type && !(0, multi_1.canBeMultiReturnType)(type)) {
context.diagnostics.push((0, diagnostics_1.invalidMultiFunctionReturnType)(node));
context.diagnostics.push((0, diagnostics_1.invalidMultiFunctionReturnType)(innerNode));
}
let returnValues = (0, call_1.transformArguments)(context, node.arguments);
let returnValues = (0, call_1.transformArguments)(context, innerNode.arguments);
if (insideTryCatch) {

@@ -31,9 +34,11 @@ returnValues = [(0, lua_ast_1.wrapInTable)(...returnValues)]; // Wrap results when returning inside try/catch

// Force-wrap LuaMultiReturn when returning inside try/catch
if (insideTryCatch && (0, multi_1.returnsMultiType)(context, node) && !(0, multi_1.shouldMultiReturnCallBeWrapped)(context, node)) {
if (insideTryCatch &&
(0, multi_1.returnsMultiType)(context, innerNode) &&
!(0, multi_1.shouldMultiReturnCallBeWrapped)(context, innerNode)) {
return [(0, lua_ast_1.wrapInTable)(context.transformExpression(node))];
}
}
else if ((0, multi_1.isInMultiReturnFunction)(context, node) && (0, multi_1.isMultiReturnType)(expressionType)) {
else if ((0, multi_1.isInMultiReturnFunction)(context, innerNode) && (0, multi_1.isMultiReturnType)(expressionType)) {
// Unpack objects typed as LuaMultiReturn
return [(0, lua_ast_1.createUnpackCall)(context, context.transformExpression(node), node)];
return [(0, lua_ast_1.createUnpackCall)(context, context.transformExpression(innerNode), innerNode)];
}

@@ -40,0 +45,0 @@ return [context.transformExpression(node)];

{
"name": "typescript-to-lua",
"version": "1.8.1",
"version": "1.8.2",
"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",

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