Skip to content

Commit

Permalink
fix(helper): improve types of useLocaleConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Jan 31, 2024
1 parent cc51ca7 commit 0fcc7f6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tools/helper/src/client/composables/useLocaleConfig.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { computed } from 'vue'
import type { ComputedRef } from 'vue'
import { useRouteLocale } from 'vuepress/client'
import type { LocaleConfig, LocaleData } from 'vuepress/shared'
import type { LocaleData } from 'vuepress/shared'

export type ExactLocaleConfig<T extends LocaleData> = Record<string, T>

/**
* Get current locale config
Expand All @@ -10,8 +12,8 @@ import type { LocaleConfig, LocaleData } from 'vuepress/shared'
* @returns current locale config
*/
export const useLocaleConfig = <T extends LocaleData>(
localesConfig: LocaleConfig<T>,
): ComputedRef<Partial<T>> => {
localesConfig: ExactLocaleConfig<T>,
): ComputedRef<T> => {
const routeLocale = useRouteLocale()

return computed(() => localesConfig[routeLocale.value] ?? {})
Expand Down

0 comments on commit 0fcc7f6

Please sign in to comment.