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

@ -124,7 +124,7 @@ export class AppVersion implements UpdateSource {
// No response has been found yet. Maybe this group will have one.
return group.handleFetch(req, context);
}, Promise.resolve(null));
}, Promise.resolve<Response|null>(null));
// The result of the above is the asset response, if there is any, or null otherwise. Return the
// asset
@ -142,7 +142,7 @@ export class AppVersion implements UpdateSource {
}
return group.handleFetch(req, context);
}, Promise.resolve(null));
}, Promise.resolve<Response|null>(null));
// If the data caching group returned a response, go with it.
if (data !== null) {

View File

@ -276,6 +276,7 @@ export abstract class AssetGroup {
const cache = await this.cache;
// Start with the set of all cached URLs.
return (await cache.keys())
.map(request => request.url)
// Exclude the URLs which have hashes.
.filter(url => !this.hashes.has(url));
}
@ -608,4 +609,4 @@ export class LazyAssetGroup extends AssetGroup {
}
}, Promise.resolve());
}
}
}

View File

@ -51,7 +51,7 @@ export class CacheTable implements Table {
'delete'(key: string): Promise<boolean> { return this.cache.delete(this.request(key)); }
keys(): Promise<string[]> {
return this.cache.keys().then(keys => keys.map(key => key.substr(1)));
return this.cache.keys().then(requests => requests.map(req => req.url.substr(1)));
}
read(key: string): Promise<any> {
@ -66,4 +66,4 @@ export class CacheTable implements Table {
write(key: string, value: Object): Promise<void> {
return this.cache.put(this.request(key), this.adapter.newResponse(JSON.stringify(value)));
}
}
}

View File

@ -25,33 +25,6 @@ interface ExtendableEvent extends Event {
waitUntil(fn: Promise<any>): void;
}
// CacheStorage API
interface Cache {
add(request: Request): Promise<void>;
addAll(requestArray: Array<Request>): Promise<void>;
'delete'(request: Request, options?: CacheStorageOptions): Promise<boolean>;
keys(request?: Request, options?: CacheStorageOptions): Promise<Array<string>>;
match(request: Request, options?: CacheStorageOptions): Promise<Response|undefined>;
matchAll(request: Request, options?: CacheStorageOptions): Promise<Array<Response>>;
put(request: Request|string, response: Response): Promise<void>;
}
interface CacheStorage {
'delete'(cacheName: string): Promise<boolean>;
has(cacheName: string): Promise<boolean>;
keys(): Promise<Array<string>>;
match(request: Request, options?: CacheStorageOptions): Promise<Response|undefined>;
open(cacheName: string): Promise<Cache>;
}
interface CacheStorageOptions {
cacheName?: string;
ignoreMethod?: boolean;
ignoreSearch?: boolean;
ignoreVary?: boolean;
}
// Client API
declare class Client {
@ -145,4 +118,4 @@ interface ServiceWorkerGlobalScope {
fetch(request: Request|string): Promise<Response>;
skipWaiting(): Promise<void>;
}
}