feat: add overload types for find
service methods
#1972
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
I thought this might be a better way to have a conversation about #1970.
The goal is to let typescript automatically infer the return type for
find
methods based onparams.paginate
.I do not think it is dependent on any other PRs.
Other Information
Adding these type definitions did have one unexpected side effect where TS no longer approved of line 106 in
packages/authentication-oauth/src/strategy.ts
, but it was such a little change that I included it in this PR.I can think of two things that I would really like some feeback on:
The main
ServiceMethods<T>
definition forfind
has the signaturefind (params?: Params): Promise<T | T[] | Paginated<T>>;
, and thePromise<T>
result is not included in the overloadsI am not sure if changes similar to the one in the
strategy.ts
file would be needed in some ecosystem libs