From 0b439b79a1013413de7de62730b01794ddbc7350 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 13 Jun 2023 16:25:39 -0500 Subject: [PATCH] Upgrade to TypeScript 5.1 --- app/soapbox/components/list.tsx | 1 + .../components/ui/form-group/form-group.tsx | 3 +++ .../manage-group-modal/create-group-modal.tsx | 7 +++--- app/soapbox/features/ui/util/fullscreen.ts | 24 +------------------ package.json | 2 +- yarn.lock | 8 +++---- 6 files changed, 14 insertions(+), 31 deletions(-) diff --git a/app/soapbox/components/list.tsx b/app/soapbox/components/list.tsx index b56e0e6a76..dad4c972a0 100644 --- a/app/soapbox/components/list.tsx +++ b/app/soapbox/components/list.tsx @@ -43,6 +43,7 @@ const ListItem: React.FC = ({ label, hint, children, onClick, onSelec const isSelect = child.type === SelectDropdown || child.type === Select; return React.cloneElement(child, { + // @ts-ignore id: domId, className: clsx({ 'w-auto': isSelect, diff --git a/app/soapbox/components/ui/form-group/form-group.tsx b/app/soapbox/components/ui/form-group/form-group.tsx index 7efb60ade9..431615cdeb 100644 --- a/app/soapbox/components/ui/form-group/form-group.tsx +++ b/app/soapbox/components/ui/form-group/form-group.tsx @@ -29,9 +29,12 @@ const FormGroup: React.FC = (props) => { if (React.isValidElement(inputChildren[0])) { firstChild = React.cloneElement( inputChildren[0], + // @ts-ignore { id: formFieldId }, ); } + + // @ts-ignore const isCheckboxFormGroup = firstChild?.type === Checkbox; if (isCheckboxFormGroup) { diff --git a/app/soapbox/features/ui/components/modals/manage-group-modal/create-group-modal.tsx b/app/soapbox/features/ui/components/modals/manage-group-modal/create-group-modal.tsx index d87126c740..a05d1bbf1e 100644 --- a/app/soapbox/features/ui/components/modals/manage-group-modal/create-group-modal.tsx +++ b/app/soapbox/features/ui/components/modals/manage-group-modal/create-group-modal.tsx @@ -1,6 +1,7 @@ import { AxiosError } from 'axios'; import React, { useMemo, useState } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; +import { z } from 'zod'; import { useCreateGroup, useGroupValidation, type CreateGroupParams } from 'soapbox/api/hooks'; import { Modal, Stack } from 'soapbox/components/ui'; @@ -71,9 +72,9 @@ const CreateGroupModal: React.FC = ({ onClose }) => { }, onError(error) { if (error instanceof AxiosError) { - const msg = error.response?.data.error; - if (typeof msg === 'string') { - toast.error(msg); + const msg = z.object({ error: z.string() }).safeParse(error.response?.data); + if (msg.success) { + toast.error(msg.data.error); } } }, diff --git a/app/soapbox/features/ui/util/fullscreen.ts b/app/soapbox/features/ui/util/fullscreen.ts index 5e13d68cc5..b04092f0b0 100644 --- a/app/soapbox/features/ui/util/fullscreen.ts +++ b/app/soapbox/features/ui/util/fullscreen.ts @@ -33,26 +33,4 @@ export const requestFullscreen = (el: Element): void => { // @ts-ignore el.mozRequestFullScreen(); } -}; - -type FullscreenListener = (this: Document, ev: Event) => void; - -export const attachFullscreenListener = (listener: FullscreenListener): void => { - if ('onfullscreenchange' in document) { - document.addEventListener('fullscreenchange', listener); - } else if ('onwebkitfullscreenchange' in document) { - document.addEventListener('webkitfullscreenchange', listener); - } else if ('onmozfullscreenchange' in document) { - document.addEventListener('mozfullscreenchange', listener); - } -}; - -export const detachFullscreenListener = (listener: FullscreenListener): void => { - if ('onfullscreenchange' in document) { - document.removeEventListener('fullscreenchange', listener); - } else if ('onwebkitfullscreenchange' in document) { - document.removeEventListener('webkitfullscreenchange', listener); - } else if ('onmozfullscreenchange' in document) { - document.removeEventListener('mozfullscreenchange', listener); - } -}; +}; \ No newline at end of file diff --git a/package.json b/package.json index 78ee0bd679..4abab6c2d5 100644 --- a/package.json +++ b/package.json @@ -181,7 +181,7 @@ "ts-node": "^10.9.1", "tslib": "^2.3.1", "twemoji": "https://github.com/twitter/twemoji#v14.0.2", - "typescript": "^4.4.4", + "typescript": "^5.1.3", "util": "^0.12.4", "uuid": "^9.0.0", "webpack": "^5.72.1", diff --git a/yarn.lock b/yarn.lock index 022c5b8d09..282fca78c1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17150,10 +17150,10 @@ typescript@^4.0: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.3.tgz#bdc5407caa2b109efd4f82fe130656f977a29324" integrity sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA== -typescript@^4.4.4: - version "4.5.5" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.5.tgz#d8c953832d28924a9e3d37c73d729c846c5896f3" - integrity sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA== +typescript@^5.1.3: + version "5.1.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.3.tgz#8d84219244a6b40b6fb2b33cc1c062f715b9e826" + integrity sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw== typeson-registry@^1.0.0-alpha.20: version "1.0.0-alpha.39"