Skip to content

Commit

Permalink
chore: Upgrade to TypeScript 3.7
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jackfranklin committed Mar 31, 2020
1 parent 29b626a commit d05c8da
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/Coverage.js
Expand Up @@ -137,7 +137,7 @@ class JSCoverage {
async stop() {
assert(this._enabled, 'JSCoverage is not enabled');
this._enabled = false;
const [profileResponse] = await Promise.all([
const result = await Promise.all([
this._client.send('Profiler.takePreciseCoverage'),
this._client.send('Profiler.stopPreciseCoverage'),
this._client.send('Profiler.disable'),
Expand All @@ -146,6 +146,7 @@ class JSCoverage {
helper.removeEventListeners(this._eventListeners);

const coverage = [];
const profileResponse = /** @type Protocol.Profiler.takePreciseCoverageReturnValue */ (result[0]);
for (const entry of profileResponse.result) {
let url = this._scriptURLs.get(entry.scriptId);
if (!url && this._reportAnonymousScripts)
Expand Down
4 changes: 3 additions & 1 deletion lib/FrameManager.js
Expand Up @@ -56,10 +56,12 @@ class FrameManager extends EventEmitter {
}

async initialize() {
const [,{frameTree}] = await Promise.all([
const result = await Promise.all([
this._client.send('Page.enable'),
this._client.send('Page.getFrameTree'),
]);

const {frameTree} = /** @type Protocol.Page.getFrameTreeReturnValue*/ (result[1]);
this._handleFrameTree(frameTree);
await Promise.all([
this._client.send('Page.setLifecycleEventsEnabled', { enabled: true }),
Expand Down
4 changes: 0 additions & 4 deletions lib/WebSocketTransport.js
Expand Up @@ -30,10 +30,6 @@ class WebSocketTransport {
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('error', reject);
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -61,7 +61,7 @@
"pixelmatch": "^4.0.2",
"pngjs": "^3.3.3",
"text-diff": "^1.0.1",
"typescript": "3.6.5"
"typescript": "3.7.5"
},
"browser": {
"./lib/BrowserFetcher.js": false,
Expand Down

0 comments on commit d05c8da

Please sign in to comment.