Skip to content

mergeDeepLeft type regression in 0.32.0 #150

Description

@jtojnar

I have a helperfunction which stopped to type check when updating from 0.31.1 to 0.32.0. Simplified to:

export const fetchOptions =
    (newOpts: RequestInit) =>
    (url: string, opts: RequestInit = {}) =>
        fetch(url, mergeDeepLeft(opts, newOpts));

https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbziAplA5igIilYAyKAZvAL5xFQQhwDkUAhiACYO0DcAUJygB6Sw4AYwgA7AM7wiKGEIAWAeTAxgY8XAC8nODrgAKUSgDuSmOIBccAEooAjgFcUkgJKjgMAJSaAfNt177KAAbS0koYFF0ABo4CGULaztHFzd4DURSLw1fXVyKGXkA4JjUDGxcAmIYPTizGMMTeI8PLiA

It now fails with the following error:

error TS2769: No overload matches this call.
  Overload 1 of 2, '(input: RequestInfo | URL, init?: RequestInit): Promise<Response>', gave the following error.
    Argument of type 'MergeDeepObject<RequestInit, RequestInit, BuiltIn, undefined, _OptionalKeys<RequestInit>>' is not assignable to parameter of type 'RequestInit'.
      Types of property 'body' are incompatible.
        Type 'unknown' is not assignable to type 'BodyInit'.
  Overload 2 of 2, '(input: RequestInfo | URL, init?: RequestInit): Promise<Response>', gave the following error.
    Argument of type 'MergeDeepObject<RequestInit, RequestInit, BuiltIn, undefined, _OptionalKeys<RequestInit>>' is not assignable to parameter of type 'RequestInit'.
      Types of property 'body' are incompatible.
        Type 'unknown' is not assignable to type 'BodyInit'.

38         fetch(url, mergeDeepLeft(opts, newOpts));
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions