Skip to content

Commit

Permalink
fix: prevent completion for paths in i18n route utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbieGoede committed Sep 30, 2024
1 parent 385db97 commit 56c6f51
Showing 1 changed file with 29 additions and 43 deletions.
72 changes: 29 additions & 43 deletions src/runtime/composables/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ import { getLocale, getLocales, getComposer } from '../compatibility'
import type { Ref } from 'vue'
import type { Locale } from 'vue-i18n'
import type { I18nHeadMetaInfo, I18nHeadOptions, LocaleObject, SeoAttributesOptions } from '../shared-types'
import type {
RouteLocationAsPathI18n,
RouteLocationAsRelativeI18n,
RouteLocationResolvedI18n,
RouteMapI18n
} from 'vue-router'
import type { RouteLocationAsRelativeI18n, RouteLocationResolvedI18n, RouteMapI18n } from 'vue-router'
import type { HeadParam } from '../utils'

export * from 'vue-i18n'
Expand Down Expand Up @@ -200,15 +195,13 @@ export function useLocaleHead({
* @public
*/
export type RouteBaseNameFunction = <Name extends keyof RouteMapI18n = keyof RouteMapI18n>(
givenRoute:
| Name
/**
* Note: disabled route path string autocompletion, this can break depending on `strategy`
* this can be enabled again after route resolve has been improved.
*/
// | RouteLocationAsStringI18n
| RouteLocationAsRelativeI18n
| RouteLocationAsPathI18n,
route: Name | RouteLocationAsRelativeI18n,
/**
* Note: disabled route path string autocompletion, this can break depending on `strategy`
* this can be enabled again after route resolve has been improved.
*/
// | RouteLocationAsStringI18n
// | RouteLocationAsPathI18n
locale?: Locale
) => string

Expand Down Expand Up @@ -244,15 +237,13 @@ export function useRouteBaseName(): RouteBaseNameFunction {
*/

export type LocalePathFunction = <Name extends keyof RouteMapI18n = keyof RouteMapI18n>(
route:
| Name
/**
* Note: disabled route path string autocompletion, this can break depending on `strategy`
* this can be enabled again after route resolve has been improved.
*/
// | RouteLocationAsStringI18n
| RouteLocationAsRelativeI18n
| RouteLocationAsPathI18n,
route: Name | RouteLocationAsRelativeI18n,
/**
* Note: disabled route path string autocompletion, this can break depending on `strategy`
* this can be enabled again after route resolve has been improved.
*/
// | RouteLocationAsStringI18n
// | RouteLocationAsPathI18n
locale?: Locale
) => string

Expand Down Expand Up @@ -287,15 +278,13 @@ export function useLocalePath(): LocalePathFunction {
* @public
*/
export type LocaleRouteFunction = <Name extends keyof RouteMapI18n = keyof RouteMapI18n>(
route:
| Name
/**
* Note: disabled route path string autocompletion, this can break depending on `strategy`
* this can be enabled again after route resolve has been improved.
*/
// | RouteLocationAsStringI18n
| RouteLocationAsRelativeI18n
| RouteLocationAsPathI18n,
route: Name | RouteLocationAsRelativeI18n,
/**
* Note: disabled route path string autocompletion, this can break depending on `strategy`
* this can be enabled again after route resolve has been improved.
*/
// | RouteLocationAsStringI18n
// | RouteLocationAsPathI18n
locale?: Locale
) => RouteLocationResolvedI18n<Name> | undefined
/**
Expand Down Expand Up @@ -329,15 +318,13 @@ export function useLocaleRoute(): LocaleRouteFunction {
* @public
*/
export type LocaleLocationFunction = <Name extends keyof RouteMapI18n = keyof RouteMapI18n>(
route:
| Name
/**
* Note: disabled route path string autocompletion, this can break depending on `strategy`
* this can be enabled again after route resolve has been improved.
*/
// | RouteLocationAsStringI18n
| RouteLocationAsRelativeI18n
| RouteLocationAsPathI18n,
route: Name | RouteLocationAsRelativeI18n,
/**
* Note: disabled route path string autocompletion, this can break depending on `strategy`
* this can be enabled again after route resolve has been improved.
*/
// | RouteLocationAsStringI18n
// | RouteLocationAsPathI18n
locale?: Locale
) => RouteLocationResolvedI18n<Name> | undefined

Expand Down Expand Up @@ -401,7 +388,6 @@ export function useBrowserLocale(): string | null {
const headers = useRequestHeaders(['accept-language'])
return (
findBrowserLocale(
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
normalizedLocales as LocaleObject[],
import.meta.client ? (navigator.languages as string[]) : parseAcceptLanguage(headers['accept-language'] || '')
) || null
Expand Down

0 comments on commit 56c6f51

Please sign in to comment.