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.18.0 to 0.19.0

dist/diagnostics.d.ts

13

CHANGELOG.md
# Changelog
## 0.18.0
* Added support for setting array length. Doing `array.length = x` will set the length of the array to `x` (or shorter, if the starting array was shorter!).
* Added the `.name` property to all transpiled classes, so `class.name` will contain the classname as string.
* Changed `class = class or {}` syntax to just be `class = {}`.
* Cleaned up printer output so it produces more human-readable code.
* Fixed bug with expression statements.
* Fixed incorrect inline sourcemap format.
* Fixed bug when merging an interface and module.
* Fixed a bug with inherited constructor super call ordering.
* Enabled strict tsconfig.
## 0.17.0

@@ -4,0 +17,0 @@ * We now support source maps in the [standard JS v3 format](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?hl=en_US&pli=1&pli=1). You can generate source maps with the `--sourceMap` CLI argument, or by adding `sourceMap: true` to your tsconfig. Inline source maps are also supported with `--inlineSourceMap` CLI/tsconfig parameter.

25

dist/CommandLineParser.d.ts
import * as ts from "typescript";
import { CompilerOptions } from "./CompilerOptions";
export declare type CLIParseResult = ParseResult<ParsedCommandLine>;
declare type ParseResult<T> = {
isValid: true;
result: T;
} | {
isValid: false;
errorMessage: string;
};
interface ParsedCommandLine extends ts.ParsedCommandLine {
export interface ParsedCommandLine extends ts.ParsedCommandLine {
options: CompilerOptions;
}
export declare const version: any;
/**
* Parse the supplied arguments.
* The result will include arguments supplied via CLI and arguments from tsconfig.
*/
export declare function parseCommandLine(args: string[]): CLIParseResult;
export declare const version: string;
export declare function getHelpString(): string;
export declare function parseTsConfigFile(filePath: string, existingOptions?: ts.CompilerOptions): CLIParseResult;
export declare function parseTsConfigString(tsConfigString: string, configPath: string, existingOptions?: ts.CompilerOptions): CLIParseResult;
/** Find configFile, function from ts api seems to be broken? */
export declare function findConfigFile(options: ts.CompilerOptions): ParseResult<string>;
export {};
export declare function updateParsedConfigFile(parsedConfigFile: ts.ParsedCommandLine): ParsedCommandLine;
export declare function parseCommandLine(args: string[]): ParsedCommandLine;
export declare function parseConfigFileWithSystem(configFileName: string, commandLineOptions?: CompilerOptions, system?: ts.System): ParsedCommandLine;

416

dist/CommandLineParser.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const path = require("path");
const ts = require("typescript");
const CompilerOptions_1 = require("./CompilerOptions");
const optionDeclarations = {
luaLibImport: {
choices: [CompilerOptions_1.LuaLibImportKind.Inline, CompilerOptions_1.LuaLibImportKind.Require, CompilerOptions_1.LuaLibImportKind.Always, CompilerOptions_1.LuaLibImportKind.None],
default: CompilerOptions_1.LuaLibImportKind.Inline,
const diagnostics = require("./diagnostics");
const optionDeclarations = [
{
name: "luaLibImport",
describe: "Specifies how js standard features missing in lua are imported.",
type: "enum",
choices: Object.values(CompilerOptions_1.LuaLibImportKind),
},
luaTarget: {
{
name: "luaTarget",
aliases: ["lt"],
choices: [CompilerOptions_1.LuaTarget.LuaJIT, CompilerOptions_1.LuaTarget.Lua53, CompilerOptions_1.LuaTarget.Lua52, CompilerOptions_1.LuaTarget.Lua51],
default: CompilerOptions_1.LuaTarget.LuaJIT,
describe: "Specify Lua target version.",
type: "enum",
choices: Object.values(CompilerOptions_1.LuaTarget),
},
noHeader: {
default: false,
{
name: "noHeader",
describe: "Specify if a header will be added to compiled files.",
type: "boolean",
},
noHoisting: {
default: false,
{
name: "noHoisting",
describe: "Disables hoisting.",
type: "boolean",
},
sourceMapTraceback: {
default: false,
{
name: "sourceMapTraceback",
describe: "Applies the source map to show source TS files and lines in error tracebacks.",
type: "boolean",
},
};
exports.version = require("../package.json").version;
const helpString = `Version ${exports.version}\n` +
"Syntax: tstl [options] [files...]\n\n" +
"Examples: tstl path/to/file.ts [...]\n" +
" tstl -p path/to/tsconfig.json\n\n" +
"In addition to the options listed below you can also pass options\n" +
"for the typescript compiler (For a list of options use tsc -h).\n" +
"Some tsc options might have no effect.";
/**
* Parse the supplied arguments.
* The result will include arguments supplied via CLI and arguments from tsconfig.
*/
function parseCommandLine(args) {
let commandLine = ts.parseCommandLine(args);
// Run diagnostics to check for invalid tsc options
const diagnosticsResult = runTsDiagnostics(commandLine);
if (diagnosticsResult.isValid === false) {
return diagnosticsResult;
}
// This will add TS and TSTL options from a tsconfig
const configResult = readTsConfig(commandLine);
if (configResult.isValid === true) {
commandLine = configResult.result;
}
else {
return { isValid: false, errorMessage: configResult.errorMessage };
}
// Run diagnostics to check for invalid tsconfig
const diagnosticsResult2 = runTsDiagnostics(commandLine);
if (diagnosticsResult2.isValid === false) {
return diagnosticsResult2;
}
// Merge TSTL CLI options in (highest priority) will also set defaults if none specified
const tstlCLIResult = parseTSTLOptions(commandLine, args);
if (tstlCLIResult.isValid === true) {
commandLine = tstlCLIResult.result;
}
else {
return { isValid: false, errorMessage: tstlCLIResult.errorMessage };
}
if (commandLine.options.project && !commandLine.options.rootDir) {
commandLine.options.rootDir = path.dirname(commandLine.options.project);
}
if (!commandLine.options.rootDir) {
commandLine.options.rootDir = process.cwd();
}
if (!commandLine.options.outDir) {
commandLine.options.outDir = commandLine.options.rootDir;
}
return { isValid: true, result: commandLine };
}
exports.parseCommandLine = parseCommandLine;
];
exports.version = `Version ${require("../package.json").version}`;
const helpString = `
Syntax: tstl [options] [files...]
Examples: tstl path/to/file.ts [...]
tstl -p path/to/tsconfig.json
In addition to the options listed below you can also pass options
for the typescript compiler (For a list of options use tsc -h).
Some tsc options might have no effect.
`.trim();
function getHelpString() {
let result = helpString + "\n\n";
result += "Options:\n";
for (const optionName in optionDeclarations) {
const option = optionDeclarations[optionName];
const aliasStrings = option.aliases
? option.aliases.map(a => "-" + a)
: [];
const optionString = aliasStrings.concat(["--" + optionName]).join("|");
const parameterDescribe = option.choices
? option.choices.join("|")
: option.type;
const spacing = " ".repeat(Math.max(1, 45 - optionString.length - parameterDescribe.length));
result += `\n ${optionString} <${parameterDescribe}>${spacing}${option.describe}\n`;
for (const option of optionDeclarations) {
const aliasStrings = (option.aliases || []).map(a => "-" + a);
const optionString = aliasStrings.concat(["--" + option.name]).join("|");
const valuesHint = option.type === "enum" ? option.choices.join("|") : option.type;
const spacing = " ".repeat(Math.max(1, 45 - optionString.length - valuesHint.length));
result += `\n ${optionString} <${valuesHint}>${spacing}${option.describe}\n`;
}

@@ -107,231 +61,123 @@ return result;

exports.getHelpString = getHelpString;
function readTsConfig(parsedCommandLine) {
const options = parsedCommandLine.options;
// Load config
if (options.project) {
const findProjectPathResult = findConfigFile(options);
if (findProjectPathResult.isValid === true) {
options.project = findProjectPathResult.result;
}
else {
return { isValid: false, errorMessage: findProjectPathResult.errorMessage };
}
const configPath = options.project;
const parsedJsonConfig = parseTsConfigFile(configPath, options);
return parsedJsonConfig;
function updateParsedConfigFile(parsedConfigFile) {
let hasRootLevelOptions = false;
for (const key in parsedConfigFile.raw) {
const option = optionDeclarations.find(option => option.name === key);
if (!option)
continue;
if (parsedConfigFile.raw.tstl === undefined)
parsedConfigFile.raw.tstl = {};
parsedConfigFile.raw.tstl[key] = parsedConfigFile.raw[key];
hasRootLevelOptions = true;
}
return { isValid: true, result: parsedCommandLine };
}
function parseTsConfigFile(filePath, existingOptions) {
const configContents = fs.readFileSync(filePath).toString();
return parseTsConfigString(configContents, filePath, existingOptions);
}
exports.parseTsConfigFile = parseTsConfigFile;
function parseTsConfigString(tsConfigString, configPath, existingOptions) {
const configJson = ts.parseConfigFileTextToJson(configPath, tsConfigString);
const parsedJsonConfig = ts.parseJsonConfigFileContent(configJson.config, ts.sys, path.dirname(configPath), existingOptions);
for (const key in parsedJsonConfig.raw) {
const option = optionDeclarations[key];
if (option !== undefined) {
const value = readValue(parsedJsonConfig.raw[key], option.type, key);
if (option.choices) {
if (option.choices.indexOf(value) < 0) {
return {
isValid: false,
errorMessage: `Unknown ${key} value '${value}'.\nAccepted values: ${option.choices}`,
};
}
}
// console.warn(`[Deprectated] TSTL options are moving to the luaConfig object. Adjust your tsconfig to `
// + `look like { "compilerOptions": { <typescript options> }, "tstl": { <tstl options> } }`);
parsedJsonConfig.options[key] = value;
if (parsedConfigFile.raw.tstl) {
if (hasRootLevelOptions) {
parsedConfigFile.errors.push(diagnostics.tstlOptionsAreMovingToTheTstlObject(parsedConfigFile.raw.tstl));
}
}
// Eventually we will only look for the tstl object for tstl options
if (parsedJsonConfig.raw.tstl) {
for (const key in parsedJsonConfig.raw.tstl) {
const option = optionDeclarations[key];
if (option !== undefined) {
const value = readValue(parsedJsonConfig.raw.tstl[key], option.type, key);
if (option.choices) {
if (option.choices.indexOf(value) < 0) {
return {
isValid: false,
errorMessage: `Unknown ${key} value '${value}'.\nAccepted values: ${option.choices}`,
};
}
}
parsedJsonConfig.options[key] = value;
for (const key in parsedConfigFile.raw.tstl) {
const option = optionDeclarations.find(option => option.name === key);
if (!option) {
parsedConfigFile.errors.push(diagnostics.unknownCompilerOption(key));
continue;
}
const { error, value } = readValue(option, parsedConfigFile.raw.tstl[key]);
if (error)
parsedConfigFile.errors.push(error);
if (parsedConfigFile.options[key] === undefined)
parsedConfigFile.options[key] = value;
}
}
return { isValid: true, result: parsedJsonConfig };
return parsedConfigFile;
}
exports.parseTsConfigString = parseTsConfigString;
function parseTSTLOptions(commandLine, args) {
const result = {};
exports.updateParsedConfigFile = updateParsedConfigFile;
function parseCommandLine(args) {
return updateParsedCommandLine(ts.parseCommandLine(args), args);
}
exports.parseCommandLine = parseCommandLine;
function updateParsedCommandLine(parsedCommandLine, args) {
for (let i = 0; i < args.length; i++) {
if (args[i].startsWith("--")) {
const argumentName = args[i].substr(2);
const option = optionDeclarations[argumentName];
if (option) {
const argumentResult = getArgumentValue(argumentName, i, args);
if (argumentResult.isValid === true) {
result[argumentName] = argumentResult.result;
// Skip value from being considered as option
i += argumentResult.increment !== undefined ? argumentResult.increment : 1;
}
else {
return { isValid: false, errorMessage: argumentResult.errorMessage };
}
if (!args[i].startsWith("-"))
continue;
const isShorthand = !args[i].startsWith("--");
const argumentName = args[i].substr(isShorthand ? 1 : 2);
const option = optionDeclarations.find(option => {
if (option.name.toLowerCase() === argumentName.toLowerCase())
return true;
if (isShorthand && option.aliases) {
return option.aliases.some(a => a.toLowerCase() === argumentName.toLowerCase());
}
return false;
});
if (option) {
// Ignore errors caused by tstl specific compiler options
const tsInvalidCompilerOptionErrorCode = 5023;
parsedCommandLine.errors = parsedCommandLine.errors.filter(err => {
return !(err.code === tsInvalidCompilerOptionErrorCode &&
String(err.messageText).endsWith(`'${args[i]}'.`));
});
const { error, value, increment } = readCommandLineArgument(option, args[i + 1]);
if (error)
parsedCommandLine.errors.push(error);
parsedCommandLine.options[option.name] = value;
i += increment;
}
else if (args[i].startsWith("-")) {
const argument = args[i].substr(1);
let argumentName;
for (const key in optionDeclarations) {
if (optionDeclarations[key].aliases && optionDeclarations[key].aliases.indexOf(argument) >= 0) {
argumentName = key;
break;
}
}
if (argumentName !== undefined) {
const argumentResult = getArgumentValue(argumentName, i, args);
if (argumentResult.isValid === true) {
result[argumentName] = argumentResult.result;
// Skip value from being considered as option
i += argumentResult.increment !== undefined ? argumentResult.increment : 1;
}
else {
return { isValid: false, errorMessage: argumentResult.errorMessage };
}
}
}
}
for (const option in result) {
commandLine.options[option] = result[option];
}
// Add defaults if not set
const defaultOptions = getDefaultOptions();
for (const option in defaultOptions) {
if (!commandLine.options[option]) {
commandLine.options[option] = defaultOptions[option];
}
}
return { isValid: true, result: commandLine };
return parsedCommandLine;
}
function getArgumentValue(argumentName, argumentIndex, args) {
const option = optionDeclarations[argumentName];
const argument = args[argumentIndex + 1];
if (option.type === "boolean" && (argument === undefined || argument.startsWith("-"))) {
// Set boolean arguments without supplied value to true
return { isValid: true, result: true, increment: 0 };
}
if (argument === undefined) {
return { isValid: false, errorMessage: `Missing value for parameter ${argumentName}` };
}
const value = readValue(argument, option.type, argumentName);
if (option.choices) {
if (option.choices.indexOf(value) < 0) {
return {
isValid: false,
errorMessage: `Unknown ${argumentName} value '${value}'. Accepted values are: ${option.choices}`,
};
function readCommandLineArgument(option, value) {
if (option.type === "boolean") {
if (value === "true" || value === "false") {
value = value === "true";
}
else {
// Set boolean arguments without supplied value to true
return { value: true, increment: 0 };
}
}
return { isValid: true, result: value };
}
function readValue(value, valueType, parameterName) {
if (valueType === "boolean") {
return value === true || value === "true" || value === "t"
? true
: false;
else if (value === undefined) {
return {
error: diagnostics.compilerOptionExpectsAnArgument(option.name),
value: undefined,
increment: 0,
};
}
else if (valueType === "enum") {
return value.toString().toLowerCase();
}
else {
return value;
}
return Object.assign({}, readValue(option, value), { increment: 1 });
}
function getDefaultOptions() {
const options = {};
for (const optionName in optionDeclarations) {
if (optionDeclarations[optionName].default !== undefined) {
options[optionName] = optionDeclarations[optionName].default;
}
}
return options;
}
/** Check the current state of the ParsedCommandLine for errors */
function runTsDiagnostics(commandLine) {
// Remove files that dont exist
commandLine.fileNames = commandLine.fileNames.filter(file => fs.existsSync(file) || fs.existsSync(file + ".ts"));
const tsInvalidCompilerOptionErrorCode = 5023;
if (commandLine.errors.length !== 0) {
// Generate a list of valid option names and aliases
const optionNames = [];
for (const key of Object.keys(optionDeclarations)) {
optionNames.push(key);
const alias = optionDeclarations[key].aliases;
if (alias) {
if (typeof alias === "string") {
optionNames.push(alias);
}
else {
optionNames.push(...alias);
}
function readValue(option, value) {
if (value === null)
return { value };
switch (option.type) {
case "boolean": {
if (typeof value !== "boolean") {
return {
value: undefined,
error: diagnostics.compilerOptionRequiresAValueOfType(option.name, "boolean"),
};
}
return { value };
}
for (const err of commandLine.errors) {
// Ignore errors caused by tstl specific compiler options
if (err.code === tsInvalidCompilerOptionErrorCode) {
let ignore = false;
for (const optionName of optionNames) {
if (err.messageText.toString().indexOf(optionName) !== -1) {
ignore = true;
break;
}
}
if (!ignore) {
return { isValid: false, errorMessage: `error TS${err.code}: ${err.messageText}` };
}
case "enum": {
if (typeof value !== "string") {
return {
value: undefined,
error: diagnostics.compilerOptionRequiresAValueOfType(option.name, "string"),
};
}
}
}
return { isValid: true, result: true };
}
/** Find configFile, function from ts api seems to be broken? */
function findConfigFile(options) {
if (!options.project) {
return { isValid: false, errorMessage: `error no base path provided, could not find config.` };
}
let configPath = options.project;
// If the project path is wrapped in double quotes, remove them
if (/^".*"$/.test(configPath)) {
configPath = configPath.substring(1, configPath.length - 1);
}
/* istanbul ignore if: Testing else part is not really possible via automated tests */
if (!path.isAbsolute(configPath)) {
// TODO check if options.project can even contain non absolute paths
configPath = path.join(process.cwd(), configPath);
}
if (fs.statSync(configPath).isDirectory()) {
configPath = path.join(configPath, "tsconfig.json");
}
else if (fs.statSync(configPath).isFile() && path.extname(configPath) === ".ts") {
// Search for tsconfig upwards in directory hierarchy starting from the file path
const dir = path.dirname(configPath).split(path.sep);
for (let i = dir.length; i > 0; i--) {
const searchPath = dir.slice(0, i).join("/") + path.sep + "tsconfig.json";
// If tsconfig.json was found, stop searching
if (ts.sys.fileExists(searchPath)) {
configPath = searchPath;
break;
const normalizedValue = value.toLowerCase();
if (option.choices && !option.choices.includes(normalizedValue)) {
const optionChoices = option.choices.join(", ");
return {
value: undefined,
error: diagnostics.argumentForOptionMustBe(`--${option.name}`, optionChoices),
};
}
return { value: normalizedValue };
}
}
return { isValid: true, result: configPath };
}
exports.findConfigFile = findConfigFile;
function parseConfigFileWithSystem(configFileName, commandLineOptions, system = ts.sys) {
const parsedConfigFile = ts.parseJsonSourceFileConfigFileContent(ts.readJsonConfigFile(configFileName, system.readFile), system, path.dirname(configFileName), commandLineOptions, configFileName);
return updateParsedConfigFile(parsedConfigFile);
}
exports.parseConfigFileWithSystem = parseConfigFileWithSystem;
//# sourceMappingURL=CommandLineParser.js.map

@@ -18,4 +18,5 @@ export declare class Decorator {

LuaIterator = "LuaIterator",
LuaTable = "LuaTable",
NoSelf = "NoSelf",
NoSelfInFile = "NoSelfInFile"
}

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

return DecoratorKind.LuaIterator;
case "luatable":
return DecoratorKind.LuaTable;
case "noself":

@@ -56,2 +58,3 @@ return DecoratorKind.NoSelf;

DecoratorKind["LuaIterator"] = "LuaIterator";
DecoratorKind["LuaTable"] = "LuaTable";
DecoratorKind["NoSelf"] = "NoSelf";

@@ -58,0 +61,0 @@ DecoratorKind["NoSelfInFile"] = "NoSelfInFile";

@@ -1,5 +0,25 @@

export { parseCommandLine } from "./CommandLineParser";
export { compile, compileFilesWithOptions, transpileString, watchWithOptions } from "./Compiler";
export { CompilerOptions, LuaLibImportKind, LuaTarget } from "./CompilerOptions";
import * as ts from "typescript";
import { CompilerOptions } from "./CompilerOptions";
import { OutputFile } from "./Emit";
import { TranspiledFile, TranspileResult } from "./Transpile";
export { parseCommandLine, ParsedCommandLine, updateParsedConfigFile } from "./CommandLineParser";
export * from "./CompilerOptions";
export * from "./Emit";
export * from "./LuaAST";
export { LuaLibFeature } from "./LuaLib";
export { LuaTranspiler } from "./LuaTranspiler";
export * from "./LuaPrinter";
export * from "./LuaTransformer";
export * from "./Transpile";
export * from "./TranspileError";
export interface TranspileFilesResult {
diagnostics: ts.Diagnostic[];
emitResult: OutputFile[];
}
export declare function transpileFiles(rootNames: string[], options?: CompilerOptions): TranspileFilesResult;
export declare function transpileProject(fileName: string, optionsToExtend?: CompilerOptions): TranspileFilesResult;
export declare function transpileVirtualProject(files: Record<string, string>, options?: CompilerOptions): TranspileResult;
export interface TranspileStringResult {
diagnostics: ts.Diagnostic[];
file?: TranspiledFile;
}
export declare function transpileString(main: string, options?: CompilerOptions): TranspileStringResult;
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
var CommandLineParser_1 = require("./CommandLineParser");
exports.parseCommandLine = CommandLineParser_1.parseCommandLine;
var Compiler_1 = require("./Compiler");
exports.compile = Compiler_1.compile;
exports.compileFilesWithOptions = Compiler_1.compileFilesWithOptions;
exports.transpileString = Compiler_1.transpileString;
exports.watchWithOptions = Compiler_1.watchWithOptions;
var CompilerOptions_1 = require("./CompilerOptions");
exports.LuaLibImportKind = CompilerOptions_1.LuaLibImportKind;
exports.LuaTarget = CompilerOptions_1.LuaTarget;
const fs = require("fs");
const path = require("path");
const ts = require("typescript");
const CommandLineParser_1 = require("./CommandLineParser");
const Emit_1 = require("./Emit");
const Transpile_1 = require("./Transpile");
var CommandLineParser_2 = require("./CommandLineParser");
exports.parseCommandLine = CommandLineParser_2.parseCommandLine;
exports.updateParsedConfigFile = CommandLineParser_2.updateParsedConfigFile;
__export(require("./CompilerOptions"));
__export(require("./Emit"));
__export(require("./LuaAST"));
var LuaLib_1 = require("./LuaLib");
exports.LuaLibFeature = LuaLib_1.LuaLibFeature;
var LuaTranspiler_1 = require("./LuaTranspiler");
exports.LuaTranspiler = LuaTranspiler_1.LuaTranspiler;
__export(require("./LuaPrinter"));
__export(require("./LuaTransformer"));
__export(require("./Transpile"));
__export(require("./TranspileError"));
function transpileFiles(rootNames, options = {}) {
const program = ts.createProgram(rootNames, options);
const { transpiledFiles, diagnostics: transpileDiagnostics } = Transpile_1.transpile({ program });
const emitResult = Emit_1.emitTranspiledFiles(program.getCompilerOptions(), transpiledFiles);
const diagnostics = ts.sortAndDeduplicateDiagnostics([
...ts.getPreEmitDiagnostics(program),
...transpileDiagnostics,
]);
return { diagnostics: [...diagnostics], emitResult };
}
exports.transpileFiles = transpileFiles;
function transpileProject(fileName, optionsToExtend) {
const parseResult = CommandLineParser_1.parseConfigFileWithSystem(fileName, optionsToExtend);
if (parseResult.errors.length > 0) {
return { diagnostics: parseResult.errors, emitResult: [] };
}
return transpileFiles(parseResult.fileNames, parseResult.options);
}
exports.transpileProject = transpileProject;
const libCache = {};
/** @internal */
function createVirtualProgram(input, options = {}) {
const compilerHost = {
fileExists: () => true,
getCanonicalFileName: fileName => fileName,
getCurrentDirectory: () => "",
getDefaultLibFileName: ts.getDefaultLibFileName,
readFile: () => "",
getNewLine: () => "\n",
useCaseSensitiveFileNames: () => false,
writeFile: () => { },
getSourceFile: filename => {
if (filename in input) {
return ts.createSourceFile(filename, input[filename], ts.ScriptTarget.Latest, false);
}
if (filename.startsWith("lib.")) {
if (libCache[filename])
return libCache[filename];
const typeScriptDir = path.dirname(require.resolve("typescript"));
const filePath = path.join(typeScriptDir, filename);
const content = fs.readFileSync(filePath, "utf8");
libCache[filename] = ts.createSourceFile(filename, content, ts.ScriptTarget.Latest, false);
return libCache[filename];
}
},
};
return ts.createProgram(Object.keys(input), options, compilerHost);
}
exports.createVirtualProgram = createVirtualProgram;
function transpileVirtualProject(files, options = {}) {
const program = createVirtualProgram(files, options);
const result = Transpile_1.transpile({ program });
const diagnostics = ts.sortAndDeduplicateDiagnostics([
...ts.getPreEmitDiagnostics(program),
...result.diagnostics,
]);
return Object.assign({}, result, { diagnostics: [...diagnostics] });
}
exports.transpileVirtualProject = transpileVirtualProject;
function transpileString(main, options = {}) {
const { diagnostics, transpiledFiles } = transpileVirtualProject({ "main.ts": main }, options);
return { diagnostics, file: transpiledFiles.find(({ fileName }) => fileName === "main.ts") };
}
exports.transpileString = transpileString;
//# sourceMappingURL=index.js.map

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

AdditionOperator = 30,
SubractionOperator = 31,
SubtractionOperator = 31,
MultiplicationOperator = 32,

@@ -63,3 +63,3 @@ DivisionOperator = 33,

export declare type BinaryBitwiseOperator = SyntaxKind.BitwiseAndOperator | SyntaxKind.BitwiseOrOperator | SyntaxKind.BitwiseExclusiveOrOperator | SyntaxKind.BitwiseRightShiftOperator | SyntaxKind.BitwiseLeftShiftOperator;
export declare type BinaryOperator = SyntaxKind.AdditionOperator | SyntaxKind.SubractionOperator | SyntaxKind.MultiplicationOperator | SyntaxKind.DivisionOperator | SyntaxKind.FloorDivisionOperator | SyntaxKind.ModuloOperator | SyntaxKind.PowerOperator | SyntaxKind.ConcatOperator | SyntaxKind.EqualityOperator | SyntaxKind.InequalityOperator | SyntaxKind.LessThanOperator | SyntaxKind.LessEqualOperator | SyntaxKind.GreaterThanOperator | SyntaxKind.GreaterEqualOperator | SyntaxKind.AndOperator | SyntaxKind.OrOperator | BinaryBitwiseOperator;
export declare type BinaryOperator = SyntaxKind.AdditionOperator | SyntaxKind.SubtractionOperator | SyntaxKind.MultiplicationOperator | SyntaxKind.DivisionOperator | SyntaxKind.FloorDivisionOperator | SyntaxKind.ModuloOperator | SyntaxKind.PowerOperator | SyntaxKind.ConcatOperator | SyntaxKind.EqualityOperator | SyntaxKind.InequalityOperator | SyntaxKind.LessThanOperator | SyntaxKind.LessEqualOperator | SyntaxKind.GreaterThanOperator | SyntaxKind.GreaterEqualOperator | SyntaxKind.AndOperator | SyntaxKind.OrOperator | BinaryBitwiseOperator;
export declare type Operator = UnaryOperator | BinaryOperator;

@@ -78,2 +78,3 @@ export declare type SymbolId = number;

export declare function setNodePosition<T extends Node>(node: T, position: TextRange): T;
export declare function setNodeOriginal<T extends Node>(node: T, tsOriginal: ts.Node): T;
export declare function setNodeOriginal<T extends Node>(node: T | undefined, tsOriginal: ts.Node): T | undefined;

@@ -113,3 +114,3 @@ export declare function setParent(node: Node | Node[] | undefined, parent: Node): void;

kind: SyntaxKind.IfStatement;
condtion: Expression;
condition: Expression;
ifBlock: Block;

@@ -119,3 +120,3 @@ elseBlock?: Block | IfStatement;

export declare function isIfStatement(node: Node): node is IfStatement;
export declare function createIfStatement(condtion: Expression, ifBlock: Block, elseBlock?: Block | IfStatement, tsOriginal?: ts.Node, parent?: Node): IfStatement;
export declare function createIfStatement(condition: Expression, ifBlock: Block, elseBlock?: Block | IfStatement, tsOriginal?: ts.Node, parent?: Node): IfStatement;
export interface IterationStatement extends Statement {

@@ -127,12 +128,12 @@ body: Block;

kind: SyntaxKind.WhileStatement;
condtion: Expression;
condition: Expression;
}
export declare function isWhileStatement(node: Node): node is WhileStatement;
export declare function createWhileStatement(body: Block, condtion: Expression, tsOriginal?: ts.Node, parent?: Node): WhileStatement;
export declare function createWhileStatement(body: Block, condition: Expression, tsOriginal?: ts.Node, parent?: Node): WhileStatement;
export interface RepeatStatement extends IterationStatement {
kind: SyntaxKind.RepeatStatement;
condtion: Expression;
condition: Expression;
}
export declare function isRepeatStatement(node: Node): node is RepeatStatement;
export declare function createRepeatStatement(body: Block, condtion: Expression, tsOriginal?: ts.Node, parent?: Node): RepeatStatement;
export declare function createRepeatStatement(body: Block, condition: Expression, tsOriginal?: ts.Node, parent?: Node): RepeatStatement;
export interface ForStatement extends IterationStatement {

@@ -258,3 +259,3 @@ kind: SyntaxKind.ForStatement;

kind: SyntaxKind.ParenthesizedExpression;
innerEpxression: Expression;
innerExpression: Expression;
}

@@ -286,3 +287,3 @@ export declare function isParenthesizedExpression(node: Node): node is ParenthesizedExpression;

export declare function cloneIdentifier(identifier: Identifier, tsOriginal?: ts.Node): Identifier;
export declare function createAnnonymousIdentifier(tsOriginal?: ts.Node, parent?: Node): Identifier;
export declare function createAnonymousIdentifier(tsOriginal?: ts.Node, parent?: Node): Identifier;
export interface TableIndexExpression extends Expression {

@@ -289,0 +290,0 @@ kind: SyntaxKind.TableIndexExpression;

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

Object.defineProperty(exports, "__esModule", { value: true });
// We can ellide a lot of nodes especially tokens and keyowords
// becasue we dont create the AST from text
// We can elide a lot of nodes especially tokens and keywords
// because we dont create the AST from text
const ts = require("typescript");

@@ -46,3 +46,3 @@ var SyntaxKind;

SyntaxKind[SyntaxKind["AdditionOperator"] = 30] = "AdditionOperator";
SyntaxKind[SyntaxKind["SubractionOperator"] = 31] = "SubractionOperator";
SyntaxKind[SyntaxKind["SubtractionOperator"] = 31] = "SubtractionOperator";
SyntaxKind[SyntaxKind["MultiplicationOperator"] = 32] = "MultiplicationOperator";

@@ -211,9 +211,9 @@ SyntaxKind[SyntaxKind["DivisionOperator"] = 33] = "DivisionOperator";

exports.isIfStatement = isIfStatement;
function createIfStatement(condtion, ifBlock, elseBlock, tsOriginal, parent) {
function createIfStatement(condition, ifBlock, elseBlock, tsOriginal, parent) {
const statement = createNode(SyntaxKind.IfStatement, tsOriginal, parent);
setParent(condtion, statement);
statement.condtion = condtion;
setParent(condition, statement);
statement.condition = condition;
setParent(ifBlock, statement);
statement.ifBlock = ifBlock;
setParent(ifBlock, statement);
setParent(elseBlock, statement);
statement.elseBlock = elseBlock;

@@ -232,8 +232,8 @@ return statement;

exports.isWhileStatement = isWhileStatement;
function createWhileStatement(body, condtion, tsOriginal, parent) {
function createWhileStatement(body, condition, tsOriginal, parent) {
const statement = createNode(SyntaxKind.WhileStatement, tsOriginal, parent);
setParent(body, statement);
statement.body = body;
setParent(condtion, statement);
statement.condtion = condtion;
setParent(condition, statement);
statement.condition = condition;
return statement;

@@ -246,8 +246,8 @@ }

exports.isRepeatStatement = isRepeatStatement;
function createRepeatStatement(body, condtion, tsOriginal, parent) {
function createRepeatStatement(body, condition, tsOriginal, parent) {
const statement = createNode(SyntaxKind.RepeatStatement, tsOriginal, parent);
setParent(body, statement);
statement.body = body;
setParent(condtion, statement);
statement.condtion = condtion;
setParent(condition, statement);
statement.condition = condition;
return statement;

@@ -470,3 +470,3 @@ }

setParent(innerExpression, expression);
expression.innerEpxression = innerExpression;
expression.innerExpression = innerExpression;
return expression;

@@ -518,3 +518,3 @@ }

exports.cloneIdentifier = cloneIdentifier;
function createAnnonymousIdentifier(tsOriginal, parent) {
function createAnonymousIdentifier(tsOriginal, parent) {
const expression = createNode(SyntaxKind.Identifier, tsOriginal, parent);

@@ -524,3 +524,3 @@ expression.text = "____";

}
exports.createAnnonymousIdentifier = createAnnonymousIdentifier;
exports.createAnonymousIdentifier = createAnonymousIdentifier;
function isTableIndexExpression(node) {

@@ -527,0 +527,0 @@ return node.kind === SyntaxKind.TableIndexExpression;

@@ -22,2 +22,3 @@ export declare enum LuaLibFeature {

ClassNewIndex = "ClassNewIndex",
Decorate = "Decorate",
FunctionApply = "FunctionApply",

@@ -28,5 +29,9 @@ FunctionBind = "FunctionBind",

InstanceOf = "InstanceOf",
InstanceOfObject = "InstanceOfObject",
Iterator = "Iterator",
Map = "Map",
NewIndex = "NewIndex",
Number = "Number",
NumberIsFinite = "NumberIsFinite",
NumberIsNaN = "NumberIsNaN",
ObjectAssign = "ObjectAssign",

@@ -41,5 +46,8 @@ ObjectEntries = "ObjectEntries",

SourceMapTraceBack = "SourceMapTraceBack",
Spread = "Spread",
StringConcat = "StringConcat",
StringEndsWith = "StringEndsWith",
StringReplace = "StringReplace",
StringSplit = "StringSplit",
StringConcat = "StringConcat",
StringStartsWith = "StringStartsWith",
Symbol = "Symbol",

@@ -46,0 +54,0 @@ SymbolRegistry = "SymbolRegistry"

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

LuaLibFeature["ClassNewIndex"] = "ClassNewIndex";
LuaLibFeature["Decorate"] = "Decorate";
LuaLibFeature["FunctionApply"] = "FunctionApply";

@@ -33,5 +34,9 @@ LuaLibFeature["FunctionBind"] = "FunctionBind";

LuaLibFeature["InstanceOf"] = "InstanceOf";
LuaLibFeature["InstanceOfObject"] = "InstanceOfObject";
LuaLibFeature["Iterator"] = "Iterator";
LuaLibFeature["Map"] = "Map";
LuaLibFeature["NewIndex"] = "NewIndex";
LuaLibFeature["Number"] = "Number";
LuaLibFeature["NumberIsFinite"] = "NumberIsFinite";
LuaLibFeature["NumberIsNaN"] = "NumberIsNaN";
LuaLibFeature["ObjectAssign"] = "ObjectAssign";

@@ -46,5 +51,8 @@ LuaLibFeature["ObjectEntries"] = "ObjectEntries";

LuaLibFeature["SourceMapTraceBack"] = "SourceMapTraceBack";
LuaLibFeature["Spread"] = "Spread";
LuaLibFeature["StringConcat"] = "StringConcat";
LuaLibFeature["StringEndsWith"] = "StringEndsWith";
LuaLibFeature["StringReplace"] = "StringReplace";
LuaLibFeature["StringSplit"] = "StringSplit";
LuaLibFeature["StringConcat"] = "StringConcat";
LuaLibFeature["StringStartsWith"] = "StringStartsWith";
LuaLibFeature["Symbol"] = "Symbol";

@@ -56,2 +64,3 @@ LuaLibFeature["SymbolRegistry"] = "SymbolRegistry";

ArrayFlatMap: [LuaLibFeature.ArrayConcat],
InstanceOf: [LuaLibFeature.Symbol],
Iterator: [LuaLibFeature.Symbol],

@@ -63,2 +72,3 @@ ObjectFromEntries: [LuaLibFeature.Iterator, LuaLibFeature.Symbol],

WeakSet: [LuaLibFeature.InstanceOf, LuaLibFeature.Iterator, LuaLibFeature.Symbol],
Spread: [LuaLibFeature.Iterator],
SymbolRegistry: [LuaLibFeature.Symbol],

@@ -65,0 +75,0 @@ };

@@ -0,4 +1,6 @@

import { SourceNode } from "source-map";
import * as tstl from "./LuaAST";
import { CompilerOptions } from "./CompilerOptions";
import { LuaLibFeature } from "./LuaLib";
declare type SourceChunk = string | SourceNode;
export declare class LuaPrinter {

@@ -14,47 +16,48 @@ private static operatorMap;

private printImplementation;
private pushIndent;
private popIndent;
private indent;
private createSourceNode;
private concatNodes;
private printBlock;
protected pushIndent(): void;
protected popIndent(): void;
protected indent(input?: SourceChunk): SourceChunk;
protected createSourceNode(node: tstl.Node, chunks: SourceChunk | SourceChunk[]): SourceNode;
protected concatNodes(...chunks: SourceChunk[]): SourceNode;
protected printBlock(block: tstl.Block): SourceNode;
private statementMayRequireSemiColon;
private nodeStartsWithParenthesis;
private printStatementArray;
private printStatement;
private printDoStatement;
private printVariableDeclarationStatement;
private printVariableAssignmentStatement;
private printIfStatement;
private printWhileStatement;
private printRepeatStatement;
private printForStatement;
private printForInStatement;
private printGotoStatement;
private printLabelStatement;
private printReturnStatement;
private printBreakStatement;
private printExpressionStatement;
private printExpression;
private printStringLiteral;
private printNumericLiteral;
private printNilLiteral;
private printDotsLiteral;
private printBooleanLiteral;
protected printStatementArray(statements: tstl.Statement[]): SourceChunk[];
printStatement(statement: tstl.Statement): SourceNode;
printDoStatement(statement: tstl.DoStatement): SourceNode;
printVariableDeclarationStatement(statement: tstl.VariableDeclarationStatement): SourceNode;
printVariableAssignmentStatement(statement: tstl.AssignmentStatement): SourceNode;
printIfStatement(statement: tstl.IfStatement): SourceNode;
printWhileStatement(statement: tstl.WhileStatement): SourceNode;
printRepeatStatement(statement: tstl.RepeatStatement): SourceNode;
printForStatement(statement: tstl.ForStatement): SourceNode;
printForInStatement(statement: tstl.ForInStatement): SourceNode;
printGotoStatement(statement: tstl.GotoStatement): SourceNode;
printLabelStatement(statement: tstl.LabelStatement): SourceNode;
printReturnStatement(statement: tstl.ReturnStatement): SourceNode;
printBreakStatement(statement: tstl.BreakStatement): SourceNode;
printExpressionStatement(statement: tstl.ExpressionStatement): SourceNode;
printExpression(expression: tstl.Expression): SourceNode;
printStringLiteral(expression: tstl.StringLiteral): SourceNode;
printNumericLiteral(expression: tstl.NumericLiteral): SourceNode;
printNilLiteral(expression: tstl.NilLiteral): SourceNode;
printDotsLiteral(expression: tstl.DotsLiteral): SourceNode;
printBooleanLiteral(expression: tstl.BooleanLiteral): SourceNode;
private printFunctionParameters;
private printFunctionExpression;
private printFunctionDefinition;
private printTableFieldExpression;
private printTableExpression;
private printUnaryExpression;
private printBinaryExpression;
private printParenthesizedExpression;
private printCallExpression;
private printMethodCallExpression;
private printIdentifier;
private printTableIndexExpression;
private printOperator;
private isEmptyStatement;
private removeDeadAndEmptyStatements;
private joinChunks;
printFunctionExpression(expression: tstl.FunctionExpression): SourceNode;
printFunctionDefinition(statement: tstl.FunctionDefinition): SourceNode;
printTableFieldExpression(expression: tstl.TableFieldExpression): SourceNode;
printTableExpression(expression: tstl.TableExpression): SourceNode;
printUnaryExpression(expression: tstl.UnaryExpression): SourceNode;
printBinaryExpression(expression: tstl.BinaryExpression): SourceNode;
printParenthesizedExpression(expression: tstl.ParenthesizedExpression): SourceNode;
printCallExpression(expression: tstl.CallExpression): SourceNode;
printMethodCallExpression(expression: tstl.MethodCallExpression): SourceNode;
printIdentifier(expression: tstl.Identifier): SourceNode;
printTableIndexExpression(expression: tstl.TableIndexExpression): SourceNode;
printOperator(kind: tstl.Operator): SourceNode;
protected removeDeadAndEmptyStatements(statements: tstl.Statement[]): tstl.Statement[];
protected isStatementEmpty(statement: tstl.Statement): boolean;
protected joinChunks(separator: string, chunks: SourceChunk[]): SourceChunk[];
}
export {};

@@ -65,13 +65,14 @@ "use strict";

let header = "";
if (this.options.noHeader === undefined || this.options.noHeader === false) {
if (!this.options.noHeader) {
header += `--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]\n`;
}
if (luaLibFeatures) {
const luaLibImport = this.options.luaLibImport || CompilerOptions_1.LuaLibImportKind.Inline;
// Require lualib bundle
if ((this.options.luaLibImport === CompilerOptions_1.LuaLibImportKind.Require && luaLibFeatures.size > 0)
|| this.options.luaLibImport === CompilerOptions_1.LuaLibImportKind.Always) {
if ((luaLibImport === CompilerOptions_1.LuaLibImportKind.Require && luaLibFeatures.size > 0)
|| luaLibImport === CompilerOptions_1.LuaLibImportKind.Always) {
header += `require("lualib_bundle");\n`;
}
// Inline lualib features
else if (this.options.luaLibImport === CompilerOptions_1.LuaLibImportKind.Inline && luaLibFeatures.size > 0) {
else if (luaLibImport === CompilerOptions_1.LuaLibImportKind.Inline && luaLibFeatures.size > 0) {
header += "-- Lua Library inline imports\n";

@@ -217,6 +218,8 @@ header += LuaLib_1.LuaLib.loadFeatures(luaLibFeatures);

}
printIfStatement(statement, isElseIf) {
printIfStatement(statement) {
const chunks = [];
const isElseIf = statement.parent !== undefined
&& tstl.isIfStatement(statement.parent);
const prefix = isElseIf ? "elseif" : "if";
chunks.push(this.indent(prefix + " "), this.printExpression(statement.condtion), " then\n");
chunks.push(this.indent(prefix + " "), this.printExpression(statement.condition), " then\n");
this.pushIndent();

@@ -227,3 +230,3 @@ chunks.push(this.printBlock(statement.ifBlock));

if (tstl.isIfStatement(statement.elseBlock)) {
chunks.push(this.printIfStatement(statement.elseBlock, true));
chunks.push(this.printIfStatement(statement.elseBlock));
}

@@ -245,3 +248,3 @@ else {

const chunks = [];
chunks.push(this.indent("while "), this.printExpression(statement.condtion), " do\n");
chunks.push(this.indent("while "), this.printExpression(statement.condition), " do\n");
this.pushIndent();

@@ -259,3 +262,3 @@ chunks.push(this.printBlock(statement.body));

this.popIndent();
chunks.push(this.indent("until "), this.printExpression(statement.condtion));
chunks.push(this.indent("until "), this.printExpression(statement.condition));
return this.concatNodes(...chunks);

@@ -464,3 +467,3 @@ }

printParenthesizedExpression(expression) {
return this.createSourceNode(expression, ["(", this.printExpression(expression.innerEpxression), ")"]);
return this.createSourceNode(expression, ["(", this.printExpression(expression.innerExpression), ")"]);
}

@@ -498,11 +501,9 @@ printCallExpression(expression) {

printOperator(kind) {
return LuaPrinter.operatorMap[kind];
// tslint:disable-next-line:no-null-keyword
return new source_map_1.SourceNode(null, null, this.sourceFile, LuaPrinter.operatorMap[kind]);
}
isEmptyStatement(statement) {
return tstl.isDoStatement(statement) && (!statement.statements || statement.statements.length === 0);
}
removeDeadAndEmptyStatements(statements) {
const aliveStatements = [];
for (const statement of statements) {
if (!this.isEmptyStatement(statement)) {
if (!this.isStatementEmpty(statement)) {
aliveStatements.push(statement);

@@ -516,2 +517,5 @@ }

}
isStatementEmpty(statement) {
return tstl.isDoStatement(statement) && (!statement.statements || statement.statements.length === 0);
}
joinChunks(separator, chunks) {

@@ -528,6 +532,5 @@ const result = [];

}
/* tslint:disable:object-literal-sort-keys */
LuaPrinter.operatorMap = {
[tstl.SyntaxKind.AdditionOperator]: "+",
[tstl.SyntaxKind.SubractionOperator]: "-",
[tstl.SyntaxKind.SubtractionOperator]: "-",
[tstl.SyntaxKind.MultiplicationOperator]: "*",

@@ -534,0 +537,0 @@ [tstl.SyntaxKind.DivisionOperator]: "/",

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

export declare type StatementVisitResult = tstl.Statement | tstl.Statement[] | undefined;
export declare type ExpressionVisitResult = tstl.Expression | undefined;
export declare type ExpressionVisitResult = tstl.Expression;
export declare enum ScopeType {

@@ -26,5 +26,7 @@ File = 1,

functionDefinitions?: Map<tstl.SymbolId, FunctionDefinitionInfo>;
importStatements?: tstl.Statement[];
loopContinued?: boolean;
}
export declare class LuaTransformer {
protected program: ts.Program;
luaKeywords: Set<string>;

@@ -35,3 +37,2 @@ private isStrict;

protected options: CompilerOptions;
protected program: ts.Program;
private isModule;

@@ -48,3 +49,3 @@ private currentSourceFile?;

private readonly typeValidationCache;
constructor(program: ts.Program, options: CompilerOptions);
constructor(program: ts.Program);
private setupState;

@@ -61,8 +62,8 @@ transformSourceFile(node: ts.SourceFile): [tstl.Block, Set<LuaLibFeature>];

transformClassDeclaration(statement: ts.ClassLikeDeclaration, nameOverride?: tstl.Identifier): StatementVisitResult;
createClassCreationMethods(statement: ts.ClassLikeDeclarationBase, className: tstl.Identifier, extendsType?: ts.Type): tstl.Statement[];
private createClassCreationMethods;
private transformClassInstanceFields;
private createConstructorName;
transformConstructorDeclaration(statement: ts.ConstructorDeclaration, className: tstl.Identifier, instanceFields: ts.PropertyDeclaration[], classDeclaration: ts.ClassLikeDeclaration): StatementVisitResult;
transformGetAccessorDeclaration(getAccessor: ts.GetAccessorDeclaration, className: tstl.Identifier, classDeclaration: ts.ClassLikeDeclaration): StatementVisitResult;
transformSetAccessorDeclaration(setAccessor: ts.SetAccessorDeclaration, className: tstl.Identifier, classDeclaration: ts.ClassLikeDeclaration): StatementVisitResult;
private transformConstructorDeclaration;
transformGetAccessorDeclaration(getAccessor: ts.GetAccessorDeclaration, className: tstl.Identifier): StatementVisitResult;
transformSetAccessorDeclaration(setAccessor: ts.SetAccessorDeclaration, className: tstl.Identifier): StatementVisitResult;
transformMethodDeclaration(node: ts.MethodDeclaration, className: tstl.Identifier, noPrototype: boolean): StatementVisitResult;

@@ -72,3 +73,3 @@ private transformParameters;

private transformParameterDefaultValueDeclaration;
transformBindingPattern(pattern: ts.BindingPattern, table: tstl.Identifier, propertyAccessStack?: ts.PropertyName[]): IterableIterator<tstl.Statement>;
transformBindingPattern(pattern: ts.BindingPattern, table: tstl.Identifier, propertyAccessStack?: ts.PropertyName[]): StatementVisitResult;
transformModuleDeclaration(statement: ts.ModuleDeclaration): StatementVisitResult;

@@ -88,3 +89,3 @@ transformEnumDeclaration(enumDeclaration: ts.EnumDeclaration): StatementVisitResult;

transformExpressionStatement(statement: ts.ExpressionStatement | ts.Expression): StatementVisitResult;
transformYield(expression: ts.YieldExpression): ExpressionVisitResult;
transformYieldExpression(expression: ts.YieldExpression): ExpressionVisitResult;
transformReturnStatement(statement: ts.ReturnStatement): StatementVisitResult;

@@ -95,8 +96,8 @@ transformIfStatement(statement: ts.IfStatement): StatementVisitResult;

transformForStatement(statement: ts.ForStatement): StatementVisitResult;
transformForOfInitializer(initializer: ts.ForInitializer, expression: tstl.Expression): tstl.Statement;
transformLoopBody(loop: ts.WhileStatement | ts.DoStatement | ts.ForStatement | ts.ForOfStatement | ts.ForInOrOfStatement): tstl.Statement[];
transformBlockOrStatement(statement: ts.Statement): tstl.Statement[];
transformForOfArrayStatement(statement: ts.ForOfStatement, block: tstl.Block): StatementVisitResult;
transformForOfLuaIteratorStatement(statement: ts.ForOfStatement, block: tstl.Block): StatementVisitResult;
transformForOfIteratorStatement(statement: ts.ForOfStatement, block: tstl.Block): StatementVisitResult;
private transformForOfInitializer;
protected transformLoopBody(loop: ts.WhileStatement | ts.DoStatement | ts.ForStatement | ts.ForOfStatement | ts.ForInOrOfStatement): tstl.Statement[];
private transformBlockOrStatement;
private transformForOfArrayStatement;
private transformForOfLuaIteratorStatement;
private transformForOfIteratorStatement;
transformForOfStatement(statement: ts.ForOfStatement): StatementVisitResult;

@@ -109,23 +110,23 @@ transformForInStatement(statement: ts.ForInStatement): StatementVisitResult;

transformContinueStatement(statement: ts.ContinueStatement): StatementVisitResult;
transformEmptyStatement(arg0: ts.EmptyStatement): StatementVisitResult;
transformEmptyStatement(statement: ts.EmptyStatement): StatementVisitResult;
transformExpression(expression: ts.Expression): ExpressionVisitResult;
transformBinaryOperation(left: tstl.Expression, right: tstl.Expression, operator: ts.BinaryOperator, tsOriginal: ts.Node): ExpressionVisitResult;
protected transformBinaryOperation(left: tstl.Expression, right: tstl.Expression, operator: ts.BinaryOperator, tsOriginal: ts.Node): ExpressionVisitResult;
transformBinaryExpression(expression: ts.BinaryExpression): ExpressionVisitResult;
private transformAssignment;
transformAssignmentStatement(expression: ts.BinaryExpression): StatementVisitResult;
transformAssignmentExpression(expression: ts.BinaryExpression): tstl.CallExpression | tstl.MethodCallExpression;
transformCompoundAssignmentExpression(expression: ts.Expression, lhs: ts.Expression, rhs: ts.Expression, replacementOperator: ts.BinaryOperator, isPostfix: boolean): tstl.CallExpression;
private transformAssignmentStatement;
private transformAssignmentExpression;
private transformCompoundAssignmentExpression;
transformBinaryOperator(operator: ts.BinaryOperator, node: ts.Node): tstl.BinaryOperator;
transformClassExpression(expression: ts.ClassExpression): ExpressionVisitResult;
transformCompoundAssignmentStatement(node: ts.Node, lhs: ts.Expression, rhs: ts.Expression, replacementOperator: ts.BinaryOperator): tstl.Statement;
transformUnaryBitLibOperation(node: ts.Node, expression: tstl.Expression, operator: tstl.UnaryBitwiseOperator, lib: string): ExpressionVisitResult;
transformUnaryBitOperation(node: ts.Node, expression: tstl.Expression, operator: tstl.UnaryBitwiseOperator): ExpressionVisitResult;
transformBinaryBitLibOperation(node: ts.Node, left: tstl.Expression, right: tstl.Expression, operator: ts.BinaryOperator, lib: string): ExpressionVisitResult;
private transformCompoundAssignmentStatement;
private transformUnaryBitLibOperation;
private transformUnaryBitOperation;
private transformBinaryBitLibOperation;
private transformBinaryBitOperation;
private transformProtectedConditionalExpression;
private transformConditionalExpression;
transformConditionalExpression(expression: ts.ConditionalExpression): ExpressionVisitResult;
transformPostfixUnaryExpression(expression: ts.PostfixUnaryExpression): ExpressionVisitResult;
transformPrefixUnaryExpression(expression: ts.PrefixUnaryExpression): ExpressionVisitResult;
transformArrayLiteral(node: ts.ArrayLiteralExpression): ExpressionVisitResult;
transformObjectLiteral(node: ts.ObjectLiteralExpression): ExpressionVisitResult;
transformArrayLiteral(expression: ts.ArrayLiteralExpression): ExpressionVisitResult;
transformObjectLiteral(expression: ts.ObjectLiteralExpression): ExpressionVisitResult;
transformDeleteExpression(expression: ts.DeleteExpression): ExpressionVisitResult;

@@ -136,7 +137,8 @@ transformFunctionExpression(node: ts.FunctionLikeDeclaration): ExpressionVisitResult;

transformSuperKeyword(expression: ts.SuperExpression): ExpressionVisitResult;
transformCallExpression(node: ts.CallExpression): ExpressionVisitResult;
transformCallExpression(expression: ts.CallExpression): ExpressionVisitResult;
private transformGlobalFunctionCall;
transformPropertyCall(node: ts.CallExpression): ExpressionVisitResult;
transformElementCall(node: ts.CallExpression): ExpressionVisitResult;
private transformArguments;
transformPropertyAccessExpression(node: ts.PropertyAccessExpression): ExpressionVisitResult;
transformPropertyAccessExpression(expression: ts.PropertyAccessExpression): ExpressionVisitResult;
private transformMathExpression;

@@ -146,2 +148,3 @@ private transformMathCallExpression;

private transformArrayProperty;
private transformLuaTableProperty;
transformElementAccessExpression(expression: ts.ElementAccessExpression): ExpressionVisitResult;

@@ -156,7 +159,11 @@ private transformConstEnumValue;

private transformSymbolCallExpression;
private transformNumberCallExpression;
private validateLuaTableCall;
private transformLuaTableExpressionStatement;
private transformLuaTableCallExpression;
private transformArrayCallExpression;
private transformFunctionCallExpression;
transformArrayBindingElement(name: ts.ArrayBindingElement): ExpressionVisitResult;
transformAssertionExpression(node: ts.AssertionExpression): ExpressionVisitResult;
transformTypeOfExpression(node: ts.TypeOfExpression): ExpressionVisitResult;
transformAssertionExpression(expression: ts.AssertionExpression): ExpressionVisitResult;
transformTypeOfExpression(expression: ts.TypeOfExpression): ExpressionVisitResult;
transformSpreadElement(expression: ts.SpreadElement): ExpressionVisitResult;

@@ -171,31 +178,34 @@ transformStringLiteral(literal: ts.StringLiteralLike): ExpressionVisitResult;

transformPropertyName(propertyName: ts.PropertyName): ExpressionVisitResult;
private getIdentifierText;
protected getIdentifierText(identifier: ts.Identifier): string;
transformIdentifier(expression: ts.Identifier): tstl.Identifier;
private transformIdentifierExpression;
private isIdentifierExported;
private addExportToIdentifier;
private createExportedIdentifier;
private transformLuaLibFunction;
checkForLuaLibType(type: ts.Type): void;
private importLuaLibFeature;
private createImmediatelyInvokedFunctionExpression;
private createUnpackCall;
private getAbsoluteImportPath;
private getImportPath;
private formatPathToLuaPath;
private shouldExportIdentifier;
private createSelfIdentifier;
private createExportsIdentifier;
private createLocalOrExportedOrGlobalDeclaration;
private validateFunctionAssignment;
private wrapInFunctionCall;
private wrapInTable;
private wrapInToStringForConcat;
private expressionPlusOne;
private getIdentifierSymbolId;
protected isIdentifierExported(identifier: tstl.Identifier): boolean;
protected isSymbolExported(symbol: ts.Symbol): boolean;
protected addExportToIdentifier(identifier: tstl.Identifier): tstl.IdentifierOrTableIndexExpression;
protected createExportedIdentifier(identifier: tstl.Identifier): tstl.TableIndexExpression;
protected transformLuaLibFunction(func: LuaLibFeature, tsParent?: ts.Expression, ...params: tstl.Expression[]): tstl.CallExpression;
protected checkForLuaLibType(type: ts.Type): void;
protected importLuaLibFeature(feature: LuaLibFeature): void;
protected createImmediatelyInvokedFunctionExpression(statements: tstl.Statement[], result: tstl.Expression | tstl.Expression[], tsOriginal: ts.Node): tstl.CallExpression;
protected createUnpackCall(expression: tstl.Expression | undefined, tsOriginal: ts.Node): tstl.Expression;
protected getAbsoluteImportPath(relativePath: string): string;
protected getImportPath(relativePath: string, node: ts.Node): string;
protected formatPathToLuaPath(filePath: string): string;
protected shouldExportIdentifier(identifier: tstl.Identifier | tstl.Identifier[]): boolean;
protected createSelfIdentifier(tsOriginal?: ts.Node): tstl.Identifier;
protected createExportsIdentifier(): tstl.Identifier;
protected createLocalOrExportedOrGlobalDeclaration(lhs: tstl.Identifier | tstl.Identifier[], rhs?: tstl.Expression, tsOriginal?: ts.Node, parent?: tstl.Node): tstl.Statement[];
protected validateFunctionAssignment(node: ts.Node, fromType: ts.Type, toType: ts.Type, toName?: string): void;
protected validatePropertyAssignment(node: ts.Node): void;
protected wrapInFunctionCall(expression: tstl.Expression): tstl.FunctionExpression;
protected wrapInTable(...expressions: tstl.Expression[]): tstl.ParenthesizedExpression;
protected wrapInToStringForConcat(expression: tstl.Expression): tstl.Expression;
protected expressionPlusOne(expression: tstl.Expression): tstl.BinaryExpression;
protected getIdentifierSymbolId(identifier: ts.Identifier): tstl.SymbolId | undefined;
protected findScope(scopeTypes: ScopeType): Scope | undefined;
protected peekScope(): Scope;
protected peekScope(): Scope | undefined;
protected pushScope(scopeType: ScopeType, node: ts.Node): void;
private shouldHoist;
protected replaceStatementInParent(oldNode: tstl.Statement, newNode?: tstl.Statement): void;
protected hoistImportStatements(scope: Scope, statements: tstl.Statement[]): tstl.Statement[];
protected hoistFunctionDefinitions(scope: Scope, statements: tstl.Statement[]): tstl.Statement[];

@@ -206,7 +216,7 @@ protected hoistVariableDeclarations(scope: Scope, statements: tstl.Statement[]): tstl.Statement[];

protected createHoistableVariableDeclarationStatement(identifier: ts.Identifier, initializer?: tstl.Expression, tsOriginal?: ts.Node, parent?: tstl.Node): tstl.AssignmentStatement | tstl.VariableDeclarationStatement;
private statementVisitResultToArray;
private filterUndefined;
private filterUndefinedAndCast;
private expectExpression;
protected statementVisitResultToArray(visitResult: StatementVisitResult): tstl.Statement[];
protected filterUndefined<T>(items: Array<T | undefined>): T[];
protected filterUndefinedAndCast<TOriginal, TCast extends TOriginal>(items: Array<TOriginal | undefined>, cast: (item: TOriginal) => item is TCast): TCast[];
private createConstructorDecorationStatement;
}
export {};

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

static forTypeOrAnySupertype(type: ts.Type, checker: ts.TypeChecker, predicate: (type: ts.Type) => boolean): boolean;
static isAmbient(node: ts.Declaration): boolean;
static isStatic(node: ts.Node): boolean;
static isStringType(type: ts.Type): boolean;
static isNumberType(type: ts.Type): boolean;
static isExplicitArrayType(type: ts.Type, checker: ts.TypeChecker, program: ts.Program): boolean;

@@ -63,3 +65,3 @@ static isFunctionType(type: ts.Type, checker: ts.TypeChecker): boolean;

static isStandardLibraryDeclaration(declaration: ts.Declaration, program: ts.Program): boolean;
static isStandardLibraryType(type: ts.Type, name: string, program: ts.Program): boolean;
static isStandardLibraryType(type: ts.Type, name: string | undefined, program: ts.Program): boolean;
static isEnumMember(enumDeclaration: ts.EnumDeclaration, value: ts.Expression): [true, ts.PropertyName] | [false, undefined];

@@ -66,0 +68,0 @@ static moduleHasEmittedBody(statement: ts.ModuleDeclaration): statement is ts.ModuleDeclaration & {

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

}
static isAmbient(node) {
return !((ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Ambient) === 0);
}
static isStatic(node) {

@@ -122,2 +125,6 @@ return node.modifiers !== undefined && node.modifiers.some(m => m.kind === ts.SyntaxKind.StaticKeyword);

}
static isNumberType(type) {
return (type.flags & ts.TypeFlags.Number) !== 0 || (type.flags & ts.TypeFlags.NumberLike) !== 0 ||
(type.flags & ts.TypeFlags.NumberLiteral) !== 0;
}
static isExplicitArrayType(type, checker, program) {

@@ -588,4 +595,4 @@ if (type.isUnionOrIntersection()) {

static isStandardLibraryType(type, name, program) {
const symbol = type.symbol;
if (!symbol || symbol.escapedName !== name) {
const symbol = type.getSymbol();
if (!symbol || (name ? symbol.escapedName !== name : symbol.escapedName === '__type')) {
return false;

@@ -592,0 +599,0 @@ }

#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Compiler_1 = require("./Compiler");
Compiler_1.compile(process.argv.slice(2));
const path = require("path");
const ts = require("typescript");
const tstl = require(".");
const CommandLineParser = require("./CommandLineParser");
const cliDiagnostics = require("./diagnostics");
function createDiagnosticReporter(pretty) {
const reporter = ts.createDiagnosticReporter(ts.sys, pretty);
return diagnostic => {
if (diagnostic.source === "typescript-to-lua") {
diagnostic = Object.assign({}, diagnostic, { code: ("TL" + diagnostic.code) });
}
reporter(diagnostic);
};
}
function createWatchStatusReporter(options) {
return ts.createWatchStatusReporter(ts.sys, shouldBePretty(options));
}
function shouldBePretty(options) {
return !options || options.pretty === undefined
? ts.sys.writeOutputIsTTY !== undefined && ts.sys.writeOutputIsTTY()
: Boolean(options.pretty);
}
let reportDiagnostic = createDiagnosticReporter(false);
function updateReportDiagnostic(options) {
reportDiagnostic = createDiagnosticReporter(shouldBePretty(options));
}
function locateConfigFile(commandLine) {
const { project } = commandLine.options;
if (!project) {
if (commandLine.fileNames.length === 0) {
const searchPath = path.posix.normalize(ts.sys.getCurrentDirectory());
return ts.findConfigFile(searchPath, ts.sys.fileExists);
}
return;
}
if (commandLine.fileNames.length !== 0) {
reportDiagnostic(cliDiagnostics.optionProjectCannotBeMixedWithSourceFilesOnACommandLine());
ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
return;
}
let fileOrDirectory = path.posix.normalize(project);
if (!path.isAbsolute(fileOrDirectory)) {
fileOrDirectory = path.posix.join(ts.sys.getCurrentDirectory(), fileOrDirectory);
}
if (!fileOrDirectory || ts.sys.directoryExists(fileOrDirectory)) {
const configFileName = path.posix.join(fileOrDirectory, "tsconfig.json");
if (ts.sys.fileExists(configFileName)) {
return configFileName;
}
else {
reportDiagnostic(cliDiagnostics.cannotFindATsconfigJsonAtTheSpecifiedDirectory(project));
ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
}
else {
if (ts.sys.fileExists(fileOrDirectory)) {
return fileOrDirectory;
}
else {
reportDiagnostic(cliDiagnostics.theSpecifiedPathDoesNotExist(project));
ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
}
}
function executeCommandLine(args) {
if (args.length > 0 && args[0].startsWith("-")) {
const firstOption = args[0].slice(args[0].startsWith("--") ? 2 : 1).toLowerCase();
if (firstOption === "build" || firstOption === "b") {
return performBuild(args.slice(1));
}
}
const commandLine = CommandLineParser.parseCommandLine(args);
if (commandLine.options.build) {
reportDiagnostic(cliDiagnostics.optionBuildMustBeFirstCommandLineArgument());
return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
// TODO: ParsedCommandLine.errors isn't meant to contain warnings. Once root-level options
// support would be dropped it should be changed to `commandLine.errors.length > 0`.
if (commandLine.errors.some(e => e.category === ts.DiagnosticCategory.Error)) {
commandLine.errors.forEach(reportDiagnostic);
return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
if (commandLine.options.version) {
console.log(CommandLineParser.version);
return ts.sys.exit(ts.ExitStatus.Success);
}
if (commandLine.options.help) {
console.log(CommandLineParser.version);
console.log(CommandLineParser.getHelpString());
return ts.sys.exit(ts.ExitStatus.Success);
}
const configFileName = locateConfigFile(commandLine);
const commandLineOptions = commandLine.options;
if (configFileName) {
const configParseResult = CommandLineParser.parseConfigFileWithSystem(configFileName, commandLineOptions);
updateReportDiagnostic(configParseResult.options);
if (configParseResult.options.watch) {
createWatchOfConfigFile(configFileName, commandLineOptions);
}
else {
performCompilation(configParseResult.fileNames, configParseResult.projectReferences, configParseResult.options, ts.getConfigFileParsingDiagnostics(configParseResult));
}
}
else {
updateReportDiagnostic(commandLineOptions);
if (commandLineOptions.watch) {
createWatchOfFilesAndCompilerOptions(commandLine.fileNames, commandLineOptions);
}
else {
performCompilation(commandLine.fileNames, commandLine.projectReferences, commandLineOptions);
}
}
}
function performBuild(_args) {
console.log("Option '--build' is not supported.");
return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
}
function performCompilation(rootNames, projectReferences, options, configFileParsingDiagnostics) {
const program = ts.createProgram({
rootNames,
options,
projectReferences,
configFileParsingDiagnostics,
});
const { transpiledFiles, diagnostics: transpileDiagnostics } = tstl.transpile({ program });
const diagnostics = ts.sortAndDeduplicateDiagnostics([
...ts.getPreEmitDiagnostics(program),
...transpileDiagnostics,
]);
const emitResult = tstl.emitTranspiledFiles(options, transpiledFiles);
emitResult.forEach(({ name, text }) => ts.sys.writeFile(name, text));
diagnostics.forEach(reportDiagnostic);
const exitCode = diagnostics.length === 0
? ts.ExitStatus.Success
: transpiledFiles.length === 0
? ts.ExitStatus.DiagnosticsPresent_OutputsSkipped
: ts.ExitStatus.DiagnosticsPresent_OutputsGenerated;
return ts.sys.exit(exitCode);
}
function createWatchOfConfigFile(configFileName, optionsToExtend) {
const watchCompilerHost = ts.createWatchCompilerHost(configFileName, optionsToExtend, ts.sys, ts.createSemanticDiagnosticsBuilderProgram, undefined, createWatchStatusReporter(optionsToExtend));
updateWatchCompilationHost(watchCompilerHost, optionsToExtend);
ts.createWatchProgram(watchCompilerHost);
}
function createWatchOfFilesAndCompilerOptions(rootFiles, options) {
const watchCompilerHost = ts.createWatchCompilerHost(rootFiles, options, ts.sys, ts.createSemanticDiagnosticsBuilderProgram, undefined, createWatchStatusReporter(options));
updateWatchCompilationHost(watchCompilerHost, options);
ts.createWatchProgram(watchCompilerHost);
}
function updateWatchCompilationHost(host, optionsToExtend) {
let fullRecompile = true;
const configFileMap = new WeakMap();
host.afterProgramCreate = builderProgram => {
const program = builderProgram.getProgram();
const options = builderProgram.getCompilerOptions();
let configFileParsingDiagnostics = [];
const configFile = options.configFile;
const configFilePath = options.configFilePath;
if (configFile && configFilePath) {
if (!configFileMap.has(configFile)) {
const parsedConfigFile = CommandLineParser.updateParsedConfigFile(ts.parseJsonSourceFileConfigFileContent(configFile, ts.sys, path.dirname(configFilePath), optionsToExtend, configFilePath));
configFileMap.set(configFile, parsedConfigFile);
}
const parsedConfigFile = configFileMap.get(configFile);
Object.assign(options, parsedConfigFile.options);
configFileParsingDiagnostics = parsedConfigFile.errors;
}
let sourceFiles;
if (!fullRecompile) {
sourceFiles = [];
while (true) {
const currentFile = builderProgram.getSemanticDiagnosticsOfNextAffectedFile();
if (!currentFile)
break;
if ("fileName" in currentFile.affected) {
sourceFiles.push(currentFile.affected);
}
else {
sourceFiles.push(...currentFile.affected.getSourceFiles());
}
}
}
const { diagnostics: emitDiagnostics, transpiledFiles } = tstl.transpile({
program,
sourceFiles,
});
const emitResult = tstl.emitTranspiledFiles(options, transpiledFiles);
emitResult.forEach(({ name, text }) => ts.sys.writeFile(name, text));
const diagnostics = ts.sortAndDeduplicateDiagnostics([
...configFileParsingDiagnostics,
...program.getOptionsDiagnostics(),
...program.getSyntacticDiagnostics(),
...program.getGlobalDiagnostics(),
...program.getSemanticDiagnostics(),
...emitDiagnostics,
]);
diagnostics.forEach(reportDiagnostic);
const errors = diagnostics.filter(d => d.category === ts.DiagnosticCategory.Error);
// do a full recompile after an error
fullRecompile = errors.length > 0;
host.onWatchStatusChange(cliDiagnostics.watchErrorSummary(errors.length), host.getNewLine(), options);
};
}
if (ts.sys.setBlocking)
ts.sys.setBlocking();
executeCommandLine(ts.sys.args);
//# sourceMappingURL=tstl.js.map

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

static ForbiddenForIn: (node: ts.Node) => TranspileError;
static ForbiddenLuaTableSetExpression: (node: ts.Node) => TranspileError;
static ForbiddenLuaTableNonDeclaration: (node: ts.Node) => TranspileError;
static InvalidExtendsLuaTable: (node: ts.Node) => TranspileError;
static InvalidInstanceOfLuaTable: (node: ts.Node) => TranspileError;
static ForbiddenLuaTableUseException: (description: string, node: ts.Node) => TranspileError;
static HeterogeneousEnum: (node: ts.Node) => TranspileError;
static InvalidDecoratorArgumentNumber: (name: string, got: number, expected: number, node: ts.Node) => TranspileError;
static InvalidDecoratorContext: (node: ts.Node) => TranspileError;
static InvalidExtensionMetaExtension: (node: ts.Node) => TranspileError;

@@ -13,0 +19,0 @@ static InvalidNewExpressionOnExtension: (node: ts.Node) => TranspileError;

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

TSTLErrors.ForbiddenForIn = (node) => new TranspileError_1.TranspileError(`Iterating over arrays with 'for ... in' is not allowed.`, node);
TSTLErrors.ForbiddenLuaTableSetExpression = (node) => new TranspileError_1.TranspileError(`A '@luaTable' object's 'set()' method can only be used as a Statement, not an Expression.`, node);
TSTLErrors.ForbiddenLuaTableNonDeclaration = (node) => new TranspileError_1.TranspileError(`Classes with the '@luaTable' decorator must be declared.`, node);
TSTLErrors.InvalidExtendsLuaTable = (node) => new TranspileError_1.TranspileError(`Cannot extend classes with the decorator '@luaTable'.`, node);
TSTLErrors.InvalidInstanceOfLuaTable = (node) => new TranspileError_1.TranspileError(`The instanceof operator cannot be used with a '@luaTable' class.`, node);
TSTLErrors.ForbiddenLuaTableUseException = (description, node) => new TranspileError_1.TranspileError(`Invalid @luaTable usage: ${description}`, node);
TSTLErrors.HeterogeneousEnum = (node) => new TranspileError_1.TranspileError(`Invalid heterogeneous enum. Enums should either specify no member values, ` +
`or specify values (of the same type) for all members.`, node);
TSTLErrors.InvalidDecoratorArgumentNumber = (name, got, expected, node) => new TranspileError_1.TranspileError(`${name} expects ${expected} argument(s) but got ${got}.`, node);
TSTLErrors.InvalidDecoratorContext = (node) => new TranspileError_1.TranspileError(`Decorator function cannot have 'this: void'.`, node);
TSTLErrors.InvalidExtensionMetaExtension = (node) => new TranspileError_1.TranspileError(`Cannot use both '@extension' and '@metaExtension' decorators on the same class.`, node);

@@ -18,0 +24,0 @@ TSTLErrors.InvalidNewExpressionOnExtension = (node) => new TranspileError_1.TranspileError(`Cannot construct classes with decorator '@extension' or '@metaExtension'.`, node);

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

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

"@types/jest": "^24.0.11",
"@types/node": "^9.6.23",
"@types/node": "^11.13.0",
"fengari": "^0.1.2",

@@ -51,0 +51,0 @@ "glob": "^7.1.2",

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 too big to display

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