From ab61661da8030366bb775657da4b3de88c332715 Mon Sep 17 00:00:00 2001 From: Evan Kennedy Date: Fri, 26 Apr 2019 16:08:02 -0700 Subject: [PATCH] Add hook normalization & finally hook (#34897) --- .../feathersjs__feathers/feathersjs__feathers-tests.ts | 10 ++++++++++ types/feathersjs__feathers/index.d.ts | 7 ++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/types/feathersjs__feathers/feathersjs__feathers-tests.ts b/types/feathersjs__feathers/feathersjs__feathers-tests.ts index bf1cdf8aa7..1fa02a79fb 100644 --- a/types/feathersjs__feathers/feathersjs__feathers-tests.ts +++ b/types/feathersjs__feathers/feathersjs__feathers-tests.ts @@ -21,5 +21,15 @@ app.service('users').hooks({ context.statusCode = 200; context.dispatch = { test: 'true' }; } + }, + after: [ + (context: HookContext) => { + context.statusCode = 200; + context.dispatch = { test: 'true' }; + } + ], + finally: (context: HookContext) => { + context.statusCode = 200; + context.dispatch = { test: 'true' }; } }); diff --git a/types/feathersjs__feathers/index.d.ts b/types/feathersjs__feathers/index.d.ts index e5ffc8abf7..f4fb85aad2 100644 --- a/types/feathersjs__feathers/index.d.ts +++ b/types/feathersjs__feathers/index.d.ts @@ -137,9 +137,10 @@ declare namespace feathers { } interface HooksObject { - before: Partial; - after: Partial; - error: Partial; + before: Partial | Hook | Hook[]; + after: Partial | Hook | Hook[]; + error: Partial | Hook | Hook[]; + 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.