@@ -34,7 +34,9 @@ import {
3434 setAdditionalMeta ,
3535 getFallbackContext ,
3636 setFallbackContext ,
37- DEFAULT_LOCALE
37+ DEFAULT_LOCALE ,
38+ isMessageAST ,
39+ isMessageFunction
3840} from '@intlify/core-base'
3941import { VueDevToolsTimelineEvents } from '@intlify/vue-devtools'
4042import { I18nWarnCodes , getWarnMessage } from './warnings'
@@ -108,7 +110,8 @@ import type {
108110 RemoveIndexSignature ,
109111 RemovedIndexResources ,
110112 IsNever ,
111- IsEmptyObject
113+ IsEmptyObject ,
114+ CoreMissingType
112115} from '@intlify/core-base'
113116import type { VueDevToolsEmitter } from '@intlify/vue-devtools'
114117import { isLegacyVueI18n } from './utils'
@@ -1757,7 +1760,9 @@ export interface ComposerInternal {
17571760 __setPluralRules ( rules : PluralizationRules ) : void
17581761}
17591762
1760- type ComposerWarnType = 'translate' | 'number format' | 'datetime format'
1763+ type ComposerWarnType = CoreMissingType
1764+
1765+ const NOOP_RETURN_ARRAY = ( ) => [ ]
17611766
17621767let composerID = 0
17631768
@@ -2309,7 +2314,7 @@ export function createComposer(options: any = {}, VueI18nLegacy?: any): any {
23092314 'number format' ,
23102315 // eslint-disable-next-line @typescript-eslint/no-explicit-any
23112316 root => ( root as any ) [ NumberPartsSymbol ] ( ...args ) ,
2312- ( ) => [ ] ,
2317+ NOOP_RETURN_ARRAY ,
23132318 val => isString ( val ) || isArray ( val )
23142319 )
23152320 }
@@ -2324,7 +2329,7 @@ export function createComposer(options: any = {}, VueI18nLegacy?: any): any {
23242329 'datetime format' ,
23252330 // eslint-disable-next-line @typescript-eslint/no-explicit-any
23262331 root => ( root as any ) [ DatetimePartsSymbol ] ( ...args ) ,
2327- ( ) => [ ] ,
2332+ NOOP_RETURN_ARRAY ,
23282333 val => isString ( val ) || isArray ( val )
23292334 )
23302335 }
@@ -2336,10 +2341,17 @@ export function createComposer(options: any = {}, VueI18nLegacy?: any): any {
23362341
23372342 // te
23382343 function te ( key : Path , locale ?: Locale ) : boolean {
2339- if ( ! key ) return false
2344+ if ( ! key ) {
2345+ return false
2346+ }
23402347 const targetLocale = isString ( locale ) ? locale : _locale . value
23412348 const message = getLocaleMessage ( targetLocale )
2342- return isString ( _context . messageResolver ( message , key ) )
2349+ const resolved = _context . messageResolver ( message , key )
2350+ return (
2351+ isMessageAST ( resolved ) ||
2352+ isMessageFunction ( resolved ) ||
2353+ isString ( resolved )
2354+ )
23432355 }
23442356
23452357 function resolveMessages ( key : Path ) : LocaleMessageValue < Message > | null {
0 commit comments