@@ -1088,11 +1088,11 @@ namespace ts {
1088
1088
}
1089
1089
1090
1090
/** Tuple with error messages for 'unknown compiler option', 'option requires type' */
1091
- type ParseCommandLineWorkerDiagnostics = [ DiagnosticMessage , DiagnosticMessage ] ;
1091
+ type ParseCommandLineWorkerDiagnostics = [ DiagnosticMessage , DiagnosticMessage , DiagnosticMessage ] ;
1092
1092
1093
1093
function parseCommandLineWorker (
1094
1094
getOptionNameMap : ( ) => OptionNameMap ,
1095
- [ unknownOptionDiagnostic , optionTypeMismatchDiagnostic ] : ParseCommandLineWorkerDiagnostics ,
1095
+ [ unknownOptionDiagnostic , unknownDidYouMeanDiagnostic , optionTypeMismatchDiagnostic ] : ParseCommandLineWorkerDiagnostics ,
1096
1096
commandLine : readonly string [ ] ,
1097
1097
readFile ?: ( path : string ) => string | undefined ) {
1098
1098
const options = { } as OptionsBase ;
@@ -1160,7 +1160,13 @@ namespace ts {
1160
1160
}
1161
1161
}
1162
1162
else {
1163
- errors . push ( createCompilerDiagnostic ( unknownOptionDiagnostic , s ) ) ;
1163
+ const possibleOption = getSpellingSuggestion ( s , optionDeclarations , opt => `--${ opt . name } ` ) ;
1164
+ if ( possibleOption ) {
1165
+ errors . push ( createCompilerDiagnostic ( unknownDidYouMeanDiagnostic , s , possibleOption . name ) ) ;
1166
+ }
1167
+ else {
1168
+ errors . push ( createCompilerDiagnostic ( unknownOptionDiagnostic , s ) ) ;
1169
+ }
1164
1170
}
1165
1171
}
1166
1172
else {
@@ -1206,6 +1212,7 @@ namespace ts {
1206
1212
export function parseCommandLine ( commandLine : readonly string [ ] , readFile ?: ( path : string ) => string | undefined ) : ParsedCommandLine {
1207
1213
return parseCommandLineWorker ( getOptionNameMap , [
1208
1214
Diagnostics . Unknown_compiler_option_0 ,
1215
+ Diagnostics . Unknown_compiler_option_0_Did_you_mean_1 ,
1209
1216
Diagnostics . Compiler_option_0_expects_an_argument
1210
1217
] , commandLine , readFile ) ;
1211
1218
}
@@ -1241,6 +1248,7 @@ namespace ts {
1241
1248
const returnBuildOptionNameMap = ( ) => ( buildOptionNameMap || ( buildOptionNameMap = createOptionNameMap ( buildOpts ) ) ) ;
1242
1249
const { options, fileNames : projects , errors } = parseCommandLineWorker ( returnBuildOptionNameMap , [
1243
1250
Diagnostics . Unknown_build_option_0 ,
1251
+ Diagnostics . Unknown_compiler_option_0_Did_you_mean_1 ,
1244
1252
Diagnostics . Build_option_0_requires_a_value_of_type_1
1245
1253
] , args ) ;
1246
1254
const buildOptions = options as BuildOptions ;
0 commit comments