mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: upgrade to TypeScript 3.7 (#5562)
TypeScript seems to struggle to understand `Promise.all` when the items in the array return different types. If we were authoring in TS we could fix this with TS generics (`Promise.all<OurTypeHere>(...)`) but for now we can typecast the result. We'll fix this properly when we author in TS.
This commit is contained in:
parent
29b626aa94
commit
4b0fd8bc30
@ -137,7 +137,7 @@ class JSCoverage {
|
|||||||
async stop() {
|
async stop() {
|
||||||
assert(this._enabled, 'JSCoverage is not enabled');
|
assert(this._enabled, 'JSCoverage is not enabled');
|
||||||
this._enabled = false;
|
this._enabled = false;
|
||||||
const [profileResponse] = await Promise.all([
|
const result = await Promise.all([
|
||||||
this._client.send('Profiler.takePreciseCoverage'),
|
this._client.send('Profiler.takePreciseCoverage'),
|
||||||
this._client.send('Profiler.stopPreciseCoverage'),
|
this._client.send('Profiler.stopPreciseCoverage'),
|
||||||
this._client.send('Profiler.disable'),
|
this._client.send('Profiler.disable'),
|
||||||
@ -146,6 +146,7 @@ class JSCoverage {
|
|||||||
helper.removeEventListeners(this._eventListeners);
|
helper.removeEventListeners(this._eventListeners);
|
||||||
|
|
||||||
const coverage = [];
|
const coverage = [];
|
||||||
|
const profileResponse = /** @type Protocol.Profiler.takePreciseCoverageReturnValue */ (result[0]);
|
||||||
for (const entry of profileResponse.result) {
|
for (const entry of profileResponse.result) {
|
||||||
let url = this._scriptURLs.get(entry.scriptId);
|
let url = this._scriptURLs.get(entry.scriptId);
|
||||||
if (!url && this._reportAnonymousScripts)
|
if (!url && this._reportAnonymousScripts)
|
||||||
|
@ -56,10 +56,12 @@ class FrameManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async initialize() {
|
async initialize() {
|
||||||
const [,{frameTree}] = await Promise.all([
|
const result = await Promise.all([
|
||||||
this._client.send('Page.enable'),
|
this._client.send('Page.enable'),
|
||||||
this._client.send('Page.getFrameTree'),
|
this._client.send('Page.getFrameTree'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const {frameTree} = /** @type Protocol.Page.getFrameTreeReturnValue*/ (result[1]);
|
||||||
this._handleFrameTree(frameTree);
|
this._handleFrameTree(frameTree);
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this._client.send('Page.setLifecycleEventsEnabled', { enabled: true }),
|
this._client.send('Page.setLifecycleEventsEnabled', { enabled: true }),
|
||||||
|
@ -30,10 +30,6 @@ class WebSocketTransport {
|
|||||||
maxPayload: 256 * 1024 * 1024, // 256Mb
|
maxPayload: 256 * 1024 * 1024, // 256Mb
|
||||||
});
|
});
|
||||||
|
|
||||||
/* error that WebSocket is not assignable to type WebSocket
|
|
||||||
* due to a misisng dispatchEvent() method which the ws library
|
|
||||||
* does not implement and we do not need
|
|
||||||
*/
|
|
||||||
ws.addEventListener('open', () => resolve(new WebSocketTransport(ws)));
|
ws.addEventListener('open', () => resolve(new WebSocketTransport(ws)));
|
||||||
ws.addEventListener('error', reject);
|
ws.addEventListener('error', reject);
|
||||||
});
|
});
|
||||||
|
@ -61,7 +61,7 @@
|
|||||||
"pixelmatch": "^4.0.2",
|
"pixelmatch": "^4.0.2",
|
||||||
"pngjs": "^3.3.3",
|
"pngjs": "^3.3.3",
|
||||||
"text-diff": "^1.0.1",
|
"text-diff": "^1.0.1",
|
||||||
"typescript": "3.6.5"
|
"typescript": "3.7.5"
|
||||||
},
|
},
|
||||||
"browser": {
|
"browser": {
|
||||||
"./lib/BrowserFetcher.js": false,
|
"./lib/BrowserFetcher.js": false,
|
||||||
|
@ -160,7 +160,7 @@ function checkSources(sources) {
|
|||||||
properties.push(...innerType.properties);
|
properties.push(...innerType.properties);
|
||||||
innerTypeNames.push(innerType.name);
|
innerTypeNames.push(innerType.name);
|
||||||
}
|
}
|
||||||
if (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);
|
||||||
return new Documentation.Type(`${type.symbol.name}<${innerTypeNames.join(', ')}>`, properties);
|
return new Documentation.Type(`${type.symbol.name}<${innerTypeNames.join(', ')}>`, properties);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user