Skip to content

Commit

Permalink
Remove from externs file
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfranklin committed Apr 22, 2020
1 parent acb0167 commit ae6cea6
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 10 deletions.
4 changes: 0 additions & 4 deletions src/externs.d.ts
@@ -1,16 +1,12 @@
import { Browser as RealBrowser, BrowserContext as RealBrowserContext} from './Browser.js';
import {Target as RealTarget} from './Target.js';
import {Page as RealPage} from './Page.js';
import {Mouse as RealMouse, Keyboard as RealKeyboard, Touchscreen as RealTouchscreen} from './Input.js';
import {Frame as RealFrame, FrameManager as RealFrameManager} from './FrameManager.js';
import {DOMWorld as RealDOMWorld} from './DOMWorld.js';
import { NetworkManager as RealNetworkManager, Request as RealRequest, Response as RealResponse } from './NetworkManager.js';
import * as child_process from 'child_process';
declare global {
module Puppeteer {
export class Mouse extends RealMouse {}
export class Keyboard extends RealKeyboard {}
export class Touchscreen extends RealTouchscreen {}
export class Browser extends RealBrowser {}
export class BrowserContext extends RealBrowserContext {}
export class Target extends RealTarget {}
Expand Down
17 changes: 16 additions & 1 deletion utils/doclint/check_public_api/JSBuilder.js
Expand Up @@ -184,6 +184,15 @@ function checkSources(sources) {
return new Documentation.Type(typeName, []);
}

/**
* @param {!ts.Symbol} symbol
* @return {boolean}
*/
function symbolHasPrivateModifier(symbol) {
const modifiers = symbol.valueDeclaration.modifiers || [];
return modifiers.some(modifier => modifier.kind === ts.SyntaxKind.PrivateKeyword);
}

/**
* @param {string} className
* @param {!ts.Symbol} symbol
Expand All @@ -194,8 +203,14 @@ function checkSources(sources) {
const members = classEvents.get(className) || [];

for (const [name, member] of symbol.members || []) {
if (name.startsWith('_'))

/* Before TypeScript we denoted private methods with an underscore
* but in TypeScript we use the private keyword
* hence we check for either here.
*/
if (name.startsWith('_') || symbolHasPrivateModifier(member))
continue;

const memberType = checker.getTypeOfSymbolAtLocation(member, member.valueDeclaration);
const signature = memberType.getCallSignatures()[0];
if (signature)
Expand Down
37 changes: 32 additions & 5 deletions utils/doclint/check_public_api/index.js
Expand Up @@ -271,6 +271,30 @@ function compareDocumentations(actual, expected) {
actualName: 'Object',
expectedName: 'CommandParameters[T]'
}],
['Method ElementHandle.press() key', {
actualName: 'string',
expectedName: 'KeyInput'
}],
['Method Keyboard.down() key', {
actualName: 'string',
expectedName: 'KeyInput'
}],
['Method Keyboard.press() key', {
actualName: 'string',
expectedName: 'KeyInput'
}],
['Method Keyboard.up() key', {
actualName: 'string',
expectedName: 'KeyInput'
}],
['Method Mouse.down() options', {
actualName: 'Object',
expectedName: 'MouseOptions'
}],
['Method Mouse.up() options', {
actualName: 'Object',
expectedName: 'MouseOptions'
}],
]);

const expectedForSource = expectedNamingMismatches.get(source);
Expand All @@ -295,12 +319,15 @@ function compareDocumentations(actual, expected) {
const actualName = actual.name.replace(/[\? ]/g, '');
// TypeScript likes to add some spaces
const expectedName = expected.name.replace(/\ /g, '');
if (expectedName !== actualName) {
const namingMismatchIsExpected = namingMisMatchInTypeIsExpected(source, actualName, expectedName);
const namingMismatchIsExpected = namingMisMatchInTypeIsExpected(source, actualName, expectedName);
if (expectedName !== actualName && !namingMismatchIsExpected)
errors.push(`${source} ${actualName} != ${expectedName}`);

if (!namingMismatchIsExpected)
errors.push(`${source} ${actualName} != ${expectedName}`);
}

/* If we got a naming mismatch and it was expected, don't check the properties
* as they will likely be considered "wrong" by DocLint too
*/
if (namingMismatchIsExpected) return;
const actualPropertiesMap = new Map(actual.properties.map(property => [property.name, property.type]));
const expectedPropertiesMap = new Map(expected.properties.map(property => [property.name, property.type]));
const propertiesDiff = diff(Array.from(actualPropertiesMap.keys()).sort(), Array.from(expectedPropertiesMap.keys()).sort());
Expand Down

0 comments on commit ae6cea6

Please sign in to comment.