@@ -10,7 +10,8 @@ export interface ParsedCommandLine extends ts.ParsedCommandLine {
1010interface CommandLineOptionBase {
1111 name : string ;
1212 aliases ?: string [ ] ;
13- describe : string ;
13+ description : string ;
14+ isTSConfigOnly ?: boolean ;
1415}
1516
1617interface CommandLineOptionOfEnum extends CommandLineOptionBase {
@@ -22,36 +23,52 @@ interface CommandLineOptionOfBoolean extends CommandLineOptionBase {
2223 type : "boolean" ;
2324}
2425
25- type CommandLineOption = CommandLineOptionOfEnum | CommandLineOptionOfBoolean ;
26+ interface CommandLineOptionOfListType extends CommandLineOptionBase {
27+ isTSConfigOnly : true ;
28+ type : "list" ;
29+ }
30+
31+ type CommandLineOption =
32+ | CommandLineOptionOfEnum
33+ | CommandLineOptionOfBoolean
34+ | CommandLineOptionOfListType ;
35+
2636const optionDeclarations : CommandLineOption [ ] = [
2737 {
2838 name : "luaLibImport" ,
29- describe : "Specifies how js standard features missing in lua are imported." ,
39+ description : "Specifies how js standard features missing in lua are imported." ,
3040 type : "enum" ,
3141 choices : Object . values ( LuaLibImportKind ) ,
3242 } ,
3343 {
3444 name : "luaTarget" ,
3545 aliases : [ "lt" ] ,
36- describe : "Specify Lua target version." ,
46+ description : "Specify Lua target version." ,
3747 type : "enum" ,
3848 choices : Object . values ( LuaTarget ) ,
3949 } ,
4050 {
4151 name : "noHeader" ,
42- describe : "Specify if a header will be added to compiled files." ,
52+ description : "Specify if a header will be added to compiled files." ,
4353 type : "boolean" ,
4454 } ,
4555 {
4656 name : "noHoisting" ,
47- describe : "Disables hoisting." ,
57+ description : "Disables hoisting." ,
4858 type : "boolean" ,
4959 } ,
5060 {
5161 name : "sourceMapTraceback" ,
52- describe : "Applies the source map to show source TS files and lines in error tracebacks." ,
62+ description :
63+ "Applies the source map to show source TS files and lines in error tracebacks." ,
5364 type : "boolean" ,
5465 } ,
66+ {
67+ name : "tsTransformers" ,
68+ description : "Custom TypeScript transformers." ,
69+ isTSConfigOnly : true ,
70+ type : "list" ,
71+ } ,
5572] ;
5673
5774export const version = `Version ${ require ( "../package.json" ) . version } ` ;
@@ -72,13 +89,15 @@ export function getHelpString(): string {
7289
7390 result += "Options:\n" ;
7491 for ( const option of optionDeclarations ) {
92+ if ( option . isTSConfigOnly ) continue ;
93+
7594 const aliasStrings = ( option . aliases || [ ] ) . map ( a => "-" + a ) ;
7695 const optionString = aliasStrings . concat ( [ "--" + option . name ] ) . join ( "|" ) ;
7796
7897 const valuesHint = option . type === "enum" ? option . choices . join ( "|" ) : option . type ;
7998 const spacing = " " . repeat ( Math . max ( 1 , 45 - optionString . length - valuesHint . length ) ) ;
8099
81- result += `\n ${ optionString } <${ valuesHint } >${ spacing } ${ option . describe } \n` ;
100+ result += `\n ${ optionString } <${ valuesHint } >${ spacing } ${ option . description } \n` ;
82101 }
83102
84103 return result ;
@@ -165,14 +184,24 @@ interface CommandLineArgument extends ReadValueResult {
165184}
166185
167186function readCommandLineArgument ( option : CommandLineOption , value : any ) : CommandLineArgument {
187+ if ( option . isTSConfigOnly ) {
188+ return {
189+ value : undefined ,
190+ error : diagnostics . optionCanOnlyBeSpecifiedInTsconfigJsonFile ( option . name ) ,
191+ increment : 0 ,
192+ } ;
193+ }
194+
168195 if ( option . type === "boolean" ) {
169196 if ( value === "true" || value === "false" ) {
170197 value = value === "true" ;
171198 } else {
172199 // Set boolean arguments without supplied value to true
173200 return { value : true , increment : 0 } ;
174201 }
175- } else if ( value === undefined ) {
202+ }
203+
204+ if ( value === undefined ) {
176205 return {
177206 error : diagnostics . compilerOptionExpectsAnArgument ( option . name ) ,
178207 value : undefined ,
@@ -222,6 +251,17 @@ function readValue(option: CommandLineOption, value: unknown): ReadValueResult {
222251
223252 return { value : normalizedValue } ;
224253 }
254+
255+ case "list" : {
256+ if ( ! Array . isArray ( value ) ) {
257+ return {
258+ value : undefined ,
259+ error : diagnostics . compilerOptionRequiresAValueOfType ( option . name , "Array" ) ,
260+ } ;
261+ }
262+
263+ return { value } ;
264+ }
225265 }
226266}
227267
0 commit comments