Skip to content

Commit eeaa752

Browse files
committed
Add tests
1 parent d415b57 commit eeaa752

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/cases/conformance/controlFlow/assertionTypePredicates1.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ function f01(x: unknown) {
3737
assertDefined(x);
3838
x; // string
3939
}
40+
if (!!true) {
41+
assert(false);
42+
x; // Unreachable
43+
}
44+
if (!!true) {
45+
assert(false && x === undefined);
46+
x; // Unreachable
47+
}
4048
}
4149

4250
function f02(x: string | undefined) {
@@ -77,6 +85,10 @@ function f10(x: string | undefined) {
7785
Debug.assertDefined(x);
7886
x.length;
7987
}
88+
if (!!true) {
89+
Debug.assert(false);
90+
x; // Unreachable
91+
}
8092
}
8193

8294
class Test {
@@ -108,6 +120,10 @@ class Test {
108120
this.assertIsTest2();
109121
this.z;
110122
}
123+
baz(x: number) {
124+
this.assert(false);
125+
x; // Unreachable
126+
}
111127
}
112128

113129
class Test2 extends Test {

0 commit comments

Comments
 (0)