donavon/thwack

ThwackResponse should consume data type

Closed this issue ยท 8 comments

With AxiosResponse I am able to specify the type of the data object. Same could be done for ThwackResponse if this was a generic instead of any https://github.com/donavon/thwack/blob/master/types/index.d.ts#L46

I'm hardly a TypeScript expert (um, like not at all). I wrote this index.d.ts by hand, so there may well be mistakes.

PRs are welcome if you have an idea on how to do this. ๐Ÿ˜€

It's as easy as

interface ThwackResponse<T> {
  data: T;
}

Like this?

export interface ThwackResponse<T> {
  status: number;
  statusText: string;
  headers: KeyValue;
  data: T;
  response: Response;
  options: ThwackOptions;
}

Same for headers I think.

If you're open to contributors - I can take a swing at this one ๐Ÿ˜„

@blakeyoder that would be great! I just merged a 0.2.0-beta.3 candidate into master so go ahead.

Hey @donavon! I'm ready to push a remote branch up. I currently don't have the correct permissions to push to this remote. Do you mind granting me the appropriate permissions? Happy to go about another path - i.e. forking the repo, but I couldn't find contributing guides.

I'll have to add some, thx for the reminder. Please fork and make a PR.