From eeaa7528339b069d6cf77e42f53105d2957f1b0b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 5 Oct 2019 18:33:00 -0700 Subject: [PATCH] Add tests --- .../controlFlow/assertionTypePredicates1.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/cases/conformance/controlFlow/assertionTypePredicates1.ts b/tests/cases/conformance/controlFlow/assertionTypePredicates1.ts index 4cc73d5c917..53d400ed91b 100644 --- a/tests/cases/conformance/controlFlow/assertionTypePredicates1.ts +++ b/tests/cases/conformance/controlFlow/assertionTypePredicates1.ts @@ -37,6 +37,14 @@ function f01(x: unknown) { assertDefined(x); x; // string } + if (!!true) { + assert(false); + x; // Unreachable + } + if (!!true) { + assert(false && x === undefined); + x; // Unreachable + } } function f02(x: string | undefined) { @@ -77,6 +85,10 @@ function f10(x: string | undefined) { Debug.assertDefined(x); x.length; } + if (!!true) { + Debug.assert(false); + x; // Unreachable + } } class Test { @@ -108,6 +120,10 @@ class Test { this.assertIsTest2(); this.z; } + baz(x: number) { + this.assert(false); + x; // Unreachable + } } class Test2 extends Test {