typescript-to-lua
Version:
A generic TypeScript to Lua transpiler. Write your code in TypeScript and publish Lua!
67 lines (66 loc) • 2 kB
TypeScript
import * as ts from "typescript";
import { Plugin } from "./transpilation/plugins";
type OmitIndexSignature<T> = {
[K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
};
export interface TransformerImport {
transform: string;
import?: string;
after?: boolean;
afterDeclarations?: boolean;
type?: "program" | "config" | "checker" | "raw" | "compilerOptions";
[option: string]: any;
}
export interface LuaPluginImport {
name: string;
import?: string;
[option: string]: any;
}
export interface InMemoryLuaPlugin {
plugin: Plugin | ((options: Record<string, any>) => Plugin);
[option: string]: any;
}
export interface TypeScriptToLuaOptions {
buildMode?: BuildMode;
extension?: string;
luaBundle?: string;
luaBundleEntry?: string;
luaTarget?: LuaTarget;
luaLibImport?: LuaLibImportKind;
luaPlugins?: Array<LuaPluginImport | InMemoryLuaPlugin>;
noImplicitGlobalVariables?: boolean;
noImplicitSelf?: boolean;
noHeader?: boolean;
noResolvePaths?: string[];
plugins?: Array<ts.PluginImport | TransformerImport>;
sourceMapTraceback?: boolean;
tstlVerbose?: boolean;
lua51AllowTryCatchInAsyncAwait?: boolean;
measurePerformance?: boolean;
}
export type CompilerOptions = OmitIndexSignature<ts.CompilerOptions> & TypeScriptToLuaOptions & {
[option: string]: any;
};
export declare enum LuaLibImportKind {
None = "none",
Inline = "inline",
Require = "require",
RequireMinimal = "require-minimal"
}
export declare enum LuaTarget {
Universal = "universal",
Lua50 = "5.0",
Lua51 = "5.1",
Lua52 = "5.2",
Lua53 = "5.3",
Lua54 = "5.4",
LuaJIT = "JIT",
Luau = "Luau"
}
export declare enum BuildMode {
Default = "default",
Library = "library"
}
export declare const isBundleEnabled: (options: CompilerOptions) => boolean;
export declare function validateOptions(options: CompilerOptions): ts.Diagnostic[];
export {};