From 0918ffdd3bcf3464fc445a21cf49a8879c540438 Mon Sep 17 00:00:00 2001
From: Herrington Darkholme <nonamesheep1@gmail.com>
Date: Sun, 23 Oct 2016 15:10:00 +0800
Subject: [PATCH 1/2] Fix #10967, allow boolean flag to have explicit value

---
 src/compiler/commandLineParser.ts | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts
index d6c7dad0e8e4f..c4e079c6a13f6 100644
--- a/src/compiler/commandLineParser.ts
+++ b/src/compiler/commandLineParser.ts
@@ -599,7 +599,13 @@ namespace ts {
                                     i++;
                                     break;
                                 case "boolean":
-                                    options[opt.name] = true;
+                                    // boolean flag has optional value true, false, others
+                                    let optValue = args[i];
+                                    options[opt.name] = optValue !== "false";
+                                    // consume next argument as boolean flag value
+                                    if (optValue === "false" || optValue === "true") {
+                                        i++;
+                                    }
                                     break;
                                 case "string":
                                     options[opt.name] = args[i] || "";

From 3a09f8e6534c4d5e248202af250342f87f702013 Mon Sep 17 00:00:00 2001
From: Herrington Darkholme <nonamesheep1@gmail.com>
Date: Sun, 23 Oct 2016 15:10:27 +0800
Subject: [PATCH 2/2] add commandLineParsing test for boolean flags

---
 src/harness/unittests/commandLineParsing.ts | 35 ++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/src/harness/unittests/commandLineParsing.ts b/src/harness/unittests/commandLineParsing.ts
index 67bc1e9b79560..c15490738fa87 100644
--- a/src/harness/unittests/commandLineParsing.ts
+++ b/src/harness/unittests/commandLineParsing.ts
@@ -1,4 +1,4 @@
-/// <reference path="..\harness.ts" />
+/// <reference path="..\harness.ts" />
 /// <reference path="..\..\compiler\commandLineParser.ts" />
 
 namespace ts {
@@ -338,5 +338,38 @@ namespace ts {
                     }
                 });
         });
+
+        it("Parse explicit boolean flag value", () => {
+            assertParseResult(["--strictNullChecks", "false", "0.ts"],
+                {
+                    errors: [],
+                    fileNames: ["0.ts"],
+                    options: {
+                        strictNullChecks: false,
+                    }
+                });
+        });
+
+        it("Parse non boolean argument after boolean flag", () => {
+            assertParseResult(["--noImplicitAny", "t", "0.ts"],
+                {
+                    errors: [],
+                    fileNames: ["t", "0.ts"],
+                    options: {
+                        noImplicitAny: true,
+                    }
+                });
+        });
+
+        it("Parse implicit boolean flag value", () => {
+            assertParseResult(["--strictNullChecks"],
+                {
+                    errors: [],
+                    fileNames: [],
+                    options: {
+                        strictNullChecks: true,
+                    }
+                });
+        });
     });
 }