Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/vue-i18n-core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,10 @@ export function getCurrentInstance():
| GenericComponentInstance
| ComponentInternalInstance
| null {
if ('currentInstance' in Vue) {
// NOTE(kazupon): avoid bundler static analysis
const name = 'current' + 'Instance'
return (Vue as any)[name] as GenericComponentInstance | null
// NOTE(kazupon): avoid bundler warning
const key = 'currentInstance'
Copy link

Copilot AI Dec 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new approach using const key = 'currentInstance' may not effectively avoid bundler static analysis warnings. Modern bundlers perform constant folding and can still detect this pattern. The previous string concatenation approach ('current' + 'Instance') was more effective at preventing static analysis because bundlers typically don't evaluate runtime string operations. Consider using a more robust approach such as computed property access or keeping the string concatenation method if the goal is to prevent bundler warnings.

Suggested change
const key = 'currentInstance'
const key = 'current' + 'Instance'

Copilot uses AI. Check for mistakes.
if (key in Vue) {
return (Vue as any)[key] as GenericComponentInstance | null
} else {
return Vue.getCurrentInstance()
}
Expand Down
Loading