mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-14 05:37:20 +03: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) {
|
||||
if (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');
|
||||
@ -232,6 +232,9 @@ function writeComment(comment, indent = '') {
|
||||
function typeToString(type, ...namespace) {
|
||||
if (!type)
|
||||
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));
|
||||
if (type.properties.length && typeString.indexOf('Object') !== -1) {
|
||||
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 response = await page.waitForEvent('response', response => response.url() === 'asdf');
|
||||
const assertion: AssertType<playwright.Response, typeof response> = true;
|
||||
}
|
||||
})();
|
||||
|
||||
// typed handles
|
||||
|
Loading…
Reference in New Issue
Block a user