Skip to content

Commit

Permalink
fix: provide types for custom providers, close #21
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed May 6, 2024
1 parent 40eb415 commit 6799d41
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions src/providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,16 @@ export function guessProviders(config: SponsorkitConfig) {
}

export function resolveProviders(names: (ProviderName | Provider)[]) {
return Array.from(new Set(names)).map((i) => {
if (typeof i === 'string') {
const provider = ProvidersMap[i]
if (!provider)
throw new Error(`Unknown provider: ${i}`)
return provider
}
return i
})
return Array.from(new Set(names))
.map((i) => {
if (typeof i === 'string') {
const provider = ProvidersMap[i]
if (!provider)
throw new Error(`Unknown provider: ${i}`)
return provider
}
return i
})
}

export async function fetchSponsors(config: SponsorkitConfig) {
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export interface SponsorkitConfig extends ProvidersConfig, SponsorkitRenderOptio
/**
* @default auto detect based on the config provided
*/
providers?: ProviderName[]
providers?: (ProviderName | Provider)[]

/**
* By pass cache
Expand Down

0 comments on commit 6799d41

Please sign in to comment.