From 411b08841829fa07e8d87c01947ca6ebdbc70b4a Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Mon, 19 Dec 2022 10:40:57 +0900 Subject: [PATCH] refactor: fix broken Vue component custom properties (#9351) --- packages/client/@types/vue.d.ts | 17 +++++++++++++---- packages/client/src/i18n.ts | 8 -------- packages/client/src/instance.ts | 7 ------- packages/client/src/store.ts | 7 ------- 4 files changed, 13 insertions(+), 26 deletions(-) diff --git a/packages/client/@types/vue.d.ts b/packages/client/@types/vue.d.ts index f6b66228f..9c9c34ccc 100644 --- a/packages/client/@types/vue.d.ts +++ b/packages/client/@types/vue.d.ts @@ -1,7 +1,16 @@ /// -declare module '*.vue' { - import type { DefineComponent } from 'vue'; - const component: DefineComponent<{}, {}, any>; - export default component; +import type { $i } from '@/account'; +import type { defaultStore } from '@/store'; +import type { instance } from '@/instance'; +import type { i18n } from '@/i18n'; + +declare module 'vue' { + interface ComponentCustomProperties { + $i: typeof $i; + $store: typeof defaultStore; + $instance: typeof instance; + $t: typeof i18n['t']; + $ts: typeof i18n['ts']; + } } diff --git a/packages/client/src/i18n.ts b/packages/client/src/i18n.ts index fbc10a0ba..31e066960 100644 --- a/packages/client/src/i18n.ts +++ b/packages/client/src/i18n.ts @@ -3,11 +3,3 @@ import { locale } from '@/config'; import { I18n } from '@/scripts/i18n'; export const i18n = markRaw(new I18n(locale)); - -// このファイルに書きたくないけどここに書かないと何故かVeturが認識しない -declare module '@vue/runtime-core' { - interface ComponentCustomProperties { - $t: typeof i18n['t']; - $ts: typeof i18n['locale']; - } -} diff --git a/packages/client/src/instance.ts b/packages/client/src/instance.ts index d24eb2419..4f591f4fc 100644 --- a/packages/client/src/instance.ts +++ b/packages/client/src/instance.ts @@ -43,10 +43,3 @@ export const emojiTags = computed(() => { } return Array.from(tags); }); - -// このファイルに書きたくないけどここに書かないと何故かVeturが認識しない -declare module '@vue/runtime-core' { - interface ComponentCustomProperties { - $instance: typeof instance; - } -} diff --git a/packages/client/src/store.ts b/packages/client/src/store.ts index 061e1913d..d1b6e08bc 100644 --- a/packages/client/src/store.ts +++ b/packages/client/src/store.ts @@ -381,10 +381,3 @@ export class ColdDeviceStorage { }; } } - -// このファイルに書きたくないけどここに書かないと何故かVeturが認識しない -declare module '@vue/runtime-core' { - interface ComponentCustomProperties { - $store: typeof defaultStore; - } -}