Skip to content

Switch Request and Response generics #1130

Closed
@delvedor

Description

@delvedor

In #1119 we introduced a big change in how the type definitions work, and I'm very happy with the result, the code is more idiomatic and it's easier to use the TypeScript features.
While working on #970, I've noticed that there is still something we can do to improve even further the developer experience.
By reading this issue tracker and around on the internet, people is more interested in the response types rather than the request types, which in most of the cases are good enough with the body set to Record<string, any>.
Currently, the generics allow you to specify the request body, the response body and the context in this order:

client.search<RequestBody, ResponseBody, Context>(...)

I'm wondering if it does make more sense to have the ResponseBody generic as the first parameter instead since it will be used more often for defining Source objects and so on. While my OCD screams when seeing about this, I think it makes way more sense given that people will use the Response types more often.

client.search<ResponseBody, RequestBody, Context>(...)

What do you think?

cc @Mpdreamz @joshdover @restrry @nreese @dgieselaar @fox1t @villasv

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions