feathersjs / feathers

The API and real-time application framework
https://feathersjs.com
MIT License
15.03k stars 748 forks source link

`params.paginate.default` override produces Typescript errors #3129

Open speigg opened 1 year ago

speigg commented 1 year ago

Steps to reproduce

app.service(path).find({
  paginate: {
    default: 1000, // ts error here
    max: 1000
  }
})

Expected behavior

I'd expect to be able to pass the necessary paginate options without facing typescript errors. It's not clear to me why only the max option would be allowed, since pagination requires default to be set in order to return paginated results.

This behavior is expected because of the documentation at https://feathersjs.com/api/databases/common.html#pagination, which indicates that params.paginate can be overriden as shown above.

Actual behavior

I get the following typescript error:

Type '{ default: number; max: number; }' is not assignable to type 'false | Pick<PaginationOptions, "max"> | undefined'.
  Object literal may only specify known properties, and 'default' does not exist in type 'Pick<PaginationOptions, "max">'.ts(2322)

System configuration

Tell us about the applicable parts of your setup.

Module versions (especially the part that's not working): Feathers Dove (5.0.1) typescript@4.9.5

Hareis commented 1 year ago

i have't the error image