chore: nit type validator fix (#4830)

This commit is contained in:
Pavel Feldman 2020-12-27 08:42:22 -08:00 committed by GitHub
parent 905f28c339
commit fee7dd7cc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 8 deletions

View File

@ -219,7 +219,7 @@ function checkSources(sources) {
innerTypeNames.push(innerType.name); innerTypeNames.push(innerType.name);
} }
if (innerTypeNames.length === 0 || (innerTypeNames.length === 1 && innerTypeNames[0] === 'void')) if (innerTypeNames.length === 0 || (innerTypeNames.length === 1 && innerTypeNames[0] === 'void'))
return new Documentation.Type(type.symbol.name); return new Documentation.Type(type.symbol.name === 'Promise' ? 'Promise<void>' : type.symbol.name);
return new Documentation.Type(`${type.symbol.name}<${innerTypeNames.join(', ')}>`, properties); return new Documentation.Type(`${type.symbol.name}<${innerTypeNames.join(', ')}>`, properties);
} }
return new Documentation.Type(typeName, []); return new Documentation.Type(typeName, []);

View File

@ -191,16 +191,17 @@ function compareDocumentations(actual, expected) {
[/\ /g, ''], [/\ /g, ''],
// We shortcut ? to null| // We shortcut ? to null|
[/\?/g, 'null|'], [/\?/g, 'null|'],
[/EvaluationArgument/g, 'Object'],
]; ];
const tsReplacers = [ const tsReplacers = [
[/\ /g, ''], [/\ /g, ''],
[/ElementHandle\<Element\>/g, 'ElementHandle'], [/Arg/g, 'Object'],
[/ElementHandle\<Node\>/g, 'ElementHandle'], [/ChromiumBrowserContext/g, 'BrowserContext'],
[/ElementHandle\<T\>/g, 'ElementHandle'], [/ElementHandle<[^>]+>/g, 'ElementHandle'],
[/Handle\<R\>/g, 'JSHandle'], [/Handle<R>/g, 'JSHandle'],
[/JSHandle\<Object\>/g, 'JSHandle'], [/JSHandle<Object>/g, 'JSHandle'],
[/object/g, 'Object'], [/object/g, 'Object'],
[/Promise\<T\>/, 'Promise<Object>'], [/Promise<T>/, 'Promise<Object>'],
[/TextendsNode\?ElementHandle:null/, 'null|ElementHandle'] [/TextendsNode\?ElementHandle:null/, 'null|ElementHandle']
] ]
let actualName = actual.name; let actualName = actual.name;
@ -317,6 +318,8 @@ function normalizeType(type) {
word += c; word += c;
} }
} }
if (word)
result.push(word);
result.sort(); result.sort();
return result.join('|'); return result.join('|');
} }

View File

@ -24,7 +24,7 @@
{ {
"name": "method", "name": "method",
"type": { "type": {
"name": "Promise" "name": "Promise<void>"
}, },
"kind": "method", "kind": "method",
"args": [ "args": [