Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): add generic type to MockedRequest.passthrough #2198

Merged
merged 1 commit into from
Sep 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/utils/request/MockedRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,16 @@ export class MockedRequest<
* Bypass the intercepted request.
* This will make a call to the actual endpoint requested.
*/
public passthrough(): MockedResponse<null> {
public passthrough<
BodyType extends DefaultBodyType = null,
>(): MockedResponse<BodyType> {
return {
// Constructing a dummy "101 Continue" mocked response
// to keep the return type of the resolver consistent.
status: 101,
statusText: 'Continue',
headers: new Headers(),
body: null,
body: null as BodyType,
// Setting "passthrough" to true will signal the response pipeline
// to perform this intercepted request as-is.
passthrough: true,
Expand Down