fetch-wrap icon indicating copy to clipboard operation
fetch-wrap copied to clipboard

Add TypeScript support

Open pke opened this issue 3 years ago • 0 comments

I wonder how one could make this a little bit more type-safe by having the middleware actually know the types of the arguments and the supposed return value (Promose<Response>).

I have started with this:

// This should be exported by "fetch-wrap" as a type
type FetchFunction = typeof fetch

export function logHeaders() {
  return function(url: string, options:RequestInit = {}, fetch: FetchFunction):Promise<Response> {
  }
}

pke avatar Mar 06 '21 11:03 pke