fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #2182 from hey-api/refactor/plugin-types

authored by

Lubos and committed by
GitHub
d20e3a99 a18dd003

+12 -19
+2 -5
packages/openapi-ts/src/initConfigs.ts
··· 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 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
+6 -10
packages/openapi-ts/src/plugins/@hey-api/sdk/config.ts
··· 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) {
+4 -4
packages/openapi-ts/src/plugins/types.d.ts
··· 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 {