Skip to content

Commit

Permalink
fix(typescript): add overload types for find service methods (#1972)
Browse files Browse the repository at this point in the history
  • Loading branch information
robbyphillips authored and daffl committed Jul 11, 2020
1 parent 9e7c0e1 commit ef55af0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/authentication-oauth/src/strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ export class OAuthStrategy extends AuthenticationBaseStrategy {
...params,
query
});
const [ entity = null ] = result.data ? result.data : result;

const [ entity = null ] = Array.isArray(result) ? result : result.data

debug('findEntity returning', entity);

Expand Down
16 changes: 16 additions & 0 deletions packages/feathers/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,22 @@ declare namespace createApplication {
}

interface ServiceOverloads<T> {
/**
* Retrieve all resources from this service.
*
* @param params - Service call parameters {@link Params}
* @see {@link https://docs.feathersjs.com/api/services.html#find-params|Feathers API Documentation: .find(params)}
*/
find? (params: Params & { paginate: false}): Promise<T[]>

/**
* Retrieve all resources from this service.
*
* @param params - Service call parameters {@link Params}
* @see {@link https://docs.feathersjs.com/api/services.html#find-params|Feathers API Documentation: .find(params)}
*/
find? (params?: Params): Promise<Paginated<T>>

/**
* Create a new resource for this service.
*
Expand Down

0 comments on commit ef55af0

Please sign in to comment.