Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add overload types for find service methods #1972

Merged
merged 2 commits into from
Jun 25, 2020
Merged

feat: add overload types for find service methods #1972

merged 2 commits into from
Jun 25, 2020

Conversation

robbyphillips
Copy link
Contributor

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 on params.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:

  1. The main ServiceMethods<T> definition for find has the signature find (params?: Params): Promise<T | T[] | Paginated<T>>;, and the Promise<T> result is not included in the overloads

  2. I am not sure if changes similar to the one in the strategy.ts file would be needed in some ecosystem libs

@robbyphillips
Copy link
Contributor Author

Hey @daffl, just wondering if I should've done something different here. Totally get that something like this might be very low priority -- it just seems like a pretty straightforward "quality of life" improvement to me.

@daffl
Copy link
Member

daffl commented Jun 25, 2020

Sorry about that and thank you for the PR @robbyphillips. Been meaning to address this but I am also in the process of moving the adapters specific typings into https://github.com/feathersjs/databases and https://github.com/feathersjs/databases/tree/master/packages/adapter-commons

@daffl daffl merged commit a12a1cf into feathersjs:master Jun 25, 2020
@robbyphillips
Copy link
Contributor Author

No worries at all, just happy to contribute if it's helpful.

And thanks for pointing out where new work is happening. Is this part of a reorg with v5?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants