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
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.0.8 to 0.0.10

2

dist/Compiler.js

@@ -53,3 +53,3 @@ #!/usr/bin/env node

if (options.outDir !== options.rootDir) {
outPath = path.join(options.outDir, sourceFile.fileName.replace(rootDir, ""));
outPath = path.join(options.outDir, path.resolve(sourceFile.fileName).replace(rootDir, ""));
}

@@ -56,0 +56,0 @@ // change extension

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

var importPath = this.transpileExpression(node.moduleSpecifier);
var importPathWithoutQuotes = importPath.replace(new RegExp("\"", "g"), "");
if (!node.importClause || !node.importClause.namedBindings) {

@@ -168,3 +169,2 @@ throw new TranspileError("Default Imports are not supported, please use named imports instead!", node);

if (ts.isNamedImports(imports)) {
var importPathWithoutQuotes = importPath.replace(new RegExp("\"", "g"), "");
var fileImportTable_1 = path.basename(importPathWithoutQuotes) + this.importCount;

@@ -183,2 +183,5 @@ var result_1 = "local " + fileImportTable_1 + " = require(" + this.getImportPath(importPathWithoutQuotes) + ")\n";

}
else if (ts.isNamespaceImport(imports)) {
return "local " + imports.name.escapedText + " = require(" + this.getImportPath(importPathWithoutQuotes) + ")\n";
}
else {

@@ -515,4 +518,7 @@ throw new TranspileError("Unsupported import type.", node);

var typeLeft = this.checker.getTypeAtLocation(node.left);
var typeRight = this.checker.getTypeAtLocation(node.right);
if (typeLeft.flags & ts.TypeFlags.String || ts.isStringLiteral(node.left))
return lhs + ".." + rhs;
if (typeRight.flags & ts.TypeFlags.String || ts.isStringLiteral(node.right))
return lhs + ".." + rhs;
default:

@@ -595,11 +601,2 @@ result = lhs + this.transpileOperator(node.operatorToken) + rhs;

if (ts.isPropertyAccessExpression(node.expression)) {
var type = this.checker.getTypeAtLocation(node.expression.expression);
switch (type.flags) {
case ts.TypeFlags.String:
case ts.TypeFlags.StringLiteral:
return this.transpileStringCallExpression(node);
case ts.TypeFlags.Object:
if (TSHelper_1.TSHelper.isArrayType(type))
return this.transpileArrayCallExpression(node);
}
var expType = this.checker.getTypeAtLocation(node.expression.expression);

@@ -610,6 +607,14 @@ if (expType.symbol && expType.symbol.escapedName == "Math") {

}
if (ts.isIdentifier(node.expression) && node.expression.escapedText == "String") {
if (this.transpileExpression(node.expression.expression) === "String") {
var params_2 = this.transpileArguments(node.arguments);
return this.transpileStringExpression(node.expression.name) + ("(" + params_2 + ")");
}
switch (expType.flags) {
case ts.TypeFlags.String:
case ts.TypeFlags.StringLiteral:
return this.transpileStringCallExpression(node);
case ts.TypeFlags.Object:
if (TSHelper_1.TSHelper.isArrayType(expType))
return this.transpileArrayCallExpression(node);
}
// Include context parameter if present

@@ -636,3 +641,3 @@ var callPath_1 = (expType && expType.symbol) ? expType.symbol.name + "." + node.expression.name.escapedText : this.transpileExpression(node.expression);

case "replace":
return "string.sub(" + caller + "," + params + ")";
return "string.gsub(" + caller + "," + params + ")";
case "indexOf":

@@ -652,3 +657,3 @@ if (node.arguments.length == 1) {

var arg2 = this.transpileExpression(node.arguments[1]);
return "string.sub(" + caller + "," + arg1 + "+1," + arg2 + "+1)";
return "string.sub(" + caller + "," + arg1 + "+1," + arg2 + ")";
}

@@ -655,0 +660,0 @@ default:

{
"name": "typescript-to-lua",
"license": "MIT",
"version": "0.0.8",
"version": "0.0.10",
"repository": "https://github.com/Perryvw/TypescriptToLua",

@@ -6,0 +6,0 @@ "scripts": {

# TypescriptToLua
A generic TypeScript to Lua transpiler. Write your code in TypeScript and publish Lua!
[![Build Status](https://travis-ci.org/Perryvw/TypescriptToLua.svg?branch=master)](https://travis-ci.org/Perryvw/TypescriptToLua) [![Coverage](https://codecov.io/gh/perryvw/typescripttolua/branch/master/graph/badge.svg)](https://codecov.io/gh/perryvw/typescripttolua)
Typescript to lua transpiler.
## Documentation
More detailed documentation and info on writing declarations can be found [on the wiki](https://github.com/Perryvw/TypescriptToLua/wiki).

@@ -6,0 +9,0 @@ ## Usage Guide

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