Skip to content

[Feature]: Generics for APIRequestContext and APIResponse #42154

Description

🚀 Feature Request

It would be great to be able to directly type the response type of the provided APIResponse.json() instead of having an any type.

Already discussed in:
#13795

Example

interface User {
  id: string;
  name: string;
}

const response = await request.get<User>('/api/users/42');

// Directly typed as User 🥳
const user = await response.json()

Motivation

It would allow better type safety for requests made with Playwright, instead of using type cast.

Activity

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions