We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
By using server.register(pluginArray), typescript does not work. Registering the same plugins one by one, it works.
server.register(pluginArray)
import { Server, Plugin } from '@hapi/hapi'; interface TestPluginOptions { x: number; } interface TestPluginDecorations { plugins: { test: { add(a: number, b: number): number; }; } } const plugin1: Plugin<TestPluginOptions, TestPluginDecorations> = { name: 'test', version: '1.0.0', register: function (srv, options) { } }; const plugin2: Plugin<{}> = { name: 'tes2', version: '1.0.0', register: function (srvs, options) { } }; const plugin3: Plugin<void> = { name: 'tes2', version: '1.0.0', register: function (srvs, options) { } }; async function test() { const server = new Server(); // does not work await server.register([ { plugin: plugin1, options: { x: 1 } }, { plugin: plugin2, options: {} }, { plugin: plugin3, options: undefined }, ]); // works await server.register({ plugin: plugin1, options: { x: 1 } }); await server.register({ plugin: plugin2, options: {} }); await server.register({ plugin: plugin3, options: undefined }); } test()
Type '{ x: number; }' is not assignable to type 'void'.
Error:
Full stack
It should work with tsc index.ts
tsc index.ts
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Support plan
Context
What are you trying to achieve or the steps to reproduce?
By using
server.register(pluginArray)
, typescript does not work.Registering the same plugins one by one, it works.
What was the result you got?
Error:
Full stack
What result did you expect?
It should work with
tsc index.ts
The text was updated successfully, but these errors were encountered: