hapijs / hapijs/hapi

Improve PluginSpecificConfiguration intellisense adding Refs generic

Open
#4,526 2 comments 0 reactions 0 assignees View on GitHub
feature
Dominant language
JavaScript
Stars
14.8k
Forks
1.4k
Avg merge
22d 3h
Merged PRs (30d)
1

Description

### 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:

```ts
// plugin.d.ts
interface PluginSpecificConfiguration {}

// routes.d.ts
interface CommonRouteProperties {
plugins?: PluginSpecificConfiguration | undefined;
}
```

With that, we could configure plugins like this

```ts
declare module '@hapi/hapi {
interface PluginSpecificConfiguration {
pluginName: PluginInterface;
}
}
```

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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.