From 091f2f42713c6da7da0ebad60fbaecc5bb95ef05 Mon Sep 17 00:00:00 2001 From: Stephan Schneider Date: Wed, 7 Mar 2018 15:23:58 +0100 Subject: [PATCH] fix: allow for synchronous Hapi plugin register fn --- types/hapi/index.d.ts | 2 +- types/hapi/test/server/server-plugins.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/types/hapi/index.d.ts b/types/hapi/index.d.ts index de1542f33f..8ad9b6f4c4 100644 --- a/types/hapi/index.d.ts +++ b/types/hapi/index.d.ts @@ -120,7 +120,7 @@ export interface PluginBase { * * server - the server object with a plugin-specific server.realm. * * options - any options passed to the plugin during registration via server.register(). */ - register: (server: Server, options: T) => Promise; + register: (server: Server, options: T) => void | Promise; /** (optional) if true, allows the plugin to be registered multiple times with the same server. Defaults to false. */ multiple?: boolean; diff --git a/types/hapi/test/server/server-plugins.ts b/types/hapi/test/server/server-plugins.ts index 7f3d194f84..8de3fdc24f 100644 --- a/types/hapi/test/server/server-plugins.ts +++ b/types/hapi/test/server/server-plugins.ts @@ -13,6 +13,10 @@ interface Plugin3 { three: 3; } +interface Plugin4 { + four: 4; +} + declare module 'hapi' { interface PluginProperties { example: { @@ -42,6 +46,11 @@ const plugin3: Plugin = { register: async (server: Server, options: Plugin3) => {} }; +const plugin4: Plugin = { + name: 'plugin4', + register: (server: Server, options: Plugin4) => {} +}; + const server = new Server({ port: 8000, }); @@ -90,5 +99,9 @@ server.register([ { plugin: plugin1, options: {one: 1} + }, + { + plugin: plugin4, + options: {four: 4} } ]);