@@ -61,48 +61,40 @@ type BaseConfig = {
61
61
exportFromIndex ?: boolean ;
62
62
name : AnyPluginName ;
63
63
output ?: string ;
64
- }
65
-
66
- interface Meta < Config extends BaseConfig > {
67
- /**
68
- * Dependency plugins will be always processed, regardless of whether user
69
- * explicitly defines them in their `plugins` config.
70
- */
71
- _dependencies ?: ReadonlyArray < AnyPluginName > ;
72
- /**
73
- * Allows overriding config before it's sent to the parser. An example is
74
- * defining `validator` as `true` and the plugin figures out which plugin
75
- * should be used for validation.
76
- */
77
- _infer ?: (
78
- config : Config & Omit < Meta < Config > , '_infer' > ,
79
- context : PluginContext ,
80
- ) => void ;
81
- /**
82
- * Optional tags can be used to help with deciding plugin order and inferring
83
- * plugin configuration options.
84
- */
85
- _tags ?: ReadonlyArray < PluginTag > ;
86
- }
87
-
88
- export type DefaultPluginConfigs < T > = {
89
- [ K in PluginNames ] : BaseConfig &
90
- Meta < any > & {
91
- _handler : Plugin . Handler < Required < Extract < T , { name : K } > > > ;
92
- _handlerLegacy ?: Plugin . LegacyHandler < Required < Extract < T , { name : K } > > > ;
93
- } ;
94
64
} ;
95
65
96
66
/**
97
67
* Public Plugin API.
98
68
*/
99
69
export namespace Plugin {
100
- export type Config < Config extends BaseConfig > = Config &
101
- Meta < Config > & {
102
- _handler : Plugin . Handler < Config > ;
103
- _handlerLegacy ?: Plugin . LegacyHandler < Config > ;
104
- exportFromIndex ?: boolean ;
105
- } ;
70
+ export type Config < T extends Types > = Pick < T , 'api' > & {
71
+ config : Omit < T [ 'config' ] , 'name' | 'output' > ;
72
+ /**
73
+ * Dependency plugins will be always processed, regardless of whether user
74
+ * explicitly defines them in their `plugins` config.
75
+ */
76
+ dependencies ?: ReadonlyArray < AnyPluginName > ;
77
+ handler : Handler < T > ;
78
+ handlerLegacy ?: LegacyHandler < T > ;
79
+ name : T [ 'config' ] [ 'name' ] ;
80
+ output : NonNullable < T [ 'config' ] [ 'output' ] > ;
81
+ /**
82
+ * Resolves static configuration values into their runtime equivalents. For
83
+ * example, when `validator` is set to `true`, it figures out which plugin
84
+ * should be used for validation.
85
+ */
86
+ resolveConfig ?: (
87
+ plugin : Omit < Plugin . Config < T > , 'dependencies' > & {
88
+ dependencies : Set < AnyPluginName > ;
89
+ } ,
90
+ context : PluginContext ,
91
+ ) => void ;
92
+ /**
93
+ * Optional tags can be used to help with deciding plugin order and resolving
94
+ * plugin configuration options.
95
+ */
96
+ tags ?: ReadonlyArray < PluginTag > ;
97
+ } ;
106
98
107
99
export type ConfigWithName < T extends Types > = Omit < Config < T > , 'config' > & {
108
100
config : Omit < T [ 'config' ] , 'output' > ;
0 commit comments