From 7768385be2b2cb4fa39ed4f093e97583057fc198 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 5 Jan 2024 15:25:26 +0900 Subject: [PATCH] refactor(frontend): reduce type errors --- packages/frontend/src/components/MkPasswordDialog.vue | 4 +++- packages/frontend/src/components/MkPoll.vue | 3 ++- packages/frontend/src/components/MkPostForm.vue | 8 +++++--- packages/frontend/src/components/MkRippleEffect.vue | 9 ++++++++- packages/frontend/src/components/MkTooltip.vue | 8 +++++--- packages/frontend/src/type.ts | 3 +++ 6 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 packages/frontend/src/type.ts diff --git a/packages/frontend/src/components/MkPasswordDialog.vue b/packages/frontend/src/components/MkPasswordDialog.vue index c77e912199..7180e5e2ca 100644 --- a/packages/frontend/src/components/MkPasswordDialog.vue +++ b/packages/frontend/src/components/MkPasswordDialog.vue @@ -41,7 +41,9 @@ import MkInput from '@/components/MkInput.vue'; import MkButton from '@/components/MkButton.vue'; import MkModalWindow from '@/components/MkModalWindow.vue'; import { i18n } from '@/i18n.js'; -import { $i } from '@/account.js'; +import { signinRequired } from '@/account.js'; + +const $i = signinRequired(); const emit = defineEmits<{ (ev: 'done', v: { password: string; token: string | null; }): void; diff --git a/packages/frontend/src/components/MkPoll.vue b/packages/frontend/src/components/MkPoll.vue index a318799ade..4cac1fe9c3 100644 --- a/packages/frontend/src/components/MkPoll.vue +++ b/packages/frontend/src/components/MkPoll.vue @@ -35,9 +35,10 @@ import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js'; import { i18n } from '@/i18n.js'; import { useInterval } from '@/scripts/use-interval.js'; +import { WithNonNullable } from '@/type.js'; const props = defineProps<{ - note: Misskey.entities.Note; + note: WithNonNullable; readOnly?: boolean; }>(); diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue index 8c6fba6637..1e073a7de9 100644 --- a/packages/frontend/src/components/MkPostForm.vue +++ b/packages/frontend/src/components/MkPostForm.vue @@ -121,7 +121,7 @@ import { defaultStore, notePostInterruptors, postFormActions } from '@/store.js' import MkInfo from '@/components/MkInfo.vue'; import { i18n } from '@/i18n.js'; import { instance } from '@/instance.js'; -import { $i, notesCount, incNotesCount, getAccounts, openAccountMenu as openAccountMenu_ } from '@/account.js'; +import { signinRequired, notesCount, incNotesCount, getAccounts, openAccountMenu as openAccountMenu_ } from '@/account.js'; import { uploadFile } from '@/scripts/upload.js'; import { deepClone } from '@/scripts/clone.js'; import MkRippleEffect from '@/components/MkRippleEffect.vue'; @@ -130,6 +130,8 @@ import { claimAchievement } from '@/scripts/achievements.js'; import { emojiPicker } from '@/scripts/emoji-picker.js'; import { mfmFunctionPicker } from '@/scripts/mfm-function-picker.js'; +const $i = signinRequired(); + const modal = inject('modal'); const props = withDefaults(defineProps<{ @@ -308,7 +310,7 @@ if (props.reply && props.reply.text != null) { } } -if ($i?.isSilenced && visibility.value === 'public') { +if ($i.isSilenced && visibility.value === 'public') { visibility.value = 'home'; } @@ -461,7 +463,7 @@ function setVisibility() { os.popup(defineAsyncComponent(() => import('@/components/MkVisibilityPicker.vue')), { currentVisibility: visibility.value, - isSilenced: $i?.isSilenced, + isSilenced: $i.isSilenced, localOnly: localOnly.value, src: visibilityButton.value, }, { diff --git a/packages/frontend/src/components/MkRippleEffect.vue b/packages/frontend/src/components/MkRippleEffect.vue index 860b083327..11f1aec30f 100644 --- a/packages/frontend/src/components/MkRippleEffect.vue +++ b/packages/frontend/src/components/MkRippleEffect.vue @@ -77,7 +77,14 @@ const emit = defineEmits<{ (ev: 'end'): void; }>(); -const particles = []; +const particles: { + size: number; + xA: number; + yA: number; + xB: number; + yB: number; + color: string; +}[] = []; const origin = 64; const colors = ['#FF1493', '#00FFFF', '#FFE202']; const zIndex = os.claimZIndex('high'); diff --git a/packages/frontend/src/components/MkTooltip.vue b/packages/frontend/src/components/MkTooltip.vue index ea22175e03..d40cd95f3a 100644 --- a/packages/frontend/src/components/MkTooltip.vue +++ b/packages/frontend/src/components/MkTooltip.vue @@ -13,8 +13,10 @@ SPDX-License-Identifier: AGPL-3.0-only >
- - {{ text }} +
@@ -31,7 +33,7 @@ const props = withDefaults(defineProps<{ targetElement?: HTMLElement; x?: number; y?: number; - text: string; + text?: string; asMfm?: boolean; maxWidth?: number; direction?: 'top' | 'bottom' | 'right' | 'left'; diff --git a/packages/frontend/src/type.ts b/packages/frontend/src/type.ts new file mode 100644 index 0000000000..9c0fc2a11e --- /dev/null +++ b/packages/frontend/src/type.ts @@ -0,0 +1,3 @@ +export type WithRequired = T & { [P in K]-?: T[P] }; + +export type WithNonNullable = T & { [P in K]-?: NonNullable };