diff options
| author | zyoshoka <107108195+zyoshoka@users.noreply.github.com> | 2023-12-26 14:19:35 +0900 |
|---|---|---|
| committer | Marie <marie@kaifa.ch> | 2023-12-28 09:45:15 +0100 |
| commit | 8daff4a998e9b8371f59de7af8909dd8dfc39a9e (patch) | |
| tree | a94a38d41563f0c7fe34021f976b5c5ec2585140 /packages/frontend/src/components | |
| parent | (dev) Issue Templateに、自分で実装してPRを出したいかの意思... (diff) | |
| download | sharkey-8daff4a998e9b8371f59de7af8909dd8dfc39a9e.tar.gz sharkey-8daff4a998e9b8371f59de7af8909dd8dfc39a9e.tar.bz2 sharkey-8daff4a998e9b8371f59de7af8909dd8dfc39a9e.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 40f9ad4057..cdd9cb87b1 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 e16307c762..bda683002d 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 cdd2cccb2e..8a3b4cef48 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -289,7 +289,7 @@ const isDeleted = ref(false); const renoted = 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 a793a85ff9..e287890e2c 100644 --- a/packages/frontend/src/components/MkNoteDetailed.vue +++ b/packages/frontend/src/components/MkNoteDetailed.vue @@ -309,7 +309,7 @@ const showContent = ref(defaultStore.state.uncollapseCW); const isDeleted = ref(false); const renoted = 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).filter(u => u !== renoteUrl && u !== renoteUri) : null; @@ -353,7 +353,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 711c54c7f1..85dd402730 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 b26ce2932a..8838da15a9 100644 --- a/packages/frontend/src/components/MkPostForm.vue +++ b/packages/frontend/src/components/MkPostForm.vue @@ -187,14 +187,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 0e8ce35609..bd1767155b 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 d8c8c4998b..665ae2b813 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 08830fca7a..c884ce53ea 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 3c5dd0ce29..9984b09c1a 100644 --- a/packages/frontend/src/components/MkSignupDialog.form.vue +++ b/packages/frontend/src/components/MkSignupDialog.form.vue @@ -121,9 +121,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 e1237659c2..3fbadbe34f 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 a5d5ff733f..bc1f33c43e 100644 --- a/packages/frontend/src/components/MkWidgets.vue +++ b/packages/frontend/src/components/MkWidgets.vue @@ -84,7 +84,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 af5daa10ff..933f00b081 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 }) |