From f4eb90bd1e95c24eb9e29f9b8b4977640b2ab7a9 Mon Sep 17 00:00:00 2001 From: deskoh Date: Thu, 23 May 2019 14:11:06 +0800 Subject: [PATCH 01/10] Typings fix and improvements. --- packages/feathers/index.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/feathers/index.d.ts b/packages/feathers/index.d.ts index 869620320b..c28050d62f 100644 --- a/packages/feathers/index.d.ts +++ b/packages/feathers/index.d.ts @@ -52,7 +52,7 @@ declare namespace createApplication { * A read only property that contains the Feathers application object. This can be used to * retrieve other services (via context.app.service('name')) or configuration values. */ - readonly app: Application; + readonly app: Application; /** * A writeable property containing the data of a create, update and patch service * method call. @@ -156,7 +156,7 @@ declare namespace createApplication { } interface SetupMethod { - setup (app: Application, path: string): void; + setup (app: Application, path: string): void; } interface ServiceOverloads { @@ -177,7 +177,7 @@ declare namespace createApplication { type ServiceMixin = (service: Service, path: string) => void; - interface Application extends EventEmitter { + interface Application extends EventEmitter { version: string; services: ServiceTypes; @@ -204,10 +204,10 @@ declare namespace createApplication { setup (server?: any): this; - service (location: L): ServiceTypes[L]; + service (location: L): Service; - service (location: string): Service; + service (location: string): ServiceTypes extends never ? Service : never; - use (path: string, service: Partial & SetupMethod> | Application, options?: any): this; + use (path: string, service: Partial & SetupMethod> | Application, options?: any): this; } } From 28f0a4481fdfcfdb6e791bc8476ed3e61e51cfdd Mon Sep 17 00:00:00 2001 From: deskoh Date: Thu, 23 May 2019 15:43:22 +0800 Subject: [PATCH 02/10] Typo fix. --- packages/feathers/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/feathers/index.d.ts b/packages/feathers/index.d.ts index c28050d62f..5991897319 100644 --- a/packages/feathers/index.d.ts +++ b/packages/feathers/index.d.ts @@ -52,7 +52,7 @@ declare namespace createApplication { * A read only property that contains the Feathers application object. This can be used to * retrieve other services (via context.app.service('name')) or configuration values. */ - readonly app: Application; + readonly app: Application; /** * A writeable property containing the data of a create, update and patch service * method call. From e4b77e9b3c1e82a05d841e1cbbd45ba8da6d3adb Mon Sep 17 00:00:00 2001 From: deskoh Date: Thu, 23 May 2019 16:55:11 +0800 Subject: [PATCH 03/10] Improved typings. --- packages/feathers/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/feathers/index.d.ts b/packages/feathers/index.d.ts index 5991897319..2c1f4ca556 100644 --- a/packages/feathers/index.d.ts +++ b/packages/feathers/index.d.ts @@ -52,7 +52,7 @@ declare namespace createApplication { * A read only property that contains the Feathers application object. This can be used to * retrieve other services (via context.app.service('name')) or configuration values. */ - readonly app: Application; + readonly app: Application; /** * A writeable property containing the data of a create, update and patch service * method call. @@ -156,7 +156,7 @@ declare namespace createApplication { } interface SetupMethod { - setup (app: Application, path: string): void; + setup (app: Application, path: string): void; } interface ServiceOverloads { @@ -206,8 +206,8 @@ declare namespace createApplication { service (location: L): Service; - service (location: string): ServiceTypes extends never ? Service : never; + service (location: string): [ServiceTypes] extends [never] ? Service : never; - use (path: string, service: Partial & SetupMethod> | Application, options?: any): this; + use (path: string, service: Partial & SetupMethod> | Application, options?: any): this; } } From 7e2f34d58334b07f896ccf7704e5f4fc5d52ae2a Mon Sep 17 00:00:00 2001 From: deskoh Date: Thu, 23 May 2019 23:09:54 +0800 Subject: [PATCH 04/10] Fixed tests. --- packages/feathers/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/feathers/index.d.ts b/packages/feathers/index.d.ts index 2c1f4ca556..b96616bbad 100644 --- a/packages/feathers/index.d.ts +++ b/packages/feathers/index.d.ts @@ -177,7 +177,7 @@ declare namespace createApplication { type ServiceMixin = (service: Service, path: string) => void; - interface Application extends EventEmitter { + interface Application extends EventEmitter { version: string; services: ServiceTypes; @@ -206,7 +206,7 @@ declare namespace createApplication { service (location: L): Service; - service (location: string): [ServiceTypes] extends [never] ? Service : never; + service(location: string): keyof ServiceTypes extends never ? Service : never; use (path: string, service: Partial & SetupMethod> | Application, options?: any): this; } From a1ec1355f1601295cac21fffc1ceb6b37484af33 Mon Sep 17 00:00:00 2001 From: deskoh Date: Sun, 26 May 2019 16:33:14 +0800 Subject: [PATCH 05/10] Fixed tests by generalizing ServiceTypes --- packages/feathers/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/feathers/index.d.ts b/packages/feathers/index.d.ts index b96616bbad..6f09e03308 100644 --- a/packages/feathers/index.d.ts +++ b/packages/feathers/index.d.ts @@ -204,9 +204,9 @@ declare namespace createApplication { setup (server?: any): this; - service (location: L): Service; + service (location: L): ServiceTypes[L]; - service(location: string): keyof ServiceTypes extends never ? Service : never; + service(location: string): keyof ServiceTypes extends never ? any : never; use (path: string, service: Partial & SetupMethod> | Application, options?: any): this; } From 06d59de9b4f23a80263f4760800b7ff3177c15dd Mon Sep 17 00:00:00 2001 From: deskoh Date: Sun, 26 May 2019 16:45:22 +0800 Subject: [PATCH 06/10] Updated types for declaration merging. --- packages/authentication-client/src/index.ts | 2 +- packages/primus/index.d.ts | 2 +- packages/socketio/index.d.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/authentication-client/src/index.ts b/packages/authentication-client/src/index.ts index ecf0f0f1b2..f6650418da 100644 --- a/packages/authentication-client/src/index.ts +++ b/packages/authentication-client/src/index.ts @@ -5,7 +5,7 @@ import { AuthenticationResult, AuthenticationRequest } from '@feathersjs/authent import { Storage, MemoryStorage, StorageWrapper } from './storage'; declare module '@feathersjs/feathers' { - interface Application { + interface Application { io?: any; rest?: any; primus?: any; diff --git a/packages/primus/index.d.ts b/packages/primus/index.d.ts index 3815db09d3..7de7c63bb0 100644 --- a/packages/primus/index.d.ts +++ b/packages/primus/index.d.ts @@ -14,7 +14,7 @@ interface FeathersPrimus { } declare module '@feathersjs/feathers' { - interface Application { + interface Application { listen (port: number): http.Server; } } diff --git a/packages/socketio/index.d.ts b/packages/socketio/index.d.ts index 68e0b6302e..a1f2ad5be5 100644 --- a/packages/socketio/index.d.ts +++ b/packages/socketio/index.d.ts @@ -13,7 +13,7 @@ interface FeathersSocketIO { } declare module '@feathersjs/feathers' { - interface Application { + interface Application { listen (port: number): http.Server; } } From fe42940e1810ff6657e17a508d2d530c01514b92 Mon Sep 17 00:00:00 2001 From: deskoh Date: Sun, 26 May 2019 16:58:11 +0800 Subject: [PATCH 07/10] Updated tests. --- packages/authentication/test/jwt.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/authentication/test/jwt.test.ts b/packages/authentication/test/jwt.test.ts index 569f0b920d..e10c361aa5 100644 --- a/packages/authentication/test/jwt.test.ts +++ b/packages/authentication/test/jwt.test.ts @@ -14,7 +14,8 @@ const { authenticate } = hooks; describe('authentication/jwt', () => { let app: Application<{ authentication: AuthenticationService & Service, - users: Service + users: Service, + protected: Service, }>; let user: any; let accessToken: string; From d6c20c8e8dcd81755686923146013f5f22e8131e Mon Sep 17 00:00:00 2001 From: deskoh Date: Sun, 26 May 2019 17:14:01 +0800 Subject: [PATCH 08/10] Updated Application.services --- packages/authentication/test/jwt.test.ts | 2 +- packages/feathers/index.d.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/authentication/test/jwt.test.ts b/packages/authentication/test/jwt.test.ts index e10c361aa5..dc0f1bae1f 100644 --- a/packages/authentication/test/jwt.test.ts +++ b/packages/authentication/test/jwt.test.ts @@ -15,7 +15,7 @@ describe('authentication/jwt', () => { let app: Application<{ authentication: AuthenticationService & Service, users: Service, - protected: Service, + protected: Service }>; let user: any; let accessToken: string; diff --git a/packages/feathers/index.d.ts b/packages/feathers/index.d.ts index 6f09e03308..630301d7f7 100644 --- a/packages/feathers/index.d.ts +++ b/packages/feathers/index.d.ts @@ -180,7 +180,7 @@ declare namespace createApplication { interface Application extends EventEmitter { version: string; - services: ServiceTypes; + services: keyof ServiceTypes extends never ? any : ServiceTypes; mixins: ServiceMixin[]; @@ -206,7 +206,7 @@ declare namespace createApplication { service (location: L): ServiceTypes[L]; - service(location: string): keyof ServiceTypes extends never ? any : never; + service (location: string): keyof ServiceTypes extends never ? any : never; use (path: string, service: Partial & SetupMethod> | Application, options?: any): this; } From 482a199ce89e997d0a7aeed40673729bd0e603a8 Mon Sep 17 00:00:00 2001 From: deskoh Date: Wed, 19 Jun 2019 22:56:12 +0800 Subject: [PATCH 09/10] Updated typings for ServiceMethods --- packages/feathers/index.d.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/feathers/index.d.ts b/packages/feathers/index.d.ts index 676b94521d..d01d8f81c8 100644 --- a/packages/feathers/index.d.ts +++ b/packages/feathers/index.d.ts @@ -137,23 +137,20 @@ declare namespace createApplication { finally?: Partial | 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 { [key: string]: any; - find? (params?: Params): Promise>; + find (params?: Params): Promise>; - get? (id: Id, params?: Params): Promise; + get (id: Id, params?: Params): Promise; - create? (data: Partial | Array>, params?: Params): Promise; + create (data: Partial | Array>, params?: Params): Promise; - update? (id: NullableId, data: T, params?: Params): Promise; + update (id: NullableId, data: T, params?: Params): Promise; - patch? (id: NullableId, data: Partial, params?: Params): Promise; + patch (id: NullableId, data: Partial, params?: Params): Promise; - remove? (id: NullableId, params?: Params): Promise; + remove (id: NullableId, params?: Params): Promise; } interface SetupMethod { From daa5cc272c9037e9b5903aa546b8b3cbd78eb195 Mon Sep 17 00:00:00 2001 From: deskoh Date: Fri, 28 Jun 2019 08:40:53 +0800 Subject: [PATCH 10/10] Fix broken build --- packages/authentication/src/service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/authentication/src/service.ts b/packages/authentication/src/service.ts index 4ea00c0ea4..e5bbefcbe6 100644 --- a/packages/authentication/src/service.ts +++ b/packages/authentication/src/service.ts @@ -7,7 +7,7 @@ import { Params, ServiceMethods } from '@feathersjs/feathers'; const debug = Debug('@feathersjs/authentication/service'); -export class AuthenticationService extends AuthenticationBase implements ServiceMethods { +export class AuthenticationService extends AuthenticationBase implements Partial> { /** * Return the payload for a JWT based on the authentication result. * Called internally by the `create` method.