From a4051330a36933ad5f5e1a442658a4bafc231aa9 Mon Sep 17 00:00:00 2001 From: bree Date: Sun, 4 Jul 2021 07:09:39 -0400 Subject: [PATCH 1/6] remove most uses of `as any` in typescript - replaced many uses of `as any` with another more specific cast `as T` - filled in missing typed for items that needed to be typed - new runtime code was added where necessary to satisfy the new types with comments - added missing theme variable "sidebar-active" to the Theme variables - forms using `react-hook-form` are now typechecked - changed some instances of `target` into `currentTarget` while removing `as any` assertions --- src/components/common/AutoComplete.tsx | 2 +- src/components/common/LocaleSelector.tsx | 6 ++--- src/components/common/UpdateIndicator.tsx | 2 +- src/components/common/messaging/Message.tsx | 7 ++++- .../attachments/AttachmentActions.tsx | 3 ++- src/components/markdown/Renderer.tsx | 27 ++++++++++++++----- .../navigation/left/HomeSidebar.tsx | 7 ++--- .../navigation/right/MemberSidebar.tsx | 16 +++-------- src/components/ui/Category.tsx | 1 + src/context/Locale.tsx | 6 +++-- src/context/Settings.tsx | 4 +-- src/context/Theme.tsx | 12 ++++++--- src/context/Voice.tsx | 6 +++-- src/context/intermediate/modals/Input.tsx | 3 ++- .../intermediate/modals/Onboarding.tsx | 12 ++++++--- .../intermediate/popovers/ModifyAccount.tsx | 27 ++++++++++++------- src/context/revoltjs/FileUploads.tsx | 4 +-- src/context/revoltjs/RevoltClient.tsx | 15 +++++------ src/context/revoltjs/SyncManager.tsx | 4 +-- src/context/revoltjs/events.ts | 27 +++++++++---------- src/context/revoltjs/hooks.ts | 14 ++++++++-- src/lib/ContextMenus.tsx | 20 +++++++------- src/pages/login/FormField.tsx | 2 ++ src/pages/login/forms/Form.tsx | 17 +++++++----- src/pages/login/forms/FormReset.tsx | 4 +-- src/pages/settings/panes/Account.tsx | 6 ++--- src/pages/settings/panes/Appearance.tsx | 10 +++---- src/pages/settings/panes/Notifications.tsx | 6 ++--- src/pages/settings/panes/Profile.tsx | 4 +-- src/pages/settings/panes/Sessions.tsx | 2 +- src/pages/settings/server/Roles.tsx | 2 +- 31 files changed, 161 insertions(+), 117 deletions(-) diff --git a/src/components/common/AutoComplete.tsx b/src/components/common/AutoComplete.tsx index 0e0f399d..565f4a4a 100644 --- a/src/components/common/AutoComplete.tsx +++ b/src/components/common/AutoComplete.tsx @@ -384,7 +384,7 @@ export default function AutoComplete({ detached, state, setState, onClick }: Pic }) } onClick={onClick}> - + )[match]} size={20} /> :{match}: ))} diff --git a/src/components/common/LocaleSelector.tsx b/src/components/common/LocaleSelector.tsx index 9e68cd72..225e2c38 100644 --- a/src/components/common/LocaleSelector.tsx +++ b/src/components/common/LocaleSelector.tsx @@ -1,7 +1,7 @@ import ComboBox from "../ui/ComboBox"; import { connectState } from "../../redux/connector"; import { WithDispatcher } from "../../redux/reducers"; -import { LanguageEntry, Languages } from "../../context/Locale"; +import { Language, LanguageEntry, Languages } from "../../context/Locale"; type Props = WithDispatcher & { locale: string; @@ -15,12 +15,12 @@ export function LocaleSelector(props: Props) { props.dispatcher && props.dispatcher({ type: "SET_LOCALE", - locale: e.currentTarget.value as any + locale: e.currentTarget.value as Language }) } > {Object.keys(Languages).map(x => { - const l = (Languages as any)[x] as LanguageEntry; + const l = Languages[x as keyof typeof Languages]; return (