Skip to content

Commit

Permalink
add more tests for typed control flow
Browse files Browse the repository at this point in the history
  • Loading branch information
ajafff committed Jan 3, 2021
1 parent 220ac71 commit bce158b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/rules/control-flow-typed/assertion.ts.lint
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
export {}
declare function returnNever(): never;
declare function assert(v: any): asserts v;

function test() {
~ [0]
returnNever();
~~~~~~~~~~~ [0]
}

function test2(v: boolean) {
assert(v);
}

function test3() {
try {
~ [0]
returnNever();
~~~~~~~~~~~ [0]
} catch {}
}

[0]: control flow end
36 changes: 36 additions & 0 deletions test/rules/exhaustive-switch/test.ts.lint
Original file line number Diff line number Diff line change
Expand Up @@ -278,3 +278,39 @@ declare function get<T>(): T;
}
debugger;
};

<T>() => {
switch (get<T>()) {
~~~~~~ [not exhaustive]
case get<T>():
return;
}
debugger;
};

<T extends 1>() => {
switch (get<T>()) {
~~~~~~ [not exhaustive]
case get<T>():
return;
}
debugger;
};

<T extends 1>() => {
switch (get<T>()) {
~~~~~~ [not exhaustive]
case get<1>():
return;
}
debugger;
};

<T extends 1>() => {
switch (get<1>()) {
~~~~~~ [not exhaustive]
case get<T>():
return;
}
debugger;
};

0 comments on commit bce158b

Please sign in to comment.