Vue · Senior · Question 53 of 75

How do you type a global property like $t added with app.config.globalProperties?

declare module 'vue' {
  interface ComponentCustomProperties {
    $t: (key: string) => string
  }
}

Explanation

Global properties are mainly for templates and the Options API; in <script setup> prefer provide/inject or a composable.

Further reading

Problem with a question

Vue · Senior · question 53

Test yourself

Take the Vue · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz