File tree Expand file tree Collapse file tree 3 files changed +12
-19
lines changed Expand file tree Collapse file tree 3 files changed +12
-19
lines changed Original file line number Diff line number Diff line change @@ -122,10 +122,7 @@ const getPluginsConfig = ({
122
122
if ( plugin . _infer ) {
123
123
const context : PluginContext = {
124
124
ensureDependency : ( dependency ) => {
125
- if (
126
- typeof dependency === 'string' &&
127
- ! plugin . _dependencies . includes ( dependency )
128
- ) {
125
+ if ( ! plugin . _dependencies . includes ( dependency ) ) {
129
126
plugin . _dependencies = [ ...plugin . _dependencies , dependency ] ;
130
127
}
131
128
} ,
@@ -139,7 +136,7 @@ const getPluginsConfig = ({
139
136
defaultConfig . _tags ?. includes ( tag ) &&
140
137
userPlugin !== name
141
138
) {
142
- return userPlugin ;
139
+ return userPlugin as any ;
143
140
}
144
141
}
145
142
Original file line number Diff line number Diff line change @@ -14,30 +14,26 @@ export const defaultConfig: Plugin.Config<Config> = {
14
14
plugin . config . client = context . pluginByTag ( {
15
15
defaultPlugin : '@hey-api/client-fetch' ,
16
16
tag : 'client' ,
17
- } ) as unknown as typeof plugin . config . client ;
17
+ } ) ;
18
18
}
19
19
20
- context . ensureDependency ( plugin . config . client ) ;
20
+ context . ensureDependency ( plugin . config . client ! ) ;
21
21
}
22
22
23
23
if ( plugin . config . transformer ) {
24
24
if ( typeof plugin . config . transformer === 'boolean' ) {
25
- plugin . config . transformer = context . pluginByTag ( {
26
- tag : 'transformer' ,
27
- } ) as unknown as typeof plugin . config . transformer ;
25
+ plugin . config . transformer = context . pluginByTag ( { tag : 'transformer' } ) ;
28
26
}
29
27
30
- context . ensureDependency ( plugin . config . transformer ) ;
28
+ context . ensureDependency ( plugin . config . transformer ! ) ;
31
29
}
32
30
33
31
if ( plugin . config . validator ) {
34
32
if ( typeof plugin . config . validator === 'boolean' ) {
35
- plugin . config . validator = context . pluginByTag ( {
36
- tag : 'validator' ,
37
- } ) as unknown as typeof plugin . config . validator ;
33
+ plugin . config . validator = context . pluginByTag ( { tag : 'validator' } ) ;
38
34
}
39
35
40
- context . ensureDependency ( plugin . config . validator ) ;
36
+ context . ensureDependency ( plugin . config . validator ! ) ;
41
37
}
42
38
43
39
if ( plugin . config . instance ) {
Original file line number Diff line number Diff line change @@ -40,12 +40,12 @@ export type AnyPluginName = PluginNames | (string & {});
40
40
type PluginTag = 'client' | 'transformer' | 'validator' ;
41
41
42
42
export interface PluginContext {
43
- ensureDependency : ( name : PluginNames | true ) => void ;
44
- pluginByTag : ( props : {
45
- defaultPlugin ?: AnyPluginName ;
43
+ ensureDependency : ( name : PluginNames ) => void ;
44
+ pluginByTag : < T extends AnyPluginName | boolean = AnyPluginName > ( props : {
45
+ defaultPlugin ?: Exclude < T , boolean > ;
46
46
errorMessage ?: string ;
47
47
tag : PluginTag ;
48
- } ) => AnyPluginName | undefined ;
48
+ } ) => Exclude < T , boolean > | undefined ;
49
49
}
50
50
51
51
export interface BaseConfig {
You can’t perform that action at this time.
0 commit comments