mswjs / msw

Industry standard API mocking for JavaScript.
https://mswjs.io
MIT License
15.97k stars 519 forks source link

Type 'StrictResponse<JsonBodyType>' is not assignable to type 'AsyncResponseResolverReturnType<T>' #2306

Open alvinlal opened 1 month ago

alvinlal commented 1 month ago

Prerequisites

Environment check

Browsers

Chromium (Chrome, Brave, etc.)

Reproduction repository

https://github.com/alvinlal/todo-app-react

Reproduction steps

open test-utils/msw/todo.ts file and see the typescript error thrown from line 15

Current behavior

typescript throwing the below type error for array response types

Type 'StrictResponse<JsonBodyType>' is not assignable to type 'AsyncResponseResolverReturnType<GetTodosResponseDto>'.
  Type 'StrictResponse<JsonBodyType>' is not assignable to type 'StrictResponse<GetTodosResponseDto>'.
    Type 'JsonBodyType' is not assignable to type 'GetTodosResponseDto'.
      Type 'undefined' is not assignable to type 'Todo[]'.ts(2322)
HttpResponse-DE19n76Q.d.ts(40, 215): The expected type comes from the return type of this signature.

Expected behavior

there shouldn't be any type errors,