Skip to content

Improve PluginSpecificConfiguration intellisense adding Refs generic #4526

@lgraziani2712

Description

@lgraziani2712

Runtime

NodeJS

Runtime version

22.7.0

Module version

21.3.10

Used with

hapi application

Any other relevant information

No response

What problem are you trying to solve?

I'm trying to write a plugin that accepts a function that receives the request as a param and it could be nice to have the generic from the route shared to plugins, something like the following:

// plugin.d.ts
interface PluginSpecificConfiguration<Refs extends ReqRef = ReqRefDefaults> {}

// routes.d.ts
interface CommonRouteProperties<Refs extends ReqRef = ReqRefDefaults> {
    plugins?: PluginSpecificConfiguration<Refs> | undefined;
}

With that, we could configure plugins like this

declare module '@hapi/hapi {
  interface PluginSpecificConfiguration<Refs extends ReqRef = ReqRefDefaults> {
    pluginName: PluginInterface<Refs>;
  }
}

I'm interested in writting a PR if y'all accept the idea :)

Do you have a new or modified API suggestion to solve the problem?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew functionality or improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions