mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: migrate src/Input to typescript (#5710)
* chore: migrate src/Input to typescript This moves `Keyboard`, `Mouse` and `Touchscreen` to TypeScript. We gain some nice TS benefits here; by creating a type for all the keycodes we support we can type the input args as that rather than `string` which will hopefully save some users some debugging once we ship our TS types in a future version. * Remove from externs file * Update utils/doclint/check_public_api/index.js Co-Authored-By: Mathias Bynens <mathias@qiwi.be> Co-authored-by: Mathias Bynens <mathias@qiwi.be>
This commit is contained in:
@@ -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
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user