-
-
Notifications
You must be signed in to change notification settings - Fork 729
Description
Bug Description
The Request interface exposed by Undici does not satisfy the same type from the global type definitions (lib/dom), and also missing properties according to the Fetch API specification:
Line 138 in d8d9a96
| export declare class Request implements BodyMixin { |
Reproducible By
As an example, consider the following code:
import { Request } from 'undicit'
function transform(req: globalThis.Request) {}
transform(new Request('/hello'))
// ^^^ Property 'referrer' is missing in type 'import(".../node_modules/undici/types/fetch").Request' but required in type 'Request'.ts(2345)The referrer property is not present in the Undici's Request type definition while it's both required in lib/dom definitions and the Fetch API specification.
readonly attribute [USVString](https://webidl.spec.whatwg.org/#idl-USVString) [referrer](https://fetch.spec.whatwg.org/#dom-request-referrer);Expected Behavior
Fetch API primitives such as Request, Response and Headers, are compatible with the global
Logs & Screenshots
No applicable logs.
Environment
- Node: v16.16.0
- Undici: ^5.20.0
- TypeScript: ^4.9.4
Additional context
I understand that I'm setting lib/dom as the source of truth here but I expect that shouldn't matter since:
- Both Undici and
lib/nodeaim to implement the Fetch API specification. - Undici is objectively missing some properties in its type definitions defined in the spec, like
referrer.
Also, for context, I'm spotting this while building Interceptors (mswjs/interceptors#340) where I try using Undici as a Fetch polyfill to guarantee fetch primitives can be created in Node versions prior to global fetch.
I'd like to open a pull request to ensure this compliance after discussing this with the maintainers of this lib.