Last active
November 16, 2020 08:05
-
-
Save lil5/989a165f916ef155425ac24f8849a030 to your computer and use it in GitHub Desktop.
Force vue-i18n to function $t to return string
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
import VueI18n, { | |
Path, Values, Locale, | |
} from 'vue-i18n/types' | |
/** | |
* Overloads VueI18n interface to avoid needing to cast return value to string. | |
* @see https://github.com/kazupon/vue-i18n/issues/410 | |
*/ | |
declare module 'vue-i18n/types' { | |
export default class VueI18n { | |
t(key: Path, locale: Locale, values?: Values): string; | |
t(key: Path, values?: Values): string; | |
} | |
} | |
declare module 'vue/types/vue' { | |
interface Vue { | |
$t: typeof VueI18n.prototype.t; | |
} | |
interface VueConstructor<V extends Vue = Vue> { | |
i18n: typeof VueI18n.prototype; | |
} | |
} | |
export default VueI18n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment