From acdb94de62719998e1a24e1d7c8e57000447c95c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Fri, 6 Jan 2023 00:48:20 +0800 Subject: [PATCH] fix: type errors (#802) --- components/account/AccountMoved.vue | 7 +++-- components/command/CommandPanel.vue | 18 +++++++++-- components/common/CommonBlurhash.vue | 14 ++++----- components/common/CommonCropImage.vue | 2 +- components/common/CommonInputImage.vue | 2 +- components/modal/ModalContainer.vue | 3 +- .../notification/NotificationPaginator.vue | 10 +++++-- components/publish/PublishWidget.vue | 2 +- components/search/SearchResult.vue | 14 +++++---- components/search/SearchWidget.vue | 30 ++++++++++++++++--- components/search/types.ts | 22 ++++++++------ components/status/StatusActions.vue | 6 ++-- components/status/StatusActionsMore.vue | 3 +- components/status/StatusBody.vue | 7 +++-- components/status/StatusCard.vue | 2 +- components/status/StatusMedia.vue | 4 +-- components/status/edit/StatusEditPreview.vue | 5 +--- composables/gestures/index.ts | 1 - composables/translate.ts | 9 ++++-- html.d.ts | 13 -------- pages/[[server]]/@[account]/[status].vue | 3 +- .../[[server]]/@[account]/index/followers.vue | 2 +- .../[[server]]/@[account]/index/following.vue | 2 +- pages/[[server]]/tags/[tag].vue | 6 ++-- 24 files changed, 113 insertions(+), 74 deletions(-) delete mode 100644 html.d.ts diff --git a/components/account/AccountMoved.vue b/components/account/AccountMoved.vue index 32e79389..ac3b79e4 100644 --- a/components/account/AccountMoved.vue +++ b/components/account/AccountMoved.vue @@ -1,4 +1,6 @@ diff --git a/components/common/CommonCropImage.vue b/components/common/CommonCropImage.vue index adee86d6..a0557210 100644 --- a/components/common/CommonCropImage.vue +++ b/components/common/CommonCropImage.vue @@ -5,7 +5,7 @@ import 'vue-advanced-cropper/dist/style.css' export interface Props { /** Images to be cropped */ - modelValue?: File + modelValue?: File | null /** Crop frame aspect ratio (width/height), default 1/1 */ stencilAspectRatio?: number /** The ratio of the longest edge of the cut box to the length of the cut screen, default 0.9, not more than 1 */ diff --git a/components/common/CommonInputImage.vue b/components/common/CommonInputImage.vue index 49a51db2..3d88734a 100644 --- a/components/common/CommonInputImage.vue +++ b/components/common/CommonInputImage.vue @@ -3,7 +3,7 @@ import { fileOpen } from 'browser-fs-access' import type { FileWithHandle } from 'browser-fs-access' const props = withDefaults(defineProps<{ - modelValue?: FileWithHandle + modelValue?: FileWithHandle | null /** The image src before change */ original?: string /** Allowed file types */ diff --git a/components/modal/ModalContainer.vue b/components/modal/ModalContainer.vue index 2ef41456..31ba7cb3 100644 --- a/components/modal/ModalContainer.vue +++ b/components/modal/ModalContainer.vue @@ -53,6 +53,7 @@ const handlePublishClose = () => { > @@ -65,7 +66,7 @@ const handlePublishClose = () => { - + diff --git a/components/notification/NotificationPaginator.vue b/components/notification/NotificationPaginator.vue index d4a8e287..2f36aded 100644 --- a/components/notification/NotificationPaginator.vue +++ b/components/notification/NotificationPaginator.vue @@ -1,5 +1,11 @@ @@ -15,7 +16,7 @@ const { translation } = useTranslation(status) class="line-compact" :content="status.content" :emojis="status.emojis" - :lang="status.language" + :lang="'language' in status && status.language" />
- +
diff --git a/composables/gestures/index.ts b/composables/gestures/index.ts index 2b04ae5b..5cb2b747 100644 --- a/composables/gestures/index.ts +++ b/composables/gestures/index.ts @@ -24,7 +24,6 @@ export const useImageGesture = ( const { set } = useSpring(motionProperties as Partial) - // @ts-expect-error we need to fix types: just suppress it for now const handlers: Handlers = { onPinch({ offset: [d] }) { set({ scale: 1 + d / 200 }) diff --git a/composables/translate.ts b/composables/translate.ts index a275453f..79e9625d 100644 --- a/composables/translate.ts +++ b/composables/translate.ts @@ -1,4 +1,4 @@ -import type { Status } from 'masto' +import type { Status, StatusEdit } from 'masto' export interface TranslationResponse { translatedText: string @@ -24,15 +24,18 @@ export async function translateText(text: string, from?: string | null, to?: str return translatedText } -const translations = new WeakMap() +const translations = new WeakMap() -export function useTranslation(status: Status) { +export function useTranslation(status: Status | StatusEdit) { if (!translations.has(status)) translations.set(status, reactive({ visible: false, text: '' })) const translation = translations.get(status)! async function toggle() { + if (!('language' in status)) + return + if (!translation.text) translation.text = await translateText(status.content, status.language) diff --git a/html.d.ts b/html.d.ts deleted file mode 100644 index 343ccfd9..00000000 --- a/html.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -// for UnoCSS attributify mode compact in Volar -// refer: https://github.com/johnsoncodehk/volar/issues/1077#issuecomment-1145361472 -declare module '@vue/runtime-dom' { - interface HTMLAttributes { - [key: string]: any - } -} -declare module '@vue/runtime-core' { - interface AllowedComponentProps { - [key: string]: any - } -} -export {} diff --git a/pages/[[server]]/@[account]/[status].vue b/pages/[[server]]/@[account]/[status].vue index 467278fc..7c11f52a 100644 --- a/pages/[[server]]/@[account]/[status].vue +++ b/pages/[[server]]/@[account]/[status].vue @@ -1,5 +1,4 @@