Skip to content

Commit

Permalink
Update namespace type with Fetch exports (#2361)
Browse files Browse the repository at this point in the history
* adds fetch classes to default namespace type

* update tests
  • Loading branch information
Ethan-Arrowood authored Oct 23, 2023
1 parent 24db5d4 commit c31bd88
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/types/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { expectAssignable } from 'tsd'
import Undici, {Pool, Client, errors, fetch, Interceptable, RedirectHandler, DecoratorHandler} from '../..'
import Undici, {Pool, Client, errors, fetch, Interceptable, RedirectHandler, DecoratorHandler, Headers, Response, Request, FormData, File, FileReader} from '../..'
import Dispatcher from "../../types/dispatcher";

expectAssignable<Pool>(new Undici.Pool('', {}))
expectAssignable<Client>(new Undici.Client('', {}))
expectAssignable<Interceptable>(new Undici.MockAgent().get(''))
expectAssignable<typeof errors>(Undici.errors)
expectAssignable<typeof fetch>(Undici.fetch)
expectAssignable<typeof Headers>(Undici.Headers)
expectAssignable<typeof Response>(Undici.Response)
expectAssignable<typeof Request>(Undici.Request)
expectAssignable<typeof FormData>(Undici.FormData)
expectAssignable<typeof File>(Undici.File)
expectAssignable<typeof FileReader>(Undici.FileReader)

const client = new Undici.Client('', {})
const handler: Dispatcher.DispatchHandlers = {}
Expand Down
6 changes: 6 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,11 @@ declare namespace Undici {
var MockAgent: typeof import('./mock-agent').default;
var mockErrors: typeof import('./mock-errors').default;
var fetch: typeof import('./fetch').fetch;
var Headers: typeof import('./fetch').Headers;
var Response: typeof import('./fetch').Response;
var Request: typeof import('./fetch').Request;
var FormData: typeof import('./formdata').FormData;
var File: typeof import('./file').File;
var FileReader: typeof import('./filereader').FileReader;
var caches: typeof import('./cache').caches;
}

0 comments on commit c31bd88

Please sign in to comment.