Skip to content

Commit 7f56082

Browse files
authored
fix: __INTLIFY_META__ access error in vue-i18n-bridge (#696)
closes #692
1 parent e20e75d commit 7f56082

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

packages/vue-i18n-core/src/composer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import {
5151
SetPluralRulesSymbol,
5252
LegacyInstanceSymbol
5353
} from './symbols'
54-
import { deepCopy, getLocaleMessages } from './utils'
54+
import { deepCopy, getLocaleMessages, getComponentOptions } from './utils'
5555
import { VERSION } from './misc'
5656

5757
import type { ComponentInternalInstance, VNode, VNodeArrayChildren } from 'vue'
@@ -1713,8 +1713,9 @@ function defineCoreMissingHandler(missing: MissingHandler): CoreMissingHandler {
17131713
// for Intlify DevTools
17141714
const getMetaInfo = /* #__PURE__*/ (): MetaInfo | null => {
17151715
const instance = getCurrentInstance()
1716-
return instance && (instance.type as any)[DEVTOOLS_META] // eslint-disable-line @typescript-eslint/no-explicit-any
1717-
? { [DEVTOOLS_META]: (instance.type as any)[DEVTOOLS_META] } // eslint-disable-line @typescript-eslint/no-explicit-any
1716+
let meta: any = null // eslint-disable-line @typescript-eslint/no-explicit-any
1717+
return instance && (meta = getComponentOptions(instance)[DEVTOOLS_META])
1718+
? { [DEVTOOLS_META]: meta } // eslint-disable-line @typescript-eslint/no-explicit-any
17181719
: null
17191720
}
17201721

packages/vue-i18n-core/src/i18n.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ import { apply } from './plugin'
2525
import { defineMixin as defineMixinNext } from './mixins/next'
2626
import { defineMixin as defineMixinBridge } from './mixins/bridge'
2727
import { enableDevTools, addTimelineEvent } from './devtools'
28-
import { isLegacyVueI18n, getLocaleMessages } from './utils'
28+
import {
29+
isLegacyVueI18n,
30+
getLocaleMessages,
31+
getComponentOptions
32+
} from './utils'
2933

3034
import type { ComponentInternalInstance, App } from 'vue'
3135
import type {
@@ -794,11 +798,6 @@ function getI18nInstance(instance: ComponentInternalInstance): I18n {
794798
}
795799
}
796800

797-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
798-
function getComponentOptions(instance: ComponentInternalInstance): any {
799-
return !__BRIDGE__ ? instance.type : instance.proxy!.$options
800-
}
801-
802801
// eslint-disable-next-line @typescript-eslint/no-explicit-any
803802
function getScope(options: UseI18nOptions, componentOptions: any): I18nScope {
804803
// prettier-ignore

packages/vue-i18n-core/src/utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { I18nErrorCodes, createI18nError } from './errors'
44

55
import type { Locale, MessageResolver } from '@intlify/core-base'
66
import type { CustomBlocks, VueMessageType } from './composer'
7+
import type { ComponentInternalInstance } from 'vue'
78

89
type GetLocaleMessagesOptions<Messages = {}> = {
910
messages?: { [K in keyof Messages]: Messages[K] }
@@ -127,4 +128,9 @@ export function deepCopy(src: any, des: any): void {
127128
}
128129
}
129130

131+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
132+
export function getComponentOptions(instance: ComponentInternalInstance): any {
133+
return !__BRIDGE__ ? instance.type : instance.proxy!.$options
134+
}
135+
130136
/* eslint-enable @typescript-eslint/no-explicit-any */

0 commit comments

Comments
 (0)