Skip to content

Commit 99aa7f2

Browse files
committed
Adds test coverage for the did you mean on CLI args
1 parent af7e232 commit 99aa7f2

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/compiler/commandLineParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ namespace ts {
11641164
if (possibleOption) {
11651165
errors.push(createCompilerDiagnostic(unknownDidYouMeanDiagnostic, s, possibleOption.name));
11661166
}
1167-
else {
1167+
else {
11681168
errors.push(createCompilerDiagnostic(unknownOptionDiagnostic, s));
11691169
}
11701170
}

src/testRunner/unittests/config/commandLineParsing.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,33 @@ namespace ts {
4040
});
4141
});
4242

43+
it("Handles 'did you mean?' for misspelt flags", () => {
44+
// --lib es6 0.ts
45+
assertParseResult(["--declarations", "--allowTS"], {
46+
errors: [
47+
{
48+
messageText:"Unknown compiler option '--declarations'. Did you mean 'declaration'?",
49+
category: Diagnostics.Unknown_compiler_option_0_Did_you_mean_1.category,
50+
code: Diagnostics.Unknown_compiler_option_0_Did_you_mean_1.code,
51+
file: undefined,
52+
start: undefined,
53+
length: undefined
54+
},
55+
{
56+
messageText: "Unknown compiler option '--allowTS'. Did you mean 'allowJs'?",
57+
category: Diagnostics.Unknown_compiler_option_0_Did_you_mean_1.category,
58+
code: Diagnostics.Unknown_compiler_option_0_Did_you_mean_1.code,
59+
file: undefined,
60+
start: undefined,
61+
length: undefined
62+
}
63+
],
64+
fileNames: [],
65+
options: {}
66+
});
67+
});
68+
69+
4370
it("Parse multiple options of library flags ", () => {
4471
// --lib es5,es2015.symbol.wellknown 0.ts
4572
assertParseResult(["--lib", "es5,es2015.symbol.wellknown", "0.ts"],
@@ -556,4 +583,6 @@ namespace ts {
556583
verifyInvalidCombination("watch", "dry");
557584
});
558585
});
586+
587+
559588
}

0 commit comments

Comments
 (0)