Skip to content

Commit

Permalink
fix(types): callback body can be any input type (nodejs#1334)
Browse files Browse the repository at this point in the history
  • Loading branch information
KhafraDev authored and metcoder95 committed Dec 26, 2022
1 parent 7bfb670 commit 0e9a6e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion test/types/mock-interceptor.test-d.ts
@@ -1,7 +1,11 @@
import { expectAssignable } from 'tsd'
import { MockAgent, MockPool } from '../..'
import { MockAgent, MockPool, BodyInit, Dispatcher } from '../..'
import { MockInterceptor, MockScope } from '../../types/mock-interceptor'

declare const mockResponseCallbackOptions: MockInterceptor.MockResponseCallbackOptions;

expectAssignable<BodyInit | Dispatcher.DispatchOptions['body']>(mockResponseCallbackOptions.body)

{
const mockPool: MockPool = new MockAgent().get('')
const mockInterceptor = mockPool.intercept({ path: '', method: 'GET' })
Expand Down
4 changes: 2 additions & 2 deletions types/mock-interceptor.d.ts
@@ -1,6 +1,6 @@
import { IncomingHttpHeaders } from 'http'
import Dispatcher from './dispatcher';
import { Headers } from './fetch'
import { BodyInit, Headers } from './fetch'

export {
Interceptable,
Expand Down Expand Up @@ -71,7 +71,7 @@ declare namespace MockInterceptor {
path: string;
origin: string;
method: string;
body?: string;
body?: BodyInit | Dispatcher.DispatchOptions['body'];
headers: Headers;
maxRedirections: number;
}
Expand Down

0 comments on commit 0e9a6e2

Please sign in to comment.