Skip to content

Commit b1ef2e4

Browse files
committed
lint: hold typed Promise.reject calls to the same rule
A type argument wraps the call in an instantiation expression the untyped pattern does not reach, as rule-gate.grit already pairs for refine(); the typed one-argument and zero-argument forms now sit beside the untyped ones, with fixture cases for each.
1 parent 5894771 commit b1ef2e4

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎lint/never-throw.grit‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
or {
2121
`throw $arg` as $site,
2222
`Promise.reject($arg)` as $site,
23+
`Promise.reject<$_>($arg)` as $site,
2324
// No argument: a rejection with no reason is never a BUG: invariant or a rethrow.
24-
`Promise.reject()` as $site where { $arg = `undefined` }
25+
`Promise.reject()` as $site where { $arg = `undefined` },
26+
`Promise.reject<$_>()` as $site where { $arg = `undefined` }
2527
} where {
2628
not or {
2729
and {

‎test/lint/never-throw.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,9 @@ export function rejections(ok: boolean, error: unknown): Promise<void> {
300300
if (ok) return Promise.reject(new Error("BUG: rejections() was handed ok"));
301301
if (error === null) return Promise.reject(new Error("x")); // outside
302302
if (error === 0) return Promise.reject(); // outside
303+
if (error === 1) return Promise.reject<void>(); // outside
304+
if (error === 2) return Promise.reject<void>(new Error("x")); // outside
305+
if (error === 3) return Promise.reject<void>(new Error("BUG: rejections() was handed 3"));
303306
return Promise.reject(error); // outside
304307
}
305308
export function rejectsTheCatchBinding(run: () => Promise<void>): Promise<void> {

0 commit comments

Comments
 (0)