From ce38b63cfa43cebd3be095ea1b86f4deb2ab9520 Mon Sep 17 00:00:00 2001 From: Martijn Walraven Date: Mon, 16 Jul 2018 17:15:36 -0700 Subject: [PATCH] Fix CachePolicy typing --- packages/apollo-datasource-rest/src/HTTPCache.ts | 4 ++-- .../src/types/http-cache-semantics/index.d.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/apollo-datasource-rest/src/HTTPCache.ts b/packages/apollo-datasource-rest/src/HTTPCache.ts index 360ca73d5bb..f3bf86e782c 100644 --- a/packages/apollo-datasource-rest/src/HTTPCache.ts +++ b/packages/apollo-datasource-rest/src/HTTPCache.ts @@ -41,7 +41,7 @@ export class HTTPCache { const policy = CachePolicy.fromObject(policyRaw); // Remove url from the policy, because otherwise it would never match a request with a custom cache key - (policy as any)._url = undefined; + policy._url = undefined; if (policy.satisfiesWithoutRevalidation(policyRequestFrom(request))) { const headers = policy.responseHeaders(); @@ -96,7 +96,7 @@ export class HTTPCache { let ttl = cacheOptions && cacheOptions.ttl; if (ttl) { - (policy as any)._rescc['max-age'] = ttl; + policy._rescc['max-age'] = ttl; } if (!policy.storable()) return response; diff --git a/packages/apollo-datasource-rest/src/types/http-cache-semantics/index.d.ts b/packages/apollo-datasource-rest/src/types/http-cache-semantics/index.d.ts index a6815ca4474..38883b5eb9f 100644 --- a/packages/apollo-datasource-rest/src/types/http-cache-semantics/index.d.ts +++ b/packages/apollo-datasource-rest/src/types/http-cache-semantics/index.d.ts @@ -31,8 +31,9 @@ declare module 'http-cache-semantics' { static fromObject(object: object): CachePolicy; toObject(): object; - _url: string; + _url: string | undefined; _status: number; + _rescc: { [key: string]: any }; } export = CachePolicy;