Skip to content

Commit

Permalink
fix: TS errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Jun 19, 2023
1 parent 4156d84 commit e9958fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
Plugin,
PluginMap,
PluginType,
RemoveFalsy,
Unplugin,
UnpluginCombineInstance,
} from './types'
Expand All @@ -22,9 +23,9 @@ function flatPlugins(plugins: OptionsPlugin): (Plugin | Unplugin<any>)[] {
export function resolvePlugins<T extends PluginType>(
plugins: OptionsPlugin,
type: T
): Array<PluginMap[T]> {
): Array<RemoveFalsy<PluginMap[T]>> {
return flatPlugins(plugins)
.filter(Boolean)
.filter((p): p is RemoveFalsy<Plugin | Unplugin<any>> => !!p)
.map((plugin) => {
if ('instance' in plugin) {
const { instance, options } = plugin as Unplugin<any>
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface PluginMap {
}
export type PluginType = keyof PluginMap
export type Plugin = PluginMap[PluginType]
export type RemoveFalsy<T> = Exclude<T, false | '' | 0 | null | undefined>

export type Factory<UserOptions> = (
userOptions: UserOptions,
Expand Down

0 comments on commit e9958fb

Please sign in to comment.