fix: fix null-type bugs (#3137)

I ran TypeScript against our code with `strictNullChecks` on. Most of the errors generated are noise, because TypeScript doesn't understand how our `assert` method works. But some were legitimate bugs. They are fixed in this patch.
This commit is contained in:
Joel Einbinder
2018-08-24 15:17:36 -07:00
committed by Andrey Lushnikov
parent d1105afaf8
commit 3d7ae2a259
9 changed files with 16 additions and 12 deletions

View File

@@ -172,6 +172,7 @@ class CDPSession extends EventEmitter {
this._lastId = 0;
/** @type {!Map<number, {resolve: function, reject: function, error: !Error, method: string}>}*/
this._callbacks = new Map();
/** @type {null|Connection|CDPSession} */
this._connection = connection;
this._targetType = targetType;
this._sessionId = sessionId;
@@ -234,6 +235,8 @@ class CDPSession extends EventEmitter {
}
async detach() {
if (!this._connection)
throw new Error(`Session already detached. Most likely the ${this._targetType} has been closed.`);
await this._connection.send('Target.detachFromTarget', {sessionId: this._sessionId});
}
@@ -266,8 +269,7 @@ function createProtocolError(error, method, object) {
let message = `Protocol error (${method}): ${object.error.message}`;
if ('data' in object.error)
message += ` ${object.error.data}`;
if (object.error.message)
return rewriteError(error, message);
return rewriteError(error, message);
}
/**