build: upgrade to TypeScript 2.6 (#21144)

Fixes #20653

PR Close #21144
This commit is contained in:
Chuck Jazdzewski
2017-12-22 09:36:47 -08:00
committed by Igor Minar
parent 83c1383701
commit 83d207d0a7
45 changed files with 331 additions and 215 deletions

View File

@ -57,17 +57,26 @@ export class MockBody implements Body {
export class MockHeaders implements Headers {
map = new Map<string, string>();
[Symbol.iterator]() { return this.map[Symbol.iterator](); }
append(name: string, value: string): void { this.map.set(name, value); }
delete (name: string): void { this.map.delete(name); }
entries() { return this.map.entries(); }
forEach(callback: Function): void { this.map.forEach(callback as any); }
get(name: string): string|null { return this.map.get(name) || null; }
has(name: string): boolean { return this.map.has(name); }
keys() { return this.map.keys(); }
set(name: string, value: string): void { this.map.set(name, value); }
values() { return this.map.values(); }
}
export class MockRequest extends MockBody implements Request {
@ -91,13 +100,12 @@ export class MockRequest extends MockBody implements Request {
throw 'Not implemented';
}
this.url = input;
if (init.headers !== undefined) {
if (init.headers instanceof MockHeaders) {
this.headers = init.headers;
const headers = init.headers as{[key: string]: string};
if (headers !== undefined) {
if (headers instanceof MockHeaders) {
this.headers = headers;
} else {
Object.keys(init.headers).forEach(header => {
this.headers.set(header, init.headers[header]);
});
Object.keys(headers).forEach(header => { this.headers.set(header, headers[header]); });
}
}
if (init.mode !== undefined) {
@ -134,13 +142,12 @@ export class MockResponse extends MockBody implements Response {
super(typeof body === 'string' ? body : null);
this.status = (init.status !== undefined) ? init.status : 200;
this.statusText = init.statusText || 'OK';
if (init.headers !== undefined) {
if (init.headers instanceof MockHeaders) {
this.headers = init.headers;
const headers = init.headers as{[key: string]: string};
if (headers !== undefined) {
if (headers instanceof MockHeaders) {
this.headers = headers;
} else {
Object.keys(init.headers).forEach(header => {
this.headers.set(header, init.headers[header]);
});
Object.keys(headers).forEach(header => { this.headers.set(header, headers[header]); });
}
}
if (init.type !== undefined) {