Skip to content

Commit 894cc63

Browse files
committed
Add tests
1 parent 8619bff commit 894cc63

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

tests/cases/conformance/controlFlow/assertionTypePredicates1.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,14 @@ declare class Wat {
126126
get p2(): asserts this is string;
127127
set p2(x: asserts this is string);
128128
}
129+
130+
function f20(x: unknown) {
131+
const assert = (value: unknown): asserts value => {}
132+
assert(typeof x === "string"); // Error
133+
const a = [assert];
134+
a[0](typeof x === "string"); // Error
135+
const t1 = new Test();
136+
t1.assert(typeof x === "string"); // Error
137+
const t2: Test = new Test();
138+
t2.assert(typeof x === "string");
139+
}

tests/cases/conformance/controlFlow/neverReturningFunctions1.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ function f42(x: number) {
157157
x; // Unreachable
158158
}
159159

160+
function f43() {
161+
const fail = (): never => { throw new Error(); };
162+
const f = [fail];
163+
fail(); // Error
164+
f[0](); // Error
165+
}
166+
160167
// Repro from #33582
161168

162169
export interface Component<T extends object = any> {

0 commit comments

Comments
 (0)