Skip to content

Commit 0f1f3bd

Browse files
authored
fix: 🐛 less ambigious plugin types (#4540)
1 parent 45c7255 commit 0f1f3bd

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/types/plugin.d.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ export interface PluginBase<T, D> {
107107
___$type_of_plugin_decorations$___?: D;
108108
}
109109

110+
/**
111+
* A plugin that is registered by name and version.
112+
*/
113+
export interface NamedPlugin<T, D = void> extends PluginBase<T, D>, PluginNameVersion {}
114+
115+
/**
116+
* A plugin that is registered by its package.json file.
117+
*/
118+
export interface PackagedPlugin<T, D = void> extends PluginBase<T, D>, PluginPackage {}
119+
120+
110121
/**
111122
* Plugins provide a way to organize application code by splitting the server logic into smaller components. Each
112123
* plugin can manipulate the server through the standard server interface, but with the added ability to sandbox
@@ -116,7 +127,7 @@ export interface PluginBase<T, D> {
116127
*
117128
* The type T is the type of the plugin options.
118129
*/
119-
export type Plugin<T, D = void> = PluginBase<T, D> & (PluginNameVersion | PluginPackage);
130+
export type Plugin<T, D = void> = NamedPlugin<T, D> | PackagedPlugin<T, D>;
120131

121132
/**
122133
* The realm object contains sandboxed server settings specific to each plugin or authentication strategy. When registering a plugin or an authentication scheme, a server object reference is provided

0 commit comments

Comments
 (0)