-
-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: properly infer parameter and return types in
server.boundary()
(…
…#2101) Co-authored-by: Artem Zakharchenko <kettanaito@gmail.com>
- Loading branch information
1 parent
21f44d7
commit 1370736
Showing
3 changed files
with
34 additions
and
7 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
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,27 @@ | ||
import { setupServer } from 'msw/node' | ||
import { test } from 'vitest' | ||
|
||
const fn = (_args: { a: number }): string => 'hello' | ||
|
||
const server = setupServer() | ||
const bound = server.boundary(fn) | ||
|
||
bound({ a: 1 }).toUpperCase() | ||
|
||
bound({ | ||
// @ts-expect-error Expected number, got string. | ||
a: '1', | ||
}) | ||
|
||
bound({ a: 1 }) | ||
// @ts-expect-error Unknown method ".fooBar()" on string. | ||
.fooBar() | ||
|
||
test( | ||
'should work', | ||
server.boundary(({ expect }) => { | ||
expect(true).toBe(true) | ||
// @ts-expect-error Property 'doesntExist' does not exist on type 'ExpectStatic' | ||
expect.doesntExist | ||
}), | ||
) |