mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(types): fix type generation to make ts tests work (#3385)
This commit is contained in:
parent
812d7eefe9
commit
55a78482e4
@ -177,7 +177,7 @@ function classBody(classDesc) {
|
|||||||
for (const {eventName, params, comment, type} of eventDescriptions) {
|
for (const {eventName, params, comment, type} of eventDescriptions) {
|
||||||
if (comment)
|
if (comment)
|
||||||
parts.push(writeComment(comment, ' '));
|
parts.push(writeComment(comment, ' '));
|
||||||
parts.push(` ${member.name}(event: '${eventName}', optionsOrPredicate?: { predicate?: (${params}) => boolean, timeout?: number }): Promise<${type}>;\n`);
|
parts.push(` ${member.name}(event: '${eventName}', optionsOrPredicate?: { predicate?: (${params}) => boolean, timeout?: number } | ((${params}) => boolean)): Promise<${type}>;\n`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return parts.join('\n');
|
return parts.join('\n');
|
||||||
@ -232,6 +232,9 @@ function writeComment(comment, indent = '') {
|
|||||||
function typeToString(type, ...namespace) {
|
function typeToString(type, ...namespace) {
|
||||||
if (!type)
|
if (!type)
|
||||||
return 'void';
|
return 'void';
|
||||||
|
// Accessibility.snapshot has a recursive data structure, so special case it here.
|
||||||
|
if (namespace[0] === 'AccessibilitySnapshot' && namespace[1] === 'children')
|
||||||
|
return 'Array<AccessibilitySnapshot>';
|
||||||
let typeString = stringifyType(parseType(type.name));
|
let typeString = stringifyType(parseType(type.name));
|
||||||
if (type.properties.length && typeString.indexOf('Object') !== -1) {
|
if (type.properties.length && typeString.indexOf('Object') !== -1) {
|
||||||
const name = namespace.map(n => n[0].toUpperCase() + n.substring(1)).join('');
|
const name = namespace.map(n => n[0].toUpperCase() + n.substring(1)).join('');
|
||||||
|
@ -399,6 +399,10 @@ playwright.chromium.launch().then(async browser => {
|
|||||||
});
|
});
|
||||||
const assertion: AssertType<playwright.Page, typeof newPage> = true;
|
const assertion: AssertType<playwright.Page, typeof newPage> = true;
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
const response = await page.waitForEvent('response', response => response.url() === 'asdf');
|
||||||
|
const assertion: AssertType<playwright.Response, typeof response> = true;
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// typed handles
|
// typed handles
|
||||||
|
Loading…
x
Reference in New Issue
Block a user