diff --git a/CHANGELOG.md b/CHANGELOG.md index 533afa2cd2c..563ae5f126c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Expect active development and potentially significant breaking changes in the `0.x` track. We'll try to be diligent about releasing a `1.0` version in a timely fashion (ideally within 3 to 6 months), to signal the start of a more stable API. ### vNEXT +- Fix: Update TypeScript Middleware and Afterware interfaces to include a datatype for 'this' in apply function. [PR #1372](https://github.com/apollographql/apollo-client/pull/1372) ### 1.0.0-rc.2 - throw error if deprecated options are being used [PR #1396](https://github.com/apollographql/apollo-client/pull/1396) @@ -520,4 +521,4 @@ This release has a minor version bump, which means npm will not automatically up ### v0.1.0 -Initial release. We didn't track changes before this version. +Initial release. We didn't track changes before this version. \ No newline at end of file diff --git a/src/transport/afterware.ts b/src/transport/afterware.ts index f7480c4b8cf..9f327e1975b 100644 --- a/src/transport/afterware.ts +++ b/src/transport/afterware.ts @@ -1,10 +1,13 @@ +import { HTTPFetchNetworkInterface } from './networkInterface'; +import { HTTPBatchedNetworkInterface } from './batchedNetworkInterface'; + export interface AfterwareResponse { response: Response; options: RequestInit; } export interface AfterwareInterface { - applyAfterware(response: AfterwareResponse, next: Function): any; + applyAfterware(this: HTTPFetchNetworkInterface, response: AfterwareResponse, next: Function): any; } export interface BatchAfterwareResponse { @@ -13,5 +16,5 @@ export interface BatchAfterwareResponse { } export interface BatchAfterwareInterface { - applyBatchAfterware(response: BatchAfterwareResponse, next: Function): any; + applyBatchAfterware(this: HTTPBatchedNetworkInterface, response: BatchAfterwareResponse, next: Function): any; } diff --git a/src/transport/middleware.ts b/src/transport/middleware.ts index 2d80590f5da..27dfcb845bc 100644 --- a/src/transport/middleware.ts +++ b/src/transport/middleware.ts @@ -1,4 +1,6 @@ -import { Request } from './networkInterface'; +import { Request, HTTPFetchNetworkInterface } from './networkInterface'; +import { HTTPBatchedNetworkInterface } from './batchedNetworkInterface'; + export interface MiddlewareRequest { request: Request; @@ -6,7 +8,7 @@ export interface MiddlewareRequest { } export interface MiddlewareInterface { - applyMiddleware(request: MiddlewareRequest, next: Function): void; + applyMiddleware(this: HTTPFetchNetworkInterface, request: MiddlewareRequest, next: Function): void; } export interface BatchMiddlewareRequest { @@ -15,5 +17,5 @@ export interface BatchMiddlewareRequest { } export interface BatchMiddlewareInterface { - applyBatchMiddleware(request: BatchMiddlewareRequest, next: Function): void; + applyBatchMiddleware(this: HTTPBatchedNetworkInterface, request: BatchMiddlewareRequest, next: Function): void; }