-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(vitest): improve vi.waitUntil type to excude falsy types (#4572)
- Loading branch information
1 parent
0a14dd8
commit 2365230
Showing
2 changed files
with
20 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { expectTypeOf, test, vi } from 'vitest' | ||
|
||
test('vi.waitUntil correctly resolves return type', () => { | ||
expectTypeOf(vi.waitUntil(() => 'string')).resolves.toEqualTypeOf<string>() | ||
expectTypeOf(vi.waitUntil(() => 1)).resolves.toEqualTypeOf<number>() | ||
|
||
expectTypeOf(vi.waitUntil(() => false as const)).resolves.toEqualTypeOf<never>() | ||
expectTypeOf(vi.waitUntil(() => '' as const)).resolves.toEqualTypeOf<never>() | ||
expectTypeOf(vi.waitUntil(() => 0 as const)).resolves.toEqualTypeOf<never>() | ||
|
||
expectTypeOf(vi.waitUntil(() => '' as '' | number)).resolves.toEqualTypeOf<number>() | ||
expectTypeOf(vi.waitUntil(() => null as null | number)).resolves.toEqualTypeOf<number>() | ||
expectTypeOf(vi.waitUntil(() => undefined as undefined | number)).resolves.toEqualTypeOf<number>() | ||
expectTypeOf(vi.waitUntil(() => false as false | number)).resolves.toEqualTypeOf<number>() | ||
expectTypeOf(vi.waitUntil(() => 0 as 0 | string)).resolves.toEqualTypeOf<string>() | ||
}) |