From 2d53eb1acf196c7472d2d08c3f7e9225046bf767 Mon Sep 17 00:00:00 2001 From: David Bushong Date: Wed, 23 Oct 2019 15:33:18 -0700 Subject: [PATCH] fix: types: pathParams can be initially undef one might wish to write a client like this: ```js class Foo extends Gofer { constructor(cfg) { super(cfg, 'foo'); } bar({ x, y }) { return this.get('/{x}/{y}', { endpointName: 'bar', pathParams: { x, y }, }); } } const foo = new Foo({ foo: { pathParams: { x: 'whee' } } }); await foo.bar({ y: 'yay' }); ``` with the current types, it will complain that you're passing an undefined value as a pathParam, but really that will be dealt with in the config merging later on, so we should accept it --- lib/typedefs.d.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/typedefs.d.ts b/lib/typedefs.d.ts index 9f47ed5..d4973a0 100644 --- a/lib/typedefs.d.ts +++ b/lib/typedefs.d.ts @@ -42,10 +42,13 @@ declare class Gofer { } declare namespace Gofer { - export function fetch(path: string, opts?: Gofer.FetchOpts): FetchResponse; + export function fetch( + path: string, + opts?: Gofer.FetchOpts & { pathParams?: { [param: string]: string } } + ): FetchResponse; export type Opts = { - pathParams?: { [param: string]: string }; + pathParams?: { [param: string]: string | undefined }; timeout?: number; connectTimeout?: number; searchDomain?: string;