mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore(typescript): migrate src/Dialog (#5639)
This PR changes `src/Dialog.js` to `src/Dialog.ts` and rewrites accordingly. Most of the changes are straight forward; the only interesting one from a TS point of view is the `DialogType` enum. I expose it again as `Dialog.Type` to avoid a breaking change. This PR also exposed some bugs with our ESLint TypeScript settings and applying the overrides, so I fixed those too. I also updated our DocLint tool to work on TS source files over JS lib files if they exist. This is the minimal change to keep the existing doc system working as we're working on moving away from this system longer term.
This commit is contained in:
@@ -3,6 +3,7 @@ const path = require('path');
|
||||
const Documentation = require('./Documentation');
|
||||
module.exports = checkSources;
|
||||
|
||||
|
||||
/**
|
||||
* @param {!Array<!import('../Source')>} sources
|
||||
*/
|
||||
@@ -30,7 +31,23 @@ function checkSources(sources) {
|
||||
const classes = [];
|
||||
/** @type {!Map<string, string>} */
|
||||
const inheritance = new Map();
|
||||
sourceFiles.filter(x => !x.fileName.includes('node_modules')).map(x => visit(x));
|
||||
|
||||
const sourceFilesNoNodeModules = sourceFiles.filter(x => !x.fileName.includes('node_modules'));
|
||||
const sourceFileNamesSet = new Set(sourceFilesNoNodeModules.map(x => x.fileName));
|
||||
sourceFilesNoNodeModules.map(x => {
|
||||
if (x.fileName.includes('/lib/')) {
|
||||
const potentialTSSource = x.fileName.replace('lib', 'src').replace('.js', '.ts');
|
||||
if (sourceFileNamesSet.has(potentialTSSource)) {
|
||||
/* Not going to visit this file because we have the TypeScript src code
|
||||
* which we'll use instead.
|
||||
*/
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
visit(x);
|
||||
});
|
||||
|
||||
const errors = [];
|
||||
const documentation = new Documentation(recreateClassesWithInheritance(classes, inheritance));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user