From 4be39f8af08d31fd2ca589ba9e8d96e470ef31b8 Mon Sep 17 00:00:00 2001 From: Joel Einbinder Date: Wed, 5 Feb 2020 16:53:36 -0800 Subject: [PATCH] chore(types): upgrade to typescript 3.7.5 (#855) --- package.json | 2 +- src/chromium/crBrowser.ts | 6 +++--- src/chromium/crCoverage.ts | 2 +- src/chromium/crPage.ts | 2 +- src/dom.ts | 2 +- src/firefox/ffBrowser.ts | 4 ++-- src/frames.ts | 2 +- src/helper.ts | 2 +- src/network.ts | 6 +++--- src/webkit/wkPage.ts | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index e34742c7a5..af3d5a56d8 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "pixelmatch": "^4.0.2", "text-diff": "^1.0.1", "ts-loader": "^6.1.2", - "typescript": "3.6.3", + "typescript": "^3.7.5", "webpack": "^4.41.0", "webpack-cli": "^3.3.9" }, diff --git a/src/chromium/crBrowser.ts b/src/chromium/crBrowser.ts index 8d157e486c..74d513b20b 100644 --- a/src/chromium/crBrowser.ts +++ b/src/chromium/crBrowser.ts @@ -93,8 +93,8 @@ export class CRBrowser extends platform.EventEmitter implements Browser { close: async (): Promise => { assert(contextId, 'Non-incognito profiles cannot be closed!'); - await this._client.send('Target.disposeBrowserContext', { browserContextId: contextId! }); - this._contexts.delete(contextId!); + await this._client.send('Target.disposeBrowserContext', { browserContextId: contextId }); + this._contexts.delete(contextId); }, cookies: async (): Promise => { @@ -288,7 +288,7 @@ export class CRBrowser extends platform.EventEmitter implements Browser { assert(this._tracingClient, 'Tracing was not started.'); let fulfill: (buffer: platform.BufferType) => void; const contentPromise = new Promise(x => fulfill = x); - this._tracingClient!.once('Tracing.tracingComplete', event => { + this._tracingClient.once('Tracing.tracingComplete', event => { readProtocolStream(this._tracingClient!, event.stream!, this._tracingPath).then(fulfill); }); await this._tracingClient!.send('Tracing.end'); diff --git a/src/chromium/crCoverage.ts b/src/chromium/crCoverage.ts index 2568bc8bcc..fcc8e789a1 100644 --- a/src/chromium/crCoverage.ts +++ b/src/chromium/crCoverage.ts @@ -129,7 +129,7 @@ class JSCoverage { this._client.send('Profiler.stopPreciseCoverage'), this._client.send('Profiler.disable'), this._client.send('Debugger.disable'), - ]); + ] as const); helper.removeEventListeners(this._eventListeners); const coverage = []; diff --git a/src/chromium/crPage.ts b/src/chromium/crPage.ts index e74687d3b7..3b9ebdd156 100644 --- a/src/chromium/crPage.ts +++ b/src/chromium/crPage.ts @@ -91,7 +91,7 @@ export class CRPage implements PageDelegate { const [,{frameTree}] = await Promise.all([ this._client.send('Page.enable'), this._client.send('Page.getFrameTree'), - ]); + ] as const); this._handleFrameTree(frameTree); const promises: Promise[] = [ this._client.send('Log.enable', {}), diff --git a/src/dom.ts b/src/dom.ts index 809d2920c7..e21aa85548 100644 --- a/src/dom.ts +++ b/src/dom.ts @@ -237,7 +237,7 @@ export class ElementHandle extends js.JSHandle { const [quads, metrics] = await Promise.all([ this._page._delegate.getContentQuads(this), this._page._delegate.layoutViewport(), - ]); + ] as const); if (!quads || !quads.length) throw new Error('Node is either not visible or not an HTMLElement'); diff --git a/src/firefox/ffBrowser.ts b/src/firefox/ffBrowser.ts index a70e18c026..6174869d1e 100644 --- a/src/firefox/ffBrowser.ts +++ b/src/firefox/ffBrowser.ts @@ -188,8 +188,8 @@ export class FFBrowser extends platform.EventEmitter implements Browser { close: async (): Promise => { assert(browserContextId, 'Non-incognito profiles cannot be closed!'); - await this._connection.send('Target.removeBrowserContext', { browserContextId: browserContextId! }); - this._contexts.delete(browserContextId!); + await this._connection.send('Target.removeBrowserContext', { browserContextId }); + this._contexts.delete(browserContextId); }, cookies: async (): Promise => { diff --git a/src/frames.ts b/src/frames.ts index 23d4c9378b..44646ace0f 100644 --- a/src/frames.ts +++ b/src/frames.ts @@ -783,7 +783,7 @@ export class Frame { const context = await this._context('utility'); const maybeHandle = await context._$(selector); assert(maybeHandle, 'No node found for selector: ' + selector); - handle = maybeHandle!; + handle = maybeHandle; } return handle; } diff --git a/src/helper.ts b/src/helper.ts index bf4e8f2bb4..cb9d5142f0 100644 --- a/src/helper.ts +++ b/src/helper.ts @@ -219,7 +219,7 @@ class Helper { } } -export function assert(value: any, message?: string) { +export function assert(value: any, message?: string): asserts value { if (!value) throw new Error(message); } diff --git a/src/network.ts b/src/network.ts index 35692a08fb..b93dc007e8 100644 --- a/src/network.ts +++ b/src/network.ts @@ -201,20 +201,20 @@ export class Request { assert(this._delegate, 'Request Interception is not enabled!'); assert(!this._interceptionHandled, 'Request is already handled!'); this._interceptionHandled = true; - await this._delegate!.abort(errorCode); + await this._delegate.abort(errorCode); } async fulfill(response: { status: number; headers: Headers; contentType: string; body: (string | platform.BufferType); }) { // Mocking responses for dataURL requests is not currently supported. assert(this._delegate, 'Request Interception is not enabled!'); assert(!this._interceptionHandled, 'Request is already handled!'); this._interceptionHandled = true; - await this._delegate!.fulfill(response); + await this._delegate.fulfill(response); } async continue(overrides: { method?: string; headers?: Headers; postData?: string } = {}) { assert(this._delegate, 'Request Interception is not enabled!'); assert(!this._interceptionHandled, 'Request is already handled!'); - await this._delegate!.continue(overrides); + await this._delegate.continue(overrides); } _isIntercepted(): boolean { diff --git a/src/webkit/wkPage.ts b/src/webkit/wkPage.ts index 4c88459e10..cf3b79fd34 100644 --- a/src/webkit/wkPage.ts +++ b/src/webkit/wkPage.ts @@ -112,7 +112,7 @@ export class WKPage implements PageDelegate { // Page agent must be enabled before Runtime. session.send('Page.enable'), session.send('Page.getResourceTree'), - ]); + ] as const); resourceTreeHandler(frameTree); const promises : Promise[] = [ // Resource tree should be received before first execution context.