From c6cc04cad803bcfb0b77f94edd866079d084a0e1 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 6 Jan 2022 21:25:42 -0800 Subject: [PATCH] chore: More typescript FIXME's removed --- app/components/FilterOptions.tsx | 6 +- app/components/GroupListItem.tsx | 1 - app/components/PaginatedList.test.tsx | 3 +- app/components/Table.tsx | 24 ++------ app/models/GroupMembership.ts | 3 + .../Settings/components/PeopleTable.tsx | 38 ++++++------- app/stores/DocumentsStore.ts | 9 +-- app/stores/UiStore.ts | 3 +- app/typings/index.d.ts | 2 + app/typings/react-table.d.ts | 55 +++++++++++++++++++ app/utils/ApiClient.ts | 32 +++++------ app/utils/getDataTransferFiles.ts | 15 +++-- package.json | 2 +- server/commands/collectionImporter.ts | 23 +++----- server/commands/documentImporter.ts | 4 +- server/commands/teamPermanentDeleter.ts | 7 +-- server/models/Collection.test.ts | 3 +- server/models/Collection.ts | 6 +- server/presenters/user.ts | 40 ++++++-------- server/queues/processors/notifications.ts | 2 +- server/routes/api/attachments.test.ts | 1 - server/routes/api/auth.test.ts | 1 - .../api/authenticationProviders.test.ts | 1 - server/routes/api/collections.test.ts | 1 - server/routes/api/documents.test.ts | 1 - server/routes/api/events.test.ts | 1 - server/routes/api/fileOperations.test.ts | 1 - server/routes/api/groups.test.ts | 1 - server/routes/api/hooks.test.ts | 1 - server/routes/api/index.test.ts | 1 - server/routes/api/integrations.test.ts | 1 - .../routes/api/middlewares/pagination.test.ts | 1 - server/routes/api/revisions.test.ts | 1 - server/routes/api/shares.test.ts | 1 - server/routes/api/team.test.ts | 1 - server/routes/api/users.test.ts | 1 - server/routes/api/utils.test.ts | 1 - server/routes/api/views.test.ts | 1 - server/routes/auth/index.test.ts | 1 - server/routes/auth/providers/email.test.ts | 1 - server/routes/auth/providers/email.ts | 8 +-- server/routes/auth/providers/index.ts | 3 +- server/routes/index.test.ts | 1 - server/services/worker.ts | 3 +- server/typings/index.d.ts | 32 ++++------- server/typings/socketio-redis.d.ts | 12 ++++ server/typings/tommoor__remove-markdown.d.ts | 8 +++ server/utils/collectionIndexing.ts | 1 - server/utils/domains.ts | 2 +- server/utils/parseDocumentIds.ts | 10 +--- server/utils/parseImages.ts | 9 +-- shared/embeds/Miro.test.ts | 3 +- shared/utils/domains.test.ts | 3 - shared/utils/domains.ts | 3 +- shared/utils/naturalSort.test.ts | 1 - shared/utils/naturalSort.ts | 2 +- shared/utils/zip.ts | 13 ++--- yarn.lock | 8 +-- 58 files changed, 199 insertions(+), 221 deletions(-) create mode 100644 app/typings/react-table.d.ts create mode 100644 server/typings/socketio-redis.d.ts create mode 100644 server/typings/tommoor__remove-markdown.d.ts diff --git a/app/components/FilterOptions.tsx b/app/components/FilterOptions.tsx index d1ef547d8..30caeae83 100644 --- a/app/components/FilterOptions.tsx +++ b/app/components/FilterOptions.tsx @@ -1,4 +1,3 @@ -import { find } from "lodash"; import * as React from "react"; import { useMenuState, MenuButton } from "reakit/Menu"; import styled from "styled-components"; @@ -34,11 +33,8 @@ const FilterOptions = ({ modal: true, }); const selected = - find(options, { - key: activeKey, - }) || options[0]; + options.find((option) => option.key === activeKey) || options[0]; - // @ts-expect-error ts-migrate(2339) FIXME: Property 'label' does not exist on type 'number | ... Remove this comment to see the full error message const selectedLabel = selected ? `${selectedPrefix} ${selected.label}` : ""; return ( diff --git a/app/components/GroupListItem.tsx b/app/components/GroupListItem.tsx index 4604d49bd..259f44e06 100644 --- a/app/components/GroupListItem.tsx +++ b/app/components/GroupListItem.tsx @@ -41,7 +41,6 @@ class GroupListItem extends React.Component { const membershipsInGroup = groupMemberships.inGroup(group.id); const users = membershipsInGroup .slice(0, MAX_AVATAR_DISPLAY) - // @ts-expect-error ts-migrate(2339) FIXME: Property 'user' does not exist on type 'GroupMembe... Remove this comment to see the full error message .map((gm) => gm.user); const overflow = memberCount - users.length; diff --git a/app/components/PaginatedList.test.tsx b/app/components/PaginatedList.test.tsx index e7081c3e7..e95a19eb6 100644 --- a/app/components/PaginatedList.test.tsx +++ b/app/components/PaginatedList.test.tsx @@ -64,8 +64,7 @@ describe("PaginatedList", () => { }); it("calls fetch when options prop changes", async () => { - // @ts-expect-error ts-migrate(2554) FIXME: Expected 1-3 arguments, but got 0. - const fetchedItems = Array(DEFAULT_PAGINATION_LIMIT).fill(); + const fetchedItems = Array(DEFAULT_PAGINATION_LIMIT).fill(undefined); const fetch = jest.fn().mockReturnValue(Promise.resolve(fetchedItems)); const list = shallow( { - // @ts-expect-error ts-migrate(2339) FIXME: Property 'sortBy' does not exist on type 'TableSta... Remove this comment to see the full error message if (!isEqual(newState.sortBy, prevState.sortBy)) { return { ...newState, pageIndex: 0 }; } @@ -127,20 +120,15 @@ function Table({ {headerGroups.map((headerGroup) => ( {headerGroup.headers.map((column) => ( - // @ts-expect-error ts-migrate(2339) FIXME: Property 'getSortByToggleProps' does not exist on ... Remove this comment to see the full error message {column.render("Header")} - { - // @ts-expect-error known issue: https://github.com/tannerlinsley/react-table/issues/2970 - column.isSorted && - // @ts-expect-error ts-migrate(2339) FIXME: Property 'isSortedDesc' does not exist on type 'He... Remove this comment to see the full error message - (column.isSortedDesc ? ( - - ) : ( - - )) - } + {column.isSorted && + (column.isSortedDesc ? ( + + ) : ( + + ))} ))} diff --git a/app/models/GroupMembership.ts b/app/models/GroupMembership.ts index 0ad01ddb9..ef71c6481 100644 --- a/app/models/GroupMembership.ts +++ b/app/models/GroupMembership.ts @@ -1,4 +1,5 @@ import BaseModel from "./BaseModel"; +import User from "./User"; class GroupMembership extends BaseModel { id: string; @@ -6,6 +7,8 @@ class GroupMembership extends BaseModel { userId: string; groupId: string; + + user: User; } export default GroupMembership; diff --git a/app/scenes/Settings/components/PeopleTable.tsx b/app/scenes/Settings/components/PeopleTable.tsx index 3b2951a78..df467400c 100644 --- a/app/scenes/Settings/components/PeopleTable.tsx +++ b/app/scenes/Settings/components/PeopleTable.tsx @@ -12,8 +12,7 @@ import Time from "~/components/Time"; import useCurrentUser from "~/hooks/useCurrentUser"; import UserMenu from "~/menus/UserMenu"; -// @ts-expect-error ts-migrate(2344) FIXME: Type 'Props' does not satisfy the constraint 'Comp... Remove this comment to see the full error message -const Table = React.lazy( +const Table = React.lazy( () => import( /* webpackChunkName: "table" */ @@ -40,38 +39,36 @@ function PeopleTable({ canManage, ...rest }: Props) { id: "name", Header: t("Name"), accessor: "name", - // @ts-expect-error ts-migrate(7031) FIXME: Binding element 'value' implicitly has an 'any' ty... Remove this comment to see the full error message - Cell: observer(({ value, row }) => ( - - {value}{" "} - {currentUser.id === row.original.id && `(${t("You")})`} - - )), + Cell: observer( + ({ value, row }: { value: string; row: { original: User } }) => ( + + {value}{" "} + {currentUser.id === row.original.id && `(${t("You")})`} + + ) + ), }, canManage ? { id: "email", Header: t("Email"), accessor: "email", - // @ts-expect-error ts-migrate(7031) FIXME: Binding element 'value' implicitly has an 'any' ty... Remove this comment to see the full error message - Cell: observer(({ value }) => value), + Cell: observer(({ value }: { value: string }) => <>{value}), } : undefined, { id: "lastActiveAt", Header: t("Last active"), accessor: "lastActiveAt", - Cell: observer( - // @ts-expect-error ts-migrate(7031) FIXME: Binding element 'value' implicitly has an 'any' ty... Remove this comment to see the full error message - ({ value }) => value &&