fix: make Serializable type any (#9059)

This commit is contained in:
Max Schmitt 2021-09-23 20:06:34 +02:00 committed by GitHub
parent 40ae28e3bb
commit 89aace688f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 4 deletions

View file

@ -102,7 +102,7 @@ Request's post body in a binary form, if any.
## method: Request.postDataJSON ## method: Request.postDataJSON
* langs: js, python * langs: js, python
- returns: <[null]|[any]> - returns: <[null]|[Serializable]>
Returns parsed request's body for `form-urlencoded` and JSON as a fallback if any. Returns parsed request's body for `form-urlencoded` and JSON as a fallback if any.

2
types/structs.d.ts vendored
View file

@ -19,7 +19,7 @@ import { JSHandle, ElementHandle, Frame, Page, BrowserContext, Locator } from '.
/** /**
* Can be converted to JSON * Can be converted to JSON
*/ */
export type Serializable = {}; export type Serializable = any;
/** /**
* Can be converted to JSON, but may also contain JSHandles. * Can be converted to JSON, but may also contain JSHandles.
*/ */

2
types/types.d.ts vendored
View file

@ -13420,7 +13420,7 @@ export interface Request {
* When the response is `application/x-www-form-urlencoded` then a key/value object of the values will be returned. * When the response is `application/x-www-form-urlencoded` then a key/value object of the values will be returned.
* Otherwise it will be parsed as JSON. * Otherwise it will be parsed as JSON.
*/ */
postDataJSON(): null|any; postDataJSON(): null|Serializable;
/** /**
* Request that was redirected by the server to this one, if any. * Request that was redirected by the server to this one, if any.

View file

@ -793,10 +793,11 @@ playwright.chromium.launch().then(async browser => {
(async () => { (async () => {
const browser = await playwright.chromium.launch(); const browser = await playwright.chromium.launch();
const page = await browser.newPage(); const page = await browser.newPage();
await Promise.all([ const [response] = await Promise.all([
page.waitForResponse(response => response.url().includes('example.com')), page.waitForResponse(response => response.url().includes('example.com')),
page.goto('https://example.com') page.goto('https://example.com')
]); ]);
console.log((await response!.json()).foobar); // JSON return value should be any
await browser.close(); await browser.close();
})(); })();