From 3da35d21070cfedec6ff0f5eb9e6fc7373fd4d37 Mon Sep 17 00:00:00 2001 From: Boopathi Rajaa Date: Tue, 18 Jun 2019 14:24:27 +0200 Subject: [PATCH] fix: types for outgoing http headers --- lib/request.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/request.ts b/lib/request.ts index 464d6c7..bd018ec 100644 --- a/lib/request.ts +++ b/lib/request.ts @@ -12,12 +12,25 @@ const getInterval = (time: [number, number]): number => { return Math.round(diff[0] * 1000 + diff[1] / 1000000); }; +/** + * The NodeJS typescript definitions has OutgoingHttpHeaders + * with `undefined` as one of the possible values, but NodeJS + * runtime will throw an error for undefined values in headers. + * + * This overwrites the headers type in the RequestOptions + * and removes undefined from one of the possible values of headers. + */ +export interface OutgoingHttpHeaders { + [header: string]: number | string | string[]; +} + export interface ServiceClientRequestOptions extends RequestOptions { pathname: string; query?: object; timing?: boolean; dropRequestAfter?: number; body?: any; + headers?: OutgoingHttpHeaders; } export class ServiceClientResponse {