Types for the pagination
properties.
#1856
PopGoesTheWza
started this conversation in
General
Replies: 1 comment 5 replies
-
Unfortunately you have to either force cast it or use guards like |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Typically I create a
got
client with the following (simplified) pattern:First issue I have is that there is no exported type definition to the
pagination
properties. Hence thepaginate
andtransform
functions cannot be typed just by their own.We can workaround that by defining some custom types in order to extract those missing types:
Those types now allow us to write typed pagination functions like:
And since the
Transform
,Filter
,Paginate
andShouldContinue
types support generics, we can use finer typing such as:Except that we now have the second issue and conflicting types where we define
pagination: {paginate, transform}
! That is because the typeExtendOptions
extendsOptions
, which extendsPromiseOnly.Options
, which extendsPaginationOptions<unknown, unknown>
Annoying, though not critical at this point, I felt like sharing this with the comunity.
Beta Was this translation helpful? Give feedback.
All reactions