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 1.5.0 to 1.6.0

2

dist/lualib-build/plugin.d.ts

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

visitors: {
303: (file: ts.SourceFile, context: tstl.TransformationContext) => tstl.File;
305: (file: ts.SourceFile, context: tstl.TransformationContext) => tstl.File;
};

@@ -13,0 +13,0 @@ printer: tstl.Printer;

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

}
export interface DiagnosticsProducingTypeChecker extends ts.TypeChecker {
export interface TypeCheckerWithEmitResolver extends ts.TypeChecker {
getEmitResolver(sourceFile?: ts.SourceFile, cancellationToken?: ts.CancellationToken): EmitResolver;

@@ -28,3 +28,3 @@ }

readonly diagnostics: ts.Diagnostic[];
readonly checker: DiagnosticsProducingTypeChecker;
readonly checker: TypeCheckerWithEmitResolver;
readonly resolver: EmitResolver;

@@ -31,0 +31,0 @@ readonly precedingStatementsStack: lua.Statement[][];

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

this.diagnostics = [];
this.checker = this.program.getDiagnosticsProducingTypeChecker();
this.checker = this.program.getTypeChecker();
this.precedingStatementsStack = [];

@@ -22,0 +22,0 @@ this.options = this.program.getCompilerOptions();

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

export declare function hasExportModifier(node: ts.Node): boolean;
export declare const createDefaultExportStringLiteral: (original?: ts.Node | undefined) => lua.StringLiteral;
export declare const createDefaultExportStringLiteral: (original?: ts.Node) => lua.StringLiteral;
export declare function getExportedSymbolDeclaration(symbol: ts.Symbol): ts.Declaration | undefined;

@@ -9,0 +9,0 @@ export declare function getSymbolFromIdentifier(context: TransformationContext, identifier: lua.Identifier): ts.Symbol | undefined;

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

const options = program.getCompilerOptions();
if (options.noImplicitSelf && program.getRootFileNames().includes(signatureDeclaration.getSourceFile().fileName)) {
if (options.noImplicitSelf && program.getSourceFile(signatureDeclaration.getSourceFile().fileName) !== undefined) {
return ContextType.Void;

@@ -65,0 +65,0 @@ }

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

export declare function createLocalOrExportedOrGlobalDeclaration(context: TransformationContext, lhs: lua.Identifier | lua.Identifier[], rhs?: lua.Expression | lua.Expression[], tsOriginal?: ts.Node, overrideExportScope?: ts.SourceFile | ts.ModuleDeclaration): lua.Statement[];
export declare const createNaN: (tsOriginal?: ts.Node | undefined) => lua.BinaryExpression;
export declare const createNaN: (tsOriginal?: ts.Node) => lua.BinaryExpression;

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

statements: lua.Statement[];
result: lua.AssignmentLeftHandSideExpression;
result: lua.Identifier;
} | {
statements: lua.Statement[];
result: lua.TableIndexExpression;
};

@@ -12,0 +15,0 @@ export declare function transformCompoundAssignmentExpression(context: TransformationContext, expression: ts.Expression, lhs: ts.Expression, rhs: ts.Expression, operator: CompoundAssignmentToken, isPostfix: boolean): lua.Expression;

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

const [rightPrecedingStatements, right] = (0, preceding_statements_1.transformInPrecedingStatementScope)(context, () => context.transformExpression(rhs));
if (lua.isTableIndexExpression(left) && shouldCacheTableIndexExpressions(left, rightPrecedingStatements)) {
if (lua.isTableIndexExpression(left)) {
// Complex property/element accesses need to cache object/index expressions to avoid repeating side-effects

@@ -64,2 +64,11 @@ // local __obj, __index = ${objExpression}, ${indexExpression};

else {
if (isSetterSkippingCompoundAssignmentOperator(operator)) {
return {
statements: [
objAndIndexDeclaration,
...transformSetterSkippingCompoundAssignment(accessExpression, operator, right, rightPrecedingStatements),
],
result: left,
};
}
// local ____tmp = ____obj[____index] ${replacementOperator} ${right};

@@ -88,20 +97,2 @@ // ____obj[____index] = ____tmp;

}
else if (ts.isPropertyAccessExpression(lhs) || ts.isElementAccessExpression(lhs)) {
// Simple property/element access expressions need to cache in temp to avoid double-evaluation
// local ____tmp = ${left} ${replacementOperator} ${right};
// ${left} = ____tmp;
// return ____tmp
const tmpIdentifier = context.createTempNameForLuaExpression(left);
const [precedingStatements, operatorExpression] = (0, binary_expression_1.transformBinaryOperation)(context, left, right, rightPrecedingStatements, operator, expression);
const tmpDeclaration = lua.createVariableDeclarationStatement(tmpIdentifier, operatorExpression);
if (isSetterSkippingCompoundAssignmentOperator(operator)) {
const statements = [
tmpDeclaration,
...transformSetterSkippingCompoundAssignment(tmpIdentifier, operator, right, precedingStatements),
];
return { statements, result: tmpIdentifier };
}
const assignStatements = (0, assignments_1.transformAssignmentWithRightPrecedingStatements)(context, lhs, tmpIdentifier, precedingStatements);
return { statements: [tmpDeclaration, ...assignStatements], result: tmpIdentifier };
}
else {

@@ -108,0 +99,0 @@ if (rightPrecedingStatements.length > 0 && isSetterSkippingCompoundAssignmentOperator(operator)) {

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

const callContext = useGlobalContext ? ts.factory.createIdentifier("_G") : ts.factory.createNull();
[callPath, parameters] = transformCallAndArguments(context, calledExpression, node.arguments, signature, callContext);
[callPath, parameters] = transformCallAndArguments(context, calledExpression, node.arguments, signature,
// Only pass context if noImplicitSelf is not configured
context.options.noImplicitSelf ? undefined : callContext);
}

@@ -201,0 +203,0 @@ const callExpression = lua.createCallExpression(callPath, parameters, node);

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

const tsconfig_1 = require("../cli/tsconfig");
const utils_1 = require("../utils");
const output_collector_1 = require("./output-collector");

@@ -48,4 +49,8 @@ const transpiler_1 = require("./transpiler");

function createVirtualProgram(input, options = {}) {
const normalizedFiles = {};
for (const [path, file] of Object.entries(input)) {
normalizedFiles[(0, utils_1.normalizeSlashes)(path)] = file;
}
const compilerHost = {
fileExists: fileName => fileName in input || ts.sys.fileExists(fileName),
fileExists: fileName => fileName in normalizedFiles || ts.sys.fileExists(fileName),
getCanonicalFileName: fileName => fileName,

@@ -59,4 +64,4 @@ getCurrentDirectory: () => "",

getSourceFile(fileName) {
if (fileName in input) {
return ts.createSourceFile(fileName, input[fileName], ts.ScriptTarget.Latest, false);
if (fileName in normalizedFiles) {
return ts.createSourceFile(fileName, normalizedFiles[fileName], ts.ScriptTarget.Latest, false);
}

@@ -81,3 +86,3 @@ let filePath;

};
return ts.createProgram(Object.keys(input), options, compilerHost);
return ts.createProgram(Object.keys(normalizedFiles), options, compilerHost);
}

@@ -84,0 +89,0 @@ exports.createVirtualProgram = createVirtualProgram;

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

for (const required of findRequiredPaths(file.code)) {
// Do no resolve lualib
if (required === "lualib_bundle") {
// Do no resolve lualib, unless it is included from node_modules
if (required === "lualib_bundle" && !isNodeModulesFile(file.fileName)) {
dependencies.push({ fileName: "lualib_bundle", code: "" });

@@ -122,0 +122,0 @@ continue;

@@ -19,5 +19,6 @@ "use strict";

var _a, _b;
const { program, writeFile = this.emitHost.writeFile } = emitOptions;
const { program, writeFile = this.emitHost.writeFile, plugins: optionsPlugins = [] } = emitOptions;
const options = program.getCompilerOptions();
const { diagnostics: getPluginsDiagnostics, plugins } = (0, plugins_1.getPlugins)(program);
const { diagnostics: getPluginsDiagnostics, plugins: configPlugins } = (0, plugins_1.getPlugins)(program);
const plugins = [...optionsPlugins, ...configPlugins];
const { diagnostics, transpiledFiles: freshFiles } = (0, transpile_1.getProgramTranspileResult)(this.emitHost, writeFile, {

@@ -24,0 +25,0 @@ ...emitOptions,

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

@@ -46,3 +46,3 @@ "repository": "https://github.com/TypeScriptToLua/TypeScriptToLua",

"peerDependencies": {
"typescript": "~4.6.2"
"typescript": "~4.7.3"
},

@@ -57,10 +57,10 @@ "dependencies": {

"@types/glob": "^7.1.1",
"@types/jest": "^27.4.1",
"@types/jest": "^27.5.2",
"@types/node": "^13.7.7",
"@types/resolve": "1.14.0",
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.13.0",
"eslint": "^8.10.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^26.1.1",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"eslint": "^8.17.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.4.6",
"fs-extra": "^8.1.0",

@@ -75,4 +75,4 @@ "javascript-stringify": "^2.0.1",

"ts-node": "^10.3.0",
"typescript": "~4.6.2"
"typescript": "~4.7.3"
}
}
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