-
-
Notifications
You must be signed in to change notification settings - Fork 797
Closed
Description
Expected behavior
It would be nice if the return type was automatically inferred from adapter services based on params.paginate
let users: User[] = await app.service('users').find({ paginate: false })
let paginated: Paginated<User> = await app.service('users').find()Actual behavior
Instead, the type system does not know which return type to use, so we need to cast it.
let paginated = await app.service('users').find() as Paginated<User>Proposal
I think we can solve this with an overload. Something like:
interface ParamsNoPaginate extends Params { // not a great name, I know..
paginate: false
}
// service.d.ts
export declare class AdapterService<T = any> implements ServiceMethods<T> {
// ...
find(params: ParamsNoPaginate): Promise<T[]>
find(params?: Params): Promise<Paginate<T>>
// ...
}I'm less comfortable with conditional types, but I suppose that would work as well and it would avoid having to extend Params.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels