Remove a bunch of un-needed null assertions (#49)

This commit is contained in:
Brent Erickson 2019-01-15 11:38:37 -08:00 коммит произвёл GitHub
Родитель 7be18c8bb0
Коммит fb6249faf7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 12 добавлений и 12 удалений

Просмотреть файл

@ -445,7 +445,7 @@ export abstract class SimpleWebRequestBase<TOptions extends WebRequestOptions =
}
}
this._setRequestHeader('Accept', SimpleWebRequestBase.mapContentType(acceptType));
SimpleWebRequest._setRequestHeader(this._xhr, this._xhrRequestHeaders, 'Accept', SimpleWebRequestBase.mapContentType(acceptType));
this._xhr.withCredentials = !!this._options.withCredentials;
@ -470,12 +470,12 @@ export abstract class SimpleWebRequestBase<TOptions extends WebRequestOptions =
}
headersCheck[headerLower] = true;
this._setRequestHeader(key, val);
SimpleWebRequest._setRequestHeader(this._xhr!!!, this._xhrRequestHeaders!!!, key, val);
});
if (this._options.sendData) {
const contentType = SimpleWebRequestBase.mapContentType(this._options.contentType || 'json');
this._setRequestHeader('Content-Type', contentType);
SimpleWebRequest._setRequestHeader(this._xhr, this._xhrRequestHeaders, 'Content-Type', contentType);
const sendData = SimpleWebRequestBase.mapBody(this._options.sendData, contentType);
@ -485,9 +485,9 @@ export abstract class SimpleWebRequestBase<TOptions extends WebRequestOptions =
}
}
private _setRequestHeader(key: string, val: string): void {
this._xhr!!!.setRequestHeader(key, val);
this._xhrRequestHeaders!!![key] = val;
private static _setRequestHeader(xhr: XMLHttpRequest, xhrRequestHeaders: Headers, key: string, val: string): void {
xhr.setRequestHeader(key, val);
xhrRequestHeaders[key] = val;
}
static mapContentType(contentType: string): string {
@ -853,12 +853,12 @@ export class SimpleWebRequest<TBody, TOptions extends WebRequestOptions = WebReq
// Clear the XHR since we technically just haven't started again yet...
if (this._xhr) {
this._xhr.onabort = null!!!;
this._xhr.onerror = null!!!;
this._xhr.onload = null!!!;
this._xhr.onprogress = null!!!;
this._xhr.onreadystatechange = null!!!;
this._xhr.ontimeout = null!!!;
this._xhr.onabort = null;
this._xhr.onerror = null;
this._xhr.onload = null;
this._xhr.onprogress = null;
this._xhr.onreadystatechange = null;
this._xhr.ontimeout = null;
this._xhr = undefined;
this._xhrRequestHeaders = undefined;