diff options
| author | zyoshoka <107108195+zyoshoka@users.noreply.github.com> | 2023-12-26 14:19:35 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-26 14:19:35 +0900 |
| commit | 75034d9240c069baff5a24409ea172374261ea3b (patch) | |
| tree | 2b701b310befef3cdd6a69e78b75f66d48809826 /packages/frontend/src/components | |
| parent | (dev) Issue Templateに、自分で実装してPRを出したいかの意思... (diff) | |
| download | misskey-75034d9240c069baff5a24409ea172374261ea3b.tar.gz misskey-75034d9240c069baff5a24409ea172374261ea3b.tar.bz2 misskey-75034d9240c069baff5a24409ea172374261ea3b.zip | |
refactor(frontend): Reactivityで型を明示するように (#12791)
* refactor(frontend): Reactivityで型を明示するように
* fix: プロパティの参照が誤っているのを修正
* fix: 初期化の値を空配列に書き換えていた部分をnullに置き換え
Diffstat (limited to 'packages/frontend/src/components')
17 files changed, 32 insertions, 32 deletions
diff --git a/packages/frontend/src/components/MkAchievements.vue b/packages/frontend/src/components/MkAchievements.vue index b067e94a6d..d49eeb0329 100644 --- a/packages/frontend/src/components/MkAchievements.vue +++ b/packages/frontend/src/components/MkAchievements.vue @@ -67,7 +67,7 @@ const props = withDefaults(defineProps<{ withDescription: true, }); -const achievements = ref(); +const achievements = ref<Misskey.entities.UsersAchievementsResponse | null>(null); const lockedAchievements = computed(() => ACHIEVEMENT_TYPES.filter(x => !(achievements.value ?? []).some(a => a.name === x))); function fetch() { diff --git a/packages/frontend/src/components/MkCaptcha.vue b/packages/frontend/src/components/MkCaptcha.vue index 14e59acad2..40bca11e64 100644 --- a/packages/frontend/src/components/MkCaptcha.vue +++ b/packages/frontend/src/components/MkCaptcha.vue @@ -26,7 +26,7 @@ export type Captcha = { getResponse(id: string): string; }; -type CaptchaProvider = 'hcaptcha' | 'recaptcha' | 'turnstile'; +export type CaptchaProvider = 'hcaptcha' | 'recaptcha' | 'turnstile'; type CaptchaContainer = { readonly [_ in CaptchaProvider]?: Captcha; diff --git a/packages/frontend/src/components/MkLink.vue b/packages/frontend/src/components/MkLink.vue index 8517eff40b..1bd0c8e5c9 100644 --- a/packages/frontend/src/components/MkLink.vue +++ b/packages/frontend/src/components/MkLink.vue @@ -29,7 +29,7 @@ const self = props.url.startsWith(local); const attr = self ? 'to' : 'href'; const target = self ? null : '_blank'; -const el = ref(); +const el = ref<HTMLElement>(); useTooltip(el, (showing) => { os.popup(defineAsyncComponent(() => import('@/components/MkUrlPreviewPopup.vue')), { diff --git a/packages/frontend/src/components/MkMarquee.vue b/packages/frontend/src/components/MkMarquee.vue index f9d0573227..145b60c8e7 100644 --- a/packages/frontend/src/components/MkMarquee.vue +++ b/packages/frontend/src/components/MkMarquee.vue @@ -27,7 +27,7 @@ export default { }, }, setup(props) { - const contentEl = ref(); + const contentEl = ref<HTMLElement>(); function calc() { const eachLength = contentEl.value.offsetWidth / props.repeat; diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index 66a5be22c3..7d4207f0fb 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -250,7 +250,7 @@ const collapsed = ref(appearNote.value.cw == null && isLong); const isDeleted = ref(false); const muted = ref(checkMute(appearNote.value, $i?.mutedWords)); const hardMuted = ref(props.withHardMute && checkMute(appearNote.value, $i?.hardMutedWords)); -const translation = ref<any>(null); +const translation = ref<Misskey.entities.NotesTranslateResponse | null>(null); const translating = ref(false); const showTicker = (defaultStore.state.instanceTicker === 'always') || (defaultStore.state.instanceTicker === 'remote' && appearNote.value.user.instance); const canRenote = computed(() => ['public', 'home'].includes(appearNote.value.visibility) || (appearNote.value.visibility === 'followers' && appearNote.value.userId === $i.id)); diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue index e88d33ed61..33a6786d03 100644 --- a/packages/frontend/src/components/MkNoteDetailed.vue +++ b/packages/frontend/src/components/MkNoteDetailed.vue @@ -273,7 +273,7 @@ const isMyRenote = $i && ($i.id === note.value.userId); const showContent = ref(false); const isDeleted = ref(false); const muted = ref($i ? checkWordMute(appearNote.value, $i, $i.mutedWords) : false); -const translation = ref(null); +const translation = ref<Misskey.entities.NotesTranslateResponse | null>(null); const translating = ref(false); const parsed = appearNote.value.text ? mfm.parse(appearNote.value.text) : null; const urls = parsed ? extractUrlFromMfm(parsed) : null; @@ -299,7 +299,7 @@ provide('react', (reaction: string) => { }); const tab = ref('replies'); -const reactionTabType = ref(null); +const reactionTabType = ref<string | null>(null); const renotesPagination = computed(() => ({ endpoint: 'notes/renotes', diff --git a/packages/frontend/src/components/MkPasswordDialog.vue b/packages/frontend/src/components/MkPasswordDialog.vue index 118f9a6a91..c77e912199 100644 --- a/packages/frontend/src/components/MkPasswordDialog.vue +++ b/packages/frontend/src/components/MkPasswordDialog.vue @@ -52,7 +52,7 @@ const emit = defineEmits<{ const dialog = shallowRef<InstanceType<typeof MkModalWindow>>(); const passwordInput = shallowRef<InstanceType<typeof MkInput>>(); const password = ref(''); -const token = ref(null); +const token = ref<string | null>(null); function onClose() { emit('cancelled'); diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue index f800d16524..5e7ca5539e 100644 --- a/packages/frontend/src/components/MkPostForm.vue +++ b/packages/frontend/src/components/MkPostForm.vue @@ -185,14 +185,14 @@ watch(showPreview, () => defaultStore.set('showPreview', showPreview.value)); const cw = ref<string | null>(props.initialCw ?? null); const localOnly = ref<boolean>(props.initialLocalOnly ?? defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly); const visibility = ref(props.initialVisibility ?? (defaultStore.state.rememberNoteVisibility ? defaultStore.state.visibility : defaultStore.state.defaultNoteVisibility) as typeof Misskey.noteVisibilities[number]); -const visibleUsers = ref([]); +const visibleUsers = ref<Misskey.entities.UserDetailed[]>([]); if (props.initialVisibleUsers) { props.initialVisibleUsers.forEach(pushVisibleUser); } const reactionAcceptance = ref(defaultStore.state.reactionAcceptance); const autocomplete = ref(null); const draghover = ref(false); -const quoteId = ref(null); +const quoteId = ref<string | null>(null); const hasNotSpecifiedMentions = ref(false); const recentHashtags = ref(JSON.parse(miLocalStorage.getItem('hashtags') ?? '[]')); const imeText = ref(''); diff --git a/packages/frontend/src/components/MkRolePreview.vue b/packages/frontend/src/components/MkRolePreview.vue index 3e4586cee4..4b6b0940ba 100644 --- a/packages/frontend/src/components/MkRolePreview.vue +++ b/packages/frontend/src/components/MkRolePreview.vue @@ -28,10 +28,11 @@ SPDX-License-Identifier: AGPL-3.0-only <script lang="ts" setup> import { } from 'vue'; +import * as Misskey from 'misskey-js'; import { i18n } from '@/i18n.js'; const props = withDefaults(defineProps<{ - role: any; + role: Misskey.entities.Role; forModeration: boolean; detailed: boolean; }>(), { diff --git a/packages/frontend/src/components/MkSelect.vue b/packages/frontend/src/components/MkSelect.vue index 5a1c788005..33b8a9a86d 100644 --- a/packages/frontend/src/components/MkSelect.vue +++ b/packages/frontend/src/components/MkSelect.vue @@ -65,10 +65,10 @@ const opening = ref(false); const changed = ref(false); const invalid = ref(false); const filled = computed(() => v.value !== '' && v.value != null); -const inputEl = ref(null); -const prefixEl = ref(null); -const suffixEl = ref(null); -const container = ref(null); +const inputEl = ref<HTMLObjectElement | null>(null); +const prefixEl = ref<HTMLElement | null>(null); +const suffixEl = ref<HTMLElement | null>(null); +const container = ref<HTMLElement | null>(null); const height = props.small ? 33 : props.large ? 39 : diff --git a/packages/frontend/src/components/MkSignin.vue b/packages/frontend/src/components/MkSignin.vue index 6051db1cad..2fc2c9ec5e 100644 --- a/packages/frontend/src/components/MkSignin.vue +++ b/packages/frontend/src/components/MkSignin.vue @@ -71,8 +71,6 @@ const host = ref(toUnicode(configHost)); const totpLogin = ref(false); const queryingKey = ref(false); const credentialRequest = ref<CredentialRequestOptions | null>(null); -const hCaptchaResponse = ref(null); -const reCaptchaResponse = ref(null); const emit = defineEmits<{ (ev: 'login', v: any): void; @@ -126,8 +124,6 @@ async function queryKey(): Promise<void> { username: username.value, password: password.value, credential: credential.toJSON(), - 'hcaptcha-response': hCaptchaResponse.value, - 'g-recaptcha-response': reCaptchaResponse.value, }); }).then(res => { emit('login', res); @@ -149,8 +145,6 @@ function onSubmit(): void { os.api('signin', { username: username.value, password: password.value, - 'hcaptcha-response': hCaptchaResponse.value, - 'g-recaptcha-response': reCaptchaResponse.value, }).then(res => { totpLogin.value = true; signing.value = false; @@ -168,8 +162,6 @@ function onSubmit(): void { os.api('signin', { username: username.value, password: password.value, - 'hcaptcha-response': hCaptchaResponse.value, - 'g-recaptcha-response': reCaptchaResponse.value, token: user.value?.twoFactorEnabled ? token.value : undefined, }).then(res => { emit('login', res); diff --git a/packages/frontend/src/components/MkSignupDialog.form.vue b/packages/frontend/src/components/MkSignupDialog.form.vue index f171e449c8..44cfb6f0fa 100644 --- a/packages/frontend/src/components/MkSignupDialog.form.vue +++ b/packages/frontend/src/components/MkSignupDialog.form.vue @@ -115,9 +115,9 @@ const emailState = ref<null | 'wait' | 'ok' | 'unavailable:used' | 'unavailable: const passwordStrength = ref<'' | 'low' | 'medium' | 'high'>(''); const passwordRetypeState = ref<null | 'match' | 'not-match'>(null); const submitting = ref<boolean>(false); -const hCaptchaResponse = ref(null); -const reCaptchaResponse = ref(null); -const turnstileResponse = ref(null); +const hCaptchaResponse = ref<string | null>(null); +const reCaptchaResponse = ref<string | null>(null); +const turnstileResponse = ref<string | null>(null); const usernameAbortController = ref<null | AbortController>(null); const emailAbortController = ref<null | AbortController>(null); diff --git a/packages/frontend/src/components/MkSparkle.vue b/packages/frontend/src/components/MkSparkle.vue index a7cd1692bf..269825e25e 100644 --- a/packages/frontend/src/components/MkSparkle.vue +++ b/packages/frontend/src/components/MkSparkle.vue @@ -72,7 +72,14 @@ SPDX-License-Identifier: AGPL-3.0-only <script lang="ts" setup> import { onMounted, onUnmounted, ref, shallowRef } from 'vue'; -const particles = ref([]); +const particles = ref<{ + id: string, + x: number, + y: number, + size: number, + dur: number, + color: string +}[]>([]); const el = shallowRef<HTMLElement>(); const width = ref(0); const height = ref(0); diff --git a/packages/frontend/src/components/MkUserAnnouncementEditDialog.vue b/packages/frontend/src/components/MkUserAnnouncementEditDialog.vue index b9fd084409..b5489d8e59 100644 --- a/packages/frontend/src/components/MkUserAnnouncementEditDialog.vue +++ b/packages/frontend/src/components/MkUserAnnouncementEditDialog.vue @@ -66,7 +66,7 @@ const props = defineProps<{ announcement?: any, }>(); -const dialog = ref(null); +const dialog = ref<InstanceType<typeof MkModalWindow> | null>(null); const title = ref<string>(props.announcement ? props.announcement.title : ''); const text = ref<string>(props.announcement ? props.announcement.text : ''); const icon = ref<string>(props.announcement ? props.announcement.icon : 'info'); diff --git a/packages/frontend/src/components/MkWidgets.vue b/packages/frontend/src/components/MkWidgets.vue index dc7c8bd06b..ee4e29dd8f 100644 --- a/packages/frontend/src/components/MkWidgets.vue +++ b/packages/frontend/src/components/MkWidgets.vue @@ -77,7 +77,7 @@ const widgetRefs = {}; const configWidget = (id: string) => { widgetRefs[id].configure(); }; -const widgetAdderSelected = ref(null); +const widgetAdderSelected = ref<string | null>(null); const addWidget = () => { if (widgetAdderSelected.value == null) return; diff --git a/packages/frontend/src/components/form/suspense.vue b/packages/frontend/src/components/form/suspense.vue index bfddac7523..eaf5ae4744 100644 --- a/packages/frontend/src/components/form/suspense.vue +++ b/packages/frontend/src/components/form/suspense.vue @@ -30,7 +30,7 @@ const props = defineProps<{ const pending = ref(true); const resolved = ref(false); const rejected = ref(false); -const result = ref(null); +const result = ref<any>(null); const process = () => { if (props.p == null) { diff --git a/packages/frontend/src/components/page/page.note.vue b/packages/frontend/src/components/page/page.note.vue index 5ca707dbc2..d885ebb1d6 100644 --- a/packages/frontend/src/components/page/page.note.vue +++ b/packages/frontend/src/components/page/page.note.vue @@ -11,7 +11,7 @@ SPDX-License-Identifier: AGPL-3.0-only </template> <script lang="ts" setup> -import { onMounted, Ref, ref } from 'vue'; +import { onMounted, ref } from 'vue'; import * as Misskey from 'misskey-js'; import { NoteBlock } from './block.type.js'; import MkNote from '@/components/MkNote.vue'; @@ -23,7 +23,7 @@ const props = defineProps<{ page: Misskey.entities.Page, }>(); -const note: Ref<Misskey.entities.Note | null> = ref(null); +const note = ref<Misskey.entities.Note | null>(null); onMounted(() => { os.api('notes/show', { noteId: props.block.note }) |