From 3acbe7461b84cf874d5ca87ba0b7e8b13756406c Mon Sep 17 00:00:00 2001 From: Arseny Smoogly Date: Sun, 21 Apr 2024 20:12:02 +0200 Subject: [PATCH] fix: specify a more precise type for DuffelError headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Client creates DuffelError with headers directly passed from `fetch`. Even though headers satisfy `Record`, that type isn't usable in practice for consumers of the library, e.g. when checking rate limit headers, — `Headers` is more precise. --- src/Client.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Client.ts b/src/Client.ts index 63e2cd04..0fa74d72 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -1,4 +1,4 @@ -import fetch from 'node-fetch' +import fetch, { Headers } from 'node-fetch' import { URL, URLSearchParams } from 'url' import { DuffelResponse, @@ -18,7 +18,7 @@ export interface Config { export class DuffelError extends Error { public meta: ApiResponseMeta public errors: ApiResponseError[] - public headers: Record + public headers: Headers constructor({ meta, @@ -27,7 +27,7 @@ export class DuffelError extends Error { }: { meta: ApiResponseMeta errors: ApiResponseError[] - headers: Record + headers: Headers }) { super() this.meta = meta