File tree Expand file tree Collapse file tree 5 files changed +54
-15
lines changed Expand file tree Collapse file tree 5 files changed +54
-15
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @vintl/vintl ' : minor
3+ ---
4+
5+ Added Vue types augmentation to type the global mixin properties
6+
7+ Mixin-provided global properties like ` $t ` , ` $fmt ` and ` $i18n ` should be properly typed now.
8+
9+ If you don't use the global mixin, the below augmentation will remove these unusable properties.
10+
11+ ``` ts
12+ declare global {
13+ namespace VueIntlController {
14+ interface Options {
15+ globalMixin: false
16+ }
17+ }
18+ }
19+ ```
Original file line number Diff line number Diff line change @@ -374,6 +374,14 @@ You can declare your messages by creating an ambient declaration file where you
374374
375375 A map of locale resources provided by the load event listeners.
376376
377+ - ` interface ` ` Options `
378+
379+ A map of options affecting type augmentation.
380+
381+ Currently supported options:
382+
383+ - ` globalMixin ` (` boolean ` , default ` true ` ) - whether to augment Vue types to type mixin-provided global properties.
384+
377385<details >
378386<summary >Example</summary >
379387
@@ -394,6 +402,10 @@ import type { ExampleObject } from '~/utils/convertibleObject.ts'
394402
395403declare global {
396404 namespace VueIntlController {
405+ interface Options {
406+ globalMixin: false // Remove types for mixin-provided properties.
407+ }
408+
397409 interface MessageValueTypes {
398410 // key doesn't matter as long as it does not collide with other key;
399411 // the interface used here solely for extensibility since you cannot
Original file line number Diff line number Diff line change 1+ import './vue-augment.js'
12export * from './messages.js'
23export * from './locales.js'
34export * from './sources.js'
Original file line number Diff line number Diff line change 1+ import type { InjectedProperties } from '../plugin.js'
2+ import type { MessageValueType } from './messages.js'
3+
4+ declare global {
5+ namespace VueIntlController {
6+ interface Options { }
7+ }
8+ }
9+
10+ type ConditionalExtensions = VueIntlController . Options extends {
11+ globalMixin : infer GlobalMixin
12+ }
13+ ? [ GlobalMixin ] extends [ true ]
14+ ? InjectedProperties < MessageValueType >
15+ : { }
16+ : InjectedProperties < MessageValueType >
17+
18+ declare module 'vue' {
19+ export interface ComponentCustomProperties extends ConditionalExtensions { }
20+ }
21+
22+ export { }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments