Skip to content

(types) undici.Response cannot be assigned to Response #3639

@panva

Description

@panva

Bug Description

type undici.Response cannot be assigned to type Response so that module authors can use globally available Response as a type but users may use undici as the implementation to obtain one.

Reproducible By

https://gist.github.com/panva/a350238b643aef7a77b29e6db395c3b9

git clone https://gist.github.com/panva/a350238b643aef7a77b29e6db395c3b9 response-type-reproduction
cd response-type-reproduction
npm i
npx tsc

Expected Behavior

The types should be compatible.

Logs & Screenshots

index.ts:4:3 - error TS2322: Type 'Promise<import("./node_modules/undici/types/fetch").Response>' is not assignable to type 'Promise<Response>'.
  Type 'import("./node_modules/undici/types/fetch").Response' is not assignable to type 'Response'.
    The types returned by 'headers.entries()' are incompatible between these types.
      Type 'SpecIterableIterator<[string, string]>' is missing the following properties from type 'HeadersIterator<[string, string]>': map, filter, take, drop, and 9 more.

4   return undici.fetch(url)
    ~~~~~~


Found 1 error in index.ts:4

Metadata

Metadata

Assignees

No one assigned

    Labels

    TypesChanges related to the TypeScript definitionsbugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions