Skip to content

Commit

Permalink
fix: types: pathParams can be initially undef
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dbushong committed Oct 23, 2019
1 parent b4caf80 commit 2d53eb1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/typedefs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2d53eb1

Please sign in to comment.