@@ -3,97 +3,103 @@ import { JsxEmit } from "typescript";
33import * as diagnosticFactories from "./transpilation/diagnostics" ;
44
55type OmitIndexSignature < T > = {
6- [ K in keyof T as string extends K ? never : number extends K ? never : K ] : T [ K ] ;
6+ [ K in keyof T as string extends K ? never : number extends K ? never : K ] :
7+ T [ K ] ;
78} ;
89
910export interface TransformerImport {
10- transform : string ;
11- import ?: string ;
12- after ?: boolean ;
13- afterDeclarations ?: boolean ;
14- type ?: "program" | "config" | "checker" | "raw" | "compilerOptions" ;
11+ transform : string ;
12+ import ?: string ;
13+ after ?: boolean ;
14+ afterDeclarations ?: boolean ;
15+ type ?: "program" | "config" | "checker" | "raw" | "compilerOptions" ;
1516
16- [ option : string ] : any ;
17+ [ option : string ] : any ;
1718}
1819
1920export interface LuaPluginImport {
20- name : string ;
21- import ?: string ;
21+ name : string ;
22+ import ?: string ;
2223
23- [ option : string ] : any ;
24+ [ option : string ] : any ;
2425}
2526
2627export interface TypeScriptToLuaOptions {
27- buildMode ?: BuildMode ;
28- extension ?: string ;
29- luaBundle ?: string ;
30- luaBundleEntry ?: string ;
31- luaTarget ?: LuaTarget ;
32- luaLibImport ?: LuaLibImportKind ;
33- luaPlugins ?: LuaPluginImport [ ] ;
34- noImplicitGlobalVariables ?: boolean ;
35- noImplicitSelf ?: boolean ;
36- noHeader ?: boolean ;
37- noResolvePaths ?: string [ ] ;
38- plugins ?: Array < ts . PluginImport | TransformerImport > ;
39- sourceMapTraceback ?: boolean ;
40- tstlVerbose ?: boolean ;
41- lua51AllowTryCatchInAsyncAwait ?: boolean ;
42- measurePerformance ?: boolean ;
28+ buildMode ?: BuildMode ;
29+ extension ?: string ;
30+ luaBundle ?: string ;
31+ luaBundleEntry ?: string ;
32+ luaTarget ?: LuaTarget ;
33+ luaLibImport ?: LuaLibImportKind ;
34+ luaPlugins ?: LuaPluginImport [ ] ;
35+ noImplicitGlobalVariables ?: boolean ;
36+ noImplicitSelf ?: boolean ;
37+ disableSelfGlobal ?: boolean ;
38+ noHeader ?: boolean ;
39+ noResolvePaths ?: string [ ] ;
40+ plugins ?: Array < ts . PluginImport | TransformerImport > ;
41+ sourceMapTraceback ?: boolean ;
42+ tstlVerbose ?: boolean ;
43+ lua51AllowTryCatchInAsyncAwait ?: boolean ;
44+ measurePerformance ?: boolean ;
4345}
4446
45- export type CompilerOptions = OmitIndexSignature < ts . CompilerOptions > &
46- TypeScriptToLuaOptions & {
47- [ option : string ] : any ;
48- } ;
47+ export type CompilerOptions =
48+ & OmitIndexSignature < ts . CompilerOptions >
49+ & TypeScriptToLuaOptions
50+ & {
51+ [ option : string ] : any ;
52+ } ;
4953
5054export enum LuaLibImportKind {
51- None = "none" ,
52- Inline = "inline" ,
53- Require = "require" ,
54- RequireMinimal = "require-minimal" ,
55+ None = "none" ,
56+ Inline = "inline" ,
57+ Require = "require" ,
58+ RequireMinimal = "require-minimal" ,
5559}
5660
5761export enum LuaTarget {
58- Universal = "universal" ,
59- Lua50 = "5.0" ,
60- Lua51 = "5.1" ,
61- Lua52 = "5.2" ,
62- Lua53 = "5.3" ,
63- Lua54 = "5.4" ,
64- LuaJIT = "JIT" ,
62+ Universal = "universal" ,
63+ Lua50 = "5.0" ,
64+ Lua51 = "5.1" ,
65+ Lua52 = "5.2" ,
66+ Lua53 = "5.3" ,
67+ Lua54 = "5.4" ,
68+ LuaJIT = "JIT" ,
6569}
6670
6771export enum BuildMode {
68- Default = "default" ,
69- Library = "library" ,
72+ Default = "default" ,
73+ Library = "library" ,
7074}
7175
7276export const isBundleEnabled = ( options : CompilerOptions ) =>
73- options . luaBundle !== undefined && options . luaBundleEntry !== undefined ;
77+ options . luaBundle !== undefined && options . luaBundleEntry !== undefined ;
7478
7579export function validateOptions ( options : CompilerOptions ) : ts . Diagnostic [ ] {
76- const diagnostics : ts . Diagnostic [ ] = [ ] ;
80+ const diagnostics : ts . Diagnostic [ ] = [ ] ;
7781
78- if ( options . luaBundle && ! options . luaBundleEntry ) {
79- diagnostics . push ( diagnosticFactories . luaBundleEntryIsRequired ( ) ) ;
80- }
82+ if ( options . luaBundle && ! options . luaBundleEntry ) {
83+ diagnostics . push ( diagnosticFactories . luaBundleEntryIsRequired ( ) ) ;
84+ }
8185
82- if ( options . luaBundle && options . luaLibImport === LuaLibImportKind . Inline ) {
83- diagnostics . push ( diagnosticFactories . usingLuaBundleWithInlineMightGenerateDuplicateCode ( ) ) ;
84- }
86+ if ( options . luaBundle && options . luaLibImport === LuaLibImportKind . Inline ) {
87+ diagnostics . push (
88+ diagnosticFactories . usingLuaBundleWithInlineMightGenerateDuplicateCode ( ) ,
89+ ) ;
90+ }
8591
86- if ( options . luaBundle && options . buildMode === BuildMode . Library ) {
87- diagnostics . push ( diagnosticFactories . cannotBundleLibrary ( ) ) ;
88- }
92+ if ( options . luaBundle && options . buildMode === BuildMode . Library ) {
93+ diagnostics . push ( diagnosticFactories . cannotBundleLibrary ( ) ) ;
94+ }
8995
90- if ( options . jsx && options . jsx !== JsxEmit . React ) {
91- diagnostics . push ( diagnosticFactories . unsupportedJsxEmit ( ) ) ;
92- }
96+ if ( options . jsx && options . jsx !== JsxEmit . React ) {
97+ diagnostics . push ( diagnosticFactories . unsupportedJsxEmit ( ) ) ;
98+ }
9399
94- if ( options . paths && ! options . baseUrl ) {
95- diagnostics . push ( diagnosticFactories . pathsWithoutBaseUrl ( ) ) ;
96- }
100+ if ( options . paths && ! options . baseUrl ) {
101+ diagnostics . push ( diagnosticFactories . pathsWithoutBaseUrl ( ) ) ;
102+ }
97103
98- return diagnostics ;
104+ return diagnostics ;
99105}
0 commit comments