-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Vue augmentation to type global mixin properties
- Loading branch information
Showing
5 changed files
with
54 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
'@vintl/vintl': minor | ||
--- | ||
|
||
Added Vue types augmentation to type the global mixin properties | ||
|
||
Mixin-provided global properties like `$t`, `$fmt` and `$i18n` should be properly typed now. | ||
|
||
If you don't use the global mixin, the below augmentation will remove these unusable properties. | ||
|
||
```ts | ||
declare global { | ||
namespace VueIntlController { | ||
interface Options { | ||
globalMixin: false | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { InjectedProperties } from '../plugin.js' | ||
import type { MessageValueType } from './messages.js' | ||
|
||
declare global { | ||
namespace VueIntlController { | ||
interface Options {} | ||
} | ||
} | ||
|
||
type ConditionalExtensions = VueIntlController.Options extends { | ||
globalMixin: infer GlobalMixin | ||
} | ||
? [GlobalMixin] extends [true] | ||
? InjectedProperties<MessageValueType> | ||
: {} | ||
: InjectedProperties<MessageValueType> | ||
|
||
declare module 'vue' { | ||
export interface ComponentCustomProperties extends ConditionalExtensions {} | ||
} | ||
|
||
export {} |
This file was deleted.
Oops, something went wrong.