From fee7dd7cc11f41c73ad949ee1c253aa6d3e110c5 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Sun, 27 Dec 2020 08:42:22 -0800 Subject: [PATCH] chore: nit type validator fix (#4830) --- utils/doclint/check_public_api/JSBuilder.js | 2 +- utils/doclint/check_public_api/index.js | 15 +++++++++------ .../test/js-builder-common/result.txt | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/utils/doclint/check_public_api/JSBuilder.js b/utils/doclint/check_public_api/JSBuilder.js index 5cd6e4d0dd..d83b65c979 100644 --- a/utils/doclint/check_public_api/JSBuilder.js +++ b/utils/doclint/check_public_api/JSBuilder.js @@ -219,7 +219,7 @@ function checkSources(sources) { innerTypeNames.push(innerType.name); } 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' : type.symbol.name); return new Documentation.Type(`${type.symbol.name}<${innerTypeNames.join(', ')}>`, properties); } return new Documentation.Type(typeName, []); diff --git a/utils/doclint/check_public_api/index.js b/utils/doclint/check_public_api/index.js index 2cd2103939..6b71bf73d1 100644 --- a/utils/doclint/check_public_api/index.js +++ b/utils/doclint/check_public_api/index.js @@ -191,16 +191,17 @@ function compareDocumentations(actual, expected) { [/\ /g, ''], // We shortcut ? to null| [/\?/g, 'null|'], + [/EvaluationArgument/g, 'Object'], ]; const tsReplacers = [ [/\ /g, ''], - [/ElementHandle\/g, 'ElementHandle'], - [/ElementHandle\/g, 'ElementHandle'], - [/ElementHandle\/g, 'ElementHandle'], - [/Handle\/g, 'JSHandle'], - [/JSHandle\/g, 'JSHandle'], + [/Arg/g, 'Object'], + [/ChromiumBrowserContext/g, 'BrowserContext'], + [/ElementHandle<[^>]+>/g, 'ElementHandle'], + [/Handle/g, 'JSHandle'], + [/JSHandle/g, 'JSHandle'], [/object/g, 'Object'], - [/Promise\/, 'Promise'], + [/Promise/, 'Promise'], [/TextendsNode\?ElementHandle:null/, 'null|ElementHandle'] ] let actualName = actual.name; @@ -317,6 +318,8 @@ function normalizeType(type) { word += c; } } + if (word) + result.push(word); result.sort(); return result.join('|'); } diff --git a/utils/doclint/check_public_api/test/js-builder-common/result.txt b/utils/doclint/check_public_api/test/js-builder-common/result.txt index 40e9475b02..09856293db 100644 --- a/utils/doclint/check_public_api/test/js-builder-common/result.txt +++ b/utils/doclint/check_public_api/test/js-builder-common/result.txt @@ -24,7 +24,7 @@ { "name": "method", "type": { - "name": "Promise" + "name": "Promise" }, "kind": "method", "args": [