Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4 tasks done
alvinlal opened this issue Oct 6, 2024 · 0 comments
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:browser Related to MSW running in a browser

Comments

@alvinlal
Copy link

alvinlal commented Oct 6, 2024

Prerequisites

Environment check

  • I'm using the latest msw version
  • I'm using Node.js version 18 or higher

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,

@alvinlal alvinlal added bug Something isn't working needs:triage Issues that have not been investigated yet. scope:browser Related to MSW running in a browser labels Oct 6, 2024
@alvinlal alvinlal changed the title Include Record<string,any>[] in JsonBodyType type error while defining response type for handler Oct 6, 2024
@kettanaito kettanaito changed the title type error while defining response type for handler Type 'StrictResponse<JsonBodyType>' is not assignable to type 'AsyncResponseResolverReturnType<T>' Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:browser Related to MSW running in a browser
Projects
None yet
Development

No branches or pull requests

1 participant