mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Specified diagnostic for CLI flags mismatched with/out --build (#43199)
* Specified diagnostic for CLI flags missing a required --build * Switched to an alternateMode member * Added --build-incompatible flags too * Small fixups to remove a hardcoding * Switched to ||= factories * Not a function * I think I get it now
This commit is contained in:
1 parent
2f82d02361
commit
fe4a6709da
4 files changed
+87
-13
No files matched your search
@@ -46,6 +46,23 @@ namespace ts {
|
||||
});
|
||||
});
|
||||
|
||||
it("Handles 'may only be used with --build' flags", () => {
|
||||
const buildFlags = ["--clean", "--dry", "--force", "--verbose"];
|
||||
|
||||
assertParseResult(buildFlags, {
|
||||
errors: buildFlags.map(buildFlag => ({
|
||||
messageText: `Compiler option '${buildFlag}' may only be used with '--build'.`,
|
||||
category: Diagnostics.Compiler_option_0_may_only_be_used_with_build.category,
|
||||
code: Diagnostics.Compiler_option_0_may_only_be_used_with_build.code,
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined
|
||||
})),
|
||||
fileNames: [],
|
||||
options: {}
|
||||
});
|
||||
});
|
||||
|
||||
it("Handles 'did you mean?' for misspelt flags", () => {
|
||||
// --declarations --allowTS
|
||||
assertParseResult(["--declarations", "--allowTS"], {
|
||||
@@ -790,9 +807,9 @@ namespace ts {
|
||||
assertParseResult(["--listFilesOnly"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "Unknown build option '--listFilesOnly'.",
|
||||
category: Diagnostics.Unknown_build_option_0.category,
|
||||
code: Diagnostics.Unknown_build_option_0.code,
|
||||
messageText: "Compiler option '--listFilesOnly' may not be used with '--build'.",
|
||||
category: Diagnostics.Compiler_option_0_may_not_be_used_with_build.category,
|
||||
code: Diagnostics.Compiler_option_0_may_not_be_used_with_build.code,
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined,
|
||||
@@ -863,9 +880,9 @@ namespace ts {
|
||||
assertParseResult(["--tsBuildInfoFile", "build.tsbuildinfo", "tests"],
|
||||
{
|
||||
errors: [{
|
||||
messageText: "Unknown build option '--tsBuildInfoFile'.",
|
||||
category: Diagnostics.Unknown_build_option_0.category,
|
||||
code: Diagnostics.Unknown_build_option_0.code,
|
||||
messageText: "Compiler option '--tsBuildInfoFile' may not be used with '--build'.",
|
||||
category: Diagnostics.Compiler_option_0_may_not_be_used_with_build.category,
|
||||
code: Diagnostics.Compiler_option_0_may_not_be_used_with_build.code,
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined
|
||||
@@ -876,6 +893,24 @@ namespace ts {
|
||||
});
|
||||
});
|
||||
|
||||
it("reports other common 'may not be used with --build' flags", () => {
|
||||
const buildFlags = ["--declaration", "--strict"];
|
||||
|
||||
assertParseResult(buildFlags, {
|
||||
errors: buildFlags.map(buildFlag => ({
|
||||
messageText: `Compiler option '${buildFlag}' may not be used with '--build'.`,
|
||||
category: Diagnostics.Compiler_option_0_may_not_be_used_with_build.category,
|
||||
code: Diagnostics.Compiler_option_0_may_not_be_used_with_build.code,
|
||||
file: undefined,
|
||||
start: undefined,
|
||||
length: undefined
|
||||
})),
|
||||
buildOptions: {},
|
||||
projects: ["."],
|
||||
watchOptions: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
describe("Combining options that make no sense together", () => {
|
||||
function verifyInvalidCombination(flag1: keyof BuildOptions, flag2: keyof BuildOptions) {
|
||||
it(`--${flag1} and --${flag2} together is invalid`, () => {
|
||||
|
||||
Reference in new issue
Block a user