Skip to content

Commit

Permalink
fix: Updated typings for ServiceMethods (#1409)
Browse files Browse the repository at this point in the history
  • Loading branch information
deskoh authored and daffl committed Jul 3, 2019
1 parent 44542e9 commit b5ee7e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/authentication/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Params, ServiceMethods } from '@feathersjs/feathers';

const debug = Debug('@feathersjs/authentication/service');

export class AuthenticationService extends AuthenticationBase implements ServiceMethods<AuthenticationResult> {
export class AuthenticationService extends AuthenticationBase implements Partial<ServiceMethods<AuthenticationResult>> {
/**
* Return the payload for a JWT based on the authentication result.
* Called internally by the `create` method.
Expand Down
15 changes: 6 additions & 9 deletions packages/feathers/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,20 @@ declare namespace createApplication {
finally?: Partial<HookMap> | Hook | Hook[];
}

// todo: figure out what to do: These methods don't actually need to be
// implemented, so they can be undefined at runtime. Yet making them
// optional gets cumbersome in strict mode.
interface ServiceMethods<T> {
[key: string]: any;

find? (params?: Params): Promise<T | T[] | Paginated<T>>;
find (params?: Params): Promise<T | T[] | Paginated<T>>;

get? (id: Id, params?: Params): Promise<T>;
get (id: Id, params?: Params): Promise<T>;

create? (data: Partial<T> | Array<Partial<T>>, params?: Params): Promise<T | T[]>;
create (data: Partial<T> | Array<Partial<T>>, params?: Params): Promise<T | T[]>;

update? (id: NullableId, data: T, params?: Params): Promise<T>;
update (id: NullableId, data: T, params?: Params): Promise<T>;

patch? (id: NullableId, data: Partial<T>, params?: Params): Promise<T>;
patch (id: NullableId, data: Partial<T>, params?: Params): Promise<T>;

remove? (id: NullableId, params?: Params): Promise<T>;
remove (id: NullableId, params?: Params): Promise<T>;
}

interface SetupMethod {
Expand Down

0 comments on commit b5ee7e2

Please sign in to comment.