chore: More typescript FIXME's removed

This commit is contained in:
Tom Moor
2022-01-06 21:25:42 -08:00
parent 8d05c752ea
commit c6cc04cad8
58 changed files with 199 additions and 221 deletions

View File

@@ -1,4 +1,3 @@
import { find } from "lodash";
import * as React from "react"; import * as React from "react";
import { useMenuState, MenuButton } from "reakit/Menu"; import { useMenuState, MenuButton } from "reakit/Menu";
import styled from "styled-components"; import styled from "styled-components";
@@ -34,11 +33,8 @@ const FilterOptions = ({
modal: true, modal: true,
}); });
const selected = const selected =
find(options, { options.find((option) => option.key === activeKey) || options[0];
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}` : ""; const selectedLabel = selected ? `${selectedPrefix} ${selected.label}` : "";
return ( return (

View File

@@ -41,7 +41,6 @@ class GroupListItem extends React.Component<Props> {
const membershipsInGroup = groupMemberships.inGroup(group.id); const membershipsInGroup = groupMemberships.inGroup(group.id);
const users = membershipsInGroup const users = membershipsInGroup
.slice(0, MAX_AVATAR_DISPLAY) .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); .map((gm) => gm.user);
const overflow = memberCount - users.length; const overflow = memberCount - users.length;

View File

@@ -64,8 +64,7 @@ describe("PaginatedList", () => {
}); });
it("calls fetch when options prop changes", async () => { 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(undefined);
const fetchedItems = Array(DEFAULT_PAGINATION_LIMIT).fill();
const fetch = jest.fn().mockReturnValue(Promise.resolve(fetchedItems)); const fetch = jest.fn().mockReturnValue(Promise.resolve(fetchedItems));
const list = shallow( const list = shallow(
<PaginatedList <PaginatedList

View File

@@ -51,15 +51,10 @@ function Table({
headerGroups, headerGroups,
rows, rows,
prepareRow, prepareRow,
// @ts-expect-error ts-migrate(2339) FIXME: Property 'canNextPage' does not exist on type 'Tab... Remove this comment to see the full error message
canNextPage, canNextPage,
// @ts-expect-error ts-migrate(2339) FIXME: Property 'nextPage' does not exist on type 'TableI... Remove this comment to see the full error message
nextPage, nextPage,
// @ts-expect-error ts-migrate(2339) FIXME: Property 'canPreviousPage' does not exist on type ... Remove this comment to see the full error message
canPreviousPage, canPreviousPage,
// @ts-expect-error ts-migrate(2339) FIXME: Property 'previousPage' does not exist on type 'Ta... Remove this comment to see the full error message
previousPage, previousPage,
// @ts-expect-error ts-migrate(2339) FIXME: Property 'pageIndex' does not exist on type 'Table... Remove this comment to see the full error message
state: { pageIndex, sortBy }, state: { pageIndex, sortBy },
} = useTable( } = useTable(
{ {
@@ -71,7 +66,6 @@ function Table({
autoResetPage: false, autoResetPage: false,
pageCount: totalPages, pageCount: totalPages,
initialState: { initialState: {
// @ts-expect-error ts-migrate(2322) FIXME: Type '{ sortBy: { id: string; desc: boolean; }[]; ... Remove this comment to see the full error message
sortBy: [ sortBy: [
{ {
id: defaultSort, id: defaultSort,
@@ -82,7 +76,6 @@ function Table({
pageIndex: page, pageIndex: page,
}, },
stateReducer: (newState, action, prevState) => { stateReducer: (newState, action, prevState) => {
// @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)) { if (!isEqual(newState.sortBy, prevState.sortBy)) {
return { ...newState, pageIndex: 0 }; return { ...newState, pageIndex: 0 };
} }
@@ -127,20 +120,15 @@ function Table({
{headerGroups.map((headerGroup) => ( {headerGroups.map((headerGroup) => (
<tr {...headerGroup.getHeaderGroupProps()}> <tr {...headerGroup.getHeaderGroupProps()}>
{headerGroup.headers.map((column) => ( {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
<Head {...column.getHeaderProps(column.getSortByToggleProps())}> <Head {...column.getHeaderProps(column.getSortByToggleProps())}>
<SortWrapper align="center" gap={4}> <SortWrapper align="center" gap={4}>
{column.render("Header")} {column.render("Header")}
{ {column.isSorted &&
// @ts-expect-error known issue: https://github.com/tannerlinsley/react-table/issues/2970 (column.isSortedDesc ? (
column.isSorted && <DescSortIcon />
// @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 ? ( <AscSortIcon />
<DescSortIcon /> ))}
) : (
<AscSortIcon />
))
}
</SortWrapper> </SortWrapper>
</Head> </Head>
))} ))}

View File

@@ -1,4 +1,5 @@
import BaseModel from "./BaseModel"; import BaseModel from "./BaseModel";
import User from "./User";
class GroupMembership extends BaseModel { class GroupMembership extends BaseModel {
id: string; id: string;
@@ -6,6 +7,8 @@ class GroupMembership extends BaseModel {
userId: string; userId: string;
groupId: string; groupId: string;
user: User;
} }
export default GroupMembership; export default GroupMembership;

View File

@@ -12,8 +12,7 @@ import Time from "~/components/Time";
import useCurrentUser from "~/hooks/useCurrentUser"; import useCurrentUser from "~/hooks/useCurrentUser";
import UserMenu from "~/menus/UserMenu"; 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<TableProps>(
() => () =>
import( import(
/* webpackChunkName: "table" */ /* webpackChunkName: "table" */
@@ -40,38 +39,36 @@ function PeopleTable({ canManage, ...rest }: Props) {
id: "name", id: "name",
Header: t("Name"), Header: t("Name"),
accessor: "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(
Cell: observer(({ value, row }) => ( ({ value, row }: { value: string; row: { original: User } }) => (
<Flex align="center" gap={8}> <Flex align="center" gap={8}>
<Avatar src={row.original.avatarUrl} size={32} /> {value}{" "} <Avatar src={row.original.avatarUrl} size={32} /> {value}{" "}
{currentUser.id === row.original.id && `(${t("You")})`} {currentUser.id === row.original.id && `(${t("You")})`}
</Flex> </Flex>
)), )
),
}, },
canManage canManage
? { ? {
id: "email", id: "email",
Header: t("Email"), Header: t("Email"),
accessor: "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: string }) => <>{value}</>),
Cell: observer(({ value }) => value),
} }
: undefined, : undefined,
{ {
id: "lastActiveAt", id: "lastActiveAt",
Header: t("Last active"), Header: t("Last active"),
accessor: "lastActiveAt", accessor: "lastActiveAt",
Cell: observer( Cell: observer(({ value }: { value: string }) =>
// @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 ? <Time dateTime={value} addSuffix /> : null
({ value }) => value && <Time dateTime={value} addSuffix />
), ),
}, },
{ {
id: "isAdmin", id: "isAdmin",
Header: t("Role"), Header: t("Role"),
accessor: "rank", accessor: "rank",
// @ts-expect-error ts-migrate(7031) FIXME: Binding element 'row' implicitly has an 'any' type... Remove this comment to see the full error message Cell: observer(({ row }: { row: { original: User } }) => (
Cell: observer(({ row }) => (
<Badges> <Badges>
{!row.original.lastActiveAt && <Badge>{t("Invited")}</Badge>} {!row.original.lastActiveAt && <Badge>{t("Invited")}</Badge>}
{row.original.isAdmin && <Badge primary>{t("Admin")}</Badge>} {row.original.isAdmin && <Badge primary>{t("Admin")}</Badge>}
@@ -86,16 +83,17 @@ function PeopleTable({ canManage, ...rest }: Props) {
accessor: "id", accessor: "id",
className: "actions", className: "actions",
Cell: observer( Cell: observer(
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type '({ row, value }: { row: any; val... Remove this comment to see the full error message ({ row, value }: { value: string; row: { original: User } }) =>
({ row, value }) => currentUser.id !== value ? (
currentUser.id !== value && <UserMenu user={row.original} /> <UserMenu user={row.original} />
) : null
), ),
} }
: undefined, : undefined,
].filter((i) => i), ].filter((i) => i),
[t, canManage, currentUser] [t, canManage, currentUser]
); );
// @ts-expect-error ts-migrate(2322) FIXME: Type '{ data: any[] & User[]; offset?: number | un... Remove this comment to see the full error message
return <Table columns={columns} {...rest} />; return <Table columns={columns} {...rest} />;
} }

View File

@@ -257,8 +257,7 @@ export default class DocumentsStore extends BaseStore<Document> {
this.backlinks.set( this.backlinks.set(
documentId, documentId,
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'doc' implicitly has an 'any' type. data.map((doc: Partial<Document>) => doc.id)
data.map((doc) => doc.id)
); );
}); });
}; };
@@ -401,15 +400,13 @@ export default class DocumentsStore extends BaseStore<Document> {
invariant(res && res.data, "Search response should be available"); invariant(res && res.data, "Search response should be available");
// add the documents and associated policies to the store // add the documents and associated policies to the store
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'result' implicitly has an 'any' type. res.data.forEach((result: SearchResult) => this.add(result.document));
res.data.forEach((result) => this.add(result.document));
this.addPolicies(res.policies); this.addPolicies(res.policies);
// store a reference to the document model in the search cache instead // store a reference to the document model in the search cache instead
// of the original result from the API. // of the original result from the API.
const results: SearchResult[] = compact( const results: SearchResult[] = compact(
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'result' implicitly has an 'any' type. res.data.map((result: SearchResult) => {
res.data.map((result) => {
const document = this.data.get(result.document.id); const document = this.data.get(result.document.id);
if (!document) return null; if (!document) return null;
return { return {

View File

@@ -79,8 +79,7 @@ class UiStore {
"(prefers-color-scheme: dark)" "(prefers-color-scheme: dark)"
); );
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'event' implicitly has an 'any' type. const setSystemTheme = (event: MediaQueryListEvent | MediaQueryList) => {
const setSystemTheme = (event) => {
this.systemTheme = event.matches ? SystemTheme.Dark : SystemTheme.Light; this.systemTheme = event.matches ? SystemTheme.Dark : SystemTheme.Light;
}; };

View File

@@ -12,3 +12,5 @@ declare module "*.png" {
const value: any; const value: any;
export = value; export = value;
} }
declare const EDITOR_VERSION: string;

55
app/typings/react-table.d.ts vendored Normal file
View File

@@ -0,0 +1,55 @@
/* eslint-disable @typescript-eslint/ban-types */
import {
UsePaginationInstanceProps,
UsePaginationOptions,
UsePaginationState,
UseSortByColumnOptions,
UseSortByColumnProps,
UseSortByHooks,
UseSortByInstanceProps,
UseSortByOptions,
UseSortByState,
} from "react-table";
declare module "react-table" {
export interface TableOptions<D extends object>
extends UseExpandedOptions<D>,
UsePaginationOptions<D>,
UseSortByOptions<D>,
// note that having Record here allows you to add anything to the options, this matches the spirit of the
// underlying js library, but might be cleaner if it's replaced by a more specific type that matches your
// feature set, this is a safe default.
Record<string, any> {}
export interface Hooks<D extends object = {}>
extends UseExpandedHooks<D>,
UseSortByHooks<D> {}
export interface TableInstance<D extends object = {}>
extends UsePaginationInstanceProps<D>,
UseSortByInstanceProps<D> {}
export interface TableState<D extends object = {}>
extends UseColumnOrderState<D>,
UseExpandedState<D>,
UsePaginationState<D>,
UseSortByState<D> {}
export interface ColumnInterface<D extends object = {}>
extends UseResizeColumnsColumnOptions<D>,
UseSortByColumnOptions<D> {}
export interface ColumnInstance<D extends object = {}>
extends UseResizeColumnsColumnProps<D>,
UseSortByColumnProps<D> {}
export interface Cell<D extends object = {}>
extends UseGroupByCellProps<D>,
UseRowStateCellProps<D> {}
export interface Row<D extends object = {}>
extends UseExpandedRowProps<D>,
UseGroupByRowProps<D>,
UseRowSelectRowProps<D>,
UseRowStateRowProps<D> {}
}

View File

@@ -38,10 +38,10 @@ class ApiClient {
fetch = async ( fetch = async (
path: string, path: string,
method: string, method: string,
data: (Record<string, any> | undefined) | FormData, data: Record<string, any> | FormData | undefined,
options: Record<string, any> = {} options: Record<string, any> = {}
) => { ) => {
let body; let body: string | FormData | undefined;
let modifiedPath; let modifiedPath;
let urlToFetch; let urlToFetch;
let isJson; let isJson;
@@ -53,7 +53,9 @@ class ApiClient {
modifiedPath = path; modifiedPath = path;
} }
} else if (method === "POST" || method === "PUT") { } else if (method === "POST" || method === "PUT") {
body = data || undefined; if (data instanceof FormData || typeof data === "string") {
body = data;
}
// Only stringify data if its a normal object and // Only stringify data if its a normal object and
// not if it's [object FormData], in addition to // not if it's [object FormData], in addition to
@@ -76,7 +78,6 @@ class ApiClient {
const headerOptions: any = { const headerOptions: any = {
Accept: "application/json", Accept: "application/json",
"cache-control": "no-cache", "cache-control": "no-cache",
// @ts-expect-error ts-migrate(2304) FIXME: Cannot find name 'EDITOR_VERSION'.
"x-editor-version": EDITOR_VERSION, "x-editor-version": EDITOR_VERSION,
pragma: "no-cache", pragma: "no-cache",
}; };
@@ -100,7 +101,6 @@ class ApiClient {
try { try {
response = await fetchWithRetry(urlToFetch, { response = await fetchWithRetry(urlToFetch, {
method, method,
// @ts-expect-error ts-migrate(2322) FIXME: Type 'string | Record<string, any> | undefined' is... Remove this comment to see the full error message
body, body,
headers, headers,
redirect: "follow", redirect: "follow",
@@ -137,58 +137,52 @@ class ApiClient {
} }
// Handle failed responses // Handle failed responses
const error = {}; const error: {
// @ts-expect-error ts-migrate(2339) FIXME: Property 'statusCode' does not exist on type '{}'. statusCode?: number;
response?: Response;
message?: string;
error?: string;
data?: Record<string, any>;
} = {};
error.statusCode = response.status; error.statusCode = response.status;
// @ts-expect-error ts-migrate(2339) FIXME: Property 'response' does not exist on type '{}'.
error.response = response; error.response = response;
try { try {
const parsed = await response.json(); const parsed = await response.json();
// @ts-expect-error ts-migrate(2339) FIXME: Property 'message' does not exist on type '{}'.
error.message = parsed.message || ""; error.message = parsed.message || "";
// @ts-expect-error ts-migrate(2339) FIXME: Property 'error' does not exist on type '{}'.
error.error = parsed.error; error.error = parsed.error;
// @ts-expect-error ts-migrate(2339) FIXME: Property 'data' does not exist on type '{}'.
error.data = parsed.data; error.data = parsed.data;
} catch (_err) { } catch (_err) {
// we're trying to parse an error so JSON may not be valid // we're trying to parse an error so JSON may not be valid
} }
// @ts-expect-error ts-migrate(2339) FIXME: Property 'error' does not exist on type '{}'.
if (response.status === 400 && error.error === "editor_update_required") { if (response.status === 400 && error.error === "editor_update_required") {
window.location.reload(); window.location.reload();
// @ts-expect-error ts-migrate(2339) FIXME: Property 'message' does not exist on type '{}'.
throw new UpdateRequiredError(error.message); throw new UpdateRequiredError(error.message);
} }
if (response.status === 400) { if (response.status === 400) {
// @ts-expect-error ts-migrate(2339) FIXME: Property 'message' does not exist on type '{}'.
throw new BadRequestError(error.message); throw new BadRequestError(error.message);
} }
if (response.status === 403) { if (response.status === 403) {
// @ts-expect-error ts-migrate(2339) FIXME: Property 'error' does not exist on type '{}'.
if (error.error === "user_suspended") { if (error.error === "user_suspended") {
stores.auth.logout(); stores.auth.logout();
return; return;
} }
// @ts-expect-error ts-migrate(2339) FIXME: Property 'message' does not exist on type '{}'.
throw new AuthorizationError(error.message); throw new AuthorizationError(error.message);
} }
if (response.status === 404) { if (response.status === 404) {
// @ts-expect-error ts-migrate(2339) FIXME: Property 'message' does not exist on type '{}'.
throw new NotFoundError(error.message); throw new NotFoundError(error.message);
} }
if (response.status === 503) { if (response.status === 503) {
// @ts-expect-error ts-migrate(2339) FIXME: Property 'message' does not exist on type '{}'.
throw new ServiceUnavailableError(error.message); throw new ServiceUnavailableError(error.message);
} }
// @ts-expect-error ts-migrate(2339) FIXME: Property 'message' does not exist on type '{}'.
throw new RequestError(error.message); throw new RequestError(error.message);
}; };

View File

@@ -4,11 +4,9 @@ export default function getDataTransferFiles(
| React.FormEvent<HTMLInputElement> | React.FormEvent<HTMLInputElement>
| React.DragEvent<HTMLElement> | React.DragEvent<HTMLElement>
): File[] { ): File[] {
let dataTransferItemsList = []; let dataTransferItemsList!: FileList | DataTransferItemList;
// @ts-expect-error ts-migrate(2339) FIXME: Property 'dataTransfer' does not exist on type 'Sy... Remove this comment to see the full error message if ("dataTransfer" in event) {
if (event.dataTransfer) {
// @ts-expect-error ts-migrate(2339) FIXME: Property 'dataTransfer' does not exist on type 'Sy... Remove this comment to see the full error message
const dt = event.dataTransfer; const dt = event.dataTransfer;
if (dt.files && dt.files.length) { if (dt.files && dt.files.length) {
@@ -18,12 +16,13 @@ export default function getDataTransferFiles(
// but Chrome implements some drag store, which is accesible via dataTransfer.items // but Chrome implements some drag store, which is accesible via dataTransfer.items
dataTransferItemsList = dt.items; dataTransferItemsList = dt.items;
} }
// @ts-expect-error ts-migrate(2339) FIXME: Property 'files' does not exist on type 'EventTarg... Remove this comment to see the full error message } else if (event.target && "files" in event.target) {
} else if (event.target && event.target.files) { // @ts-expect-error fallback
// @ts-expect-error ts-migrate(2339) FIXME: Property 'files' does not exist on type 'EventTarg... Remove this comment to see the full error message
dataTransferItemsList = event.target.files; dataTransferItemsList = event.target.files;
} }
// Convert from DataTransferItemsList to the native Array // Convert from DataTransferItemsList to the native Array
return Array.prototype.slice.call(dataTransferItemsList); return dataTransferItemsList
? Array.prototype.slice.call(dataTransferItemsList)
: [];
} }

View File

@@ -230,7 +230,7 @@
"@types/react-medium-image-zoom": "^3.0.1", "@types/react-medium-image-zoom": "^3.0.1",
"@types/react-portal": "^4.0.4", "@types/react-portal": "^4.0.4",
"@types/react-router-dom": "^5.3.2", "@types/react-router-dom": "^5.3.2",
"@types/react-table": "^7.7.8", "@types/react-table": "^7.7.9",
"@types/react-virtualized-auto-sizer": "^1.0.1", "@types/react-virtualized-auto-sizer": "^1.0.1",
"@types/react-window": "^1.8.5", "@types/react-window": "^1.8.5",
"@types/semver": "^7.3.9", "@types/semver": "^7.3.9",

View File

@@ -45,18 +45,9 @@ export default async function collectionImporter({
} }
// store progress and pointers // store progress and pointers
// @ts-expect-error ts-migrate(2741) FIXME: Property 'string' is missing in type '{}' but requ... Remove this comment to see the full error message const collections: Record<string, Collection> = {};
const collections: { const documents: Record<string, Document> = {};
string: Collection; const attachments: Record<string, Attachment> = {};
} = {};
// @ts-expect-error ts-migrate(2741) FIXME: Property 'string' is missing in type '{}' but requ... Remove this comment to see the full error message
const documents: {
string: Document;
} = {};
// @ts-expect-error ts-migrate(2741) FIXME: Property 'string' is missing in type '{}' but requ... Remove this comment to see the full error message
const attachments: {
string: Attachment;
} = {};
for (const item of items) { for (const item of items) {
if (item.type === "collection") { if (item.type === "collection") {
@@ -113,6 +104,7 @@ export default async function collectionImporter({
const tmpDir = os.tmpdir(); const tmpDir = os.tmpdir();
const tmpFilePath = `${tmpDir}/upload-${uuidv4()}`; const tmpFilePath = `${tmpDir}/upload-${uuidv4()}`;
await fs.promises.writeFile(tmpFilePath, content); await fs.promises.writeFile(tmpFilePath, content);
const file = new File({ const file = new File({
name, name,
type: "text/markdown", type: "text/markdown",
@@ -123,6 +115,7 @@ export default async function collectionImporter({
user, user,
ip, ip,
}); });
await fs.promises.unlink(tmpFilePath); await fs.promises.unlink(tmpFilePath);
// must be a nested document, find and reference the parent document // must be a nested document, find and reference the parent document
let parentDocumentId; let parentDocumentId;
@@ -142,10 +135,8 @@ export default async function collectionImporter({
collectionId: collection.id, collectionId: collection.id,
createdAt: item.metadata.createdAt createdAt: item.metadata.createdAt
? new Date(item.metadata.createdAt) ? new Date(item.metadata.createdAt)
: // @ts-expect-error ts-migrate(2339) FIXME: Property 'date' does not exist on type 'Item'. : item.item.date,
item.date, updatedAt: item.item.date,
// @ts-expect-error ts-migrate(2339) FIXME: Property 'date' does not exist on type 'Item'.
updatedAt: item.date,
parentDocumentId, parentDocumentId,
user, user,
ip, ip,

View File

@@ -1,7 +1,5 @@
import fs from "fs"; import fs from "fs";
import path from "path"; import path from "path";
import File from "formidable/lib/file";
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'jopl... Remove this comment to see the full error message
import { strikethrough, tables } from "joplin-turndown-plugin-gfm"; import { strikethrough, tables } from "joplin-turndown-plugin-gfm";
import mammoth from "mammoth"; import mammoth from "mammoth";
import quotedPrintable from "quoted-printable"; import quotedPrintable from "quoted-printable";
@@ -21,6 +19,7 @@ const turndownService = new TurndownService({
bulletListMarker: "-", bulletListMarker: "-",
headingStyle: "atx", headingStyle: "atx",
}); });
// Use the GitHub-flavored markdown plugin to parse // Use the GitHub-flavored markdown plugin to parse
// strikethoughs and tables // strikethoughs and tables
turndownService turndownService
@@ -32,6 +31,7 @@ turndownService
return "\n"; return "\n";
}, },
}); });
interface ImportableFile { interface ImportableFile {
type: string; type: string;
getMarkdown: (file: any) => Promise<string>; getMarkdown: (file: any) => Promise<string>;

View File

@@ -1,3 +1,4 @@
import { Transaction } from "sequelize";
import { sequelize } from "@server/database/sequelize"; import { sequelize } from "@server/database/sequelize";
import Logger from "@server/logging/logger"; import Logger from "@server/logging/logger";
import { import {
@@ -31,8 +32,7 @@ export default async function teamPermanentDeleter(team: Team) {
`Permanently deleting team ${team.name} (${team.id})` `Permanently deleting team ${team.name} (${team.id})`
); );
const teamId = team.id; const teamId = team.id;
// @ts-expect-error ts-migrate(7034) FIXME: Variable 'transaction' implicitly has type 'any' i... Remove this comment to see the full error message let transaction!: Transaction;
let transaction;
try { try {
transaction = await sequelize.transaction(); transaction = await sequelize.transaction();
@@ -54,7 +54,6 @@ export default async function teamPermanentDeleter(team: Team) {
await Promise.all( await Promise.all(
attachments.map((attachment) => attachments.map((attachment) =>
attachment.destroy({ attachment.destroy({
// @ts-expect-error ts-migrate(7005) FIXME: Variable 'transaction' implicitly has an 'any' typ... Remove this comment to see the full error message
transaction, transaction,
}) })
) )
@@ -78,7 +77,6 @@ export default async function teamPermanentDeleter(team: Team) {
userId: userIds, userId: userIds,
}, },
force: true, force: true,
// @ts-expect-error ts-migrate(7005) FIXME: Variable 'transaction' implicitly has an 'any' typ... Remove this comment to see the full error message
transaction, transaction,
}); });
await ApiKey.destroy({ await ApiKey.destroy({
@@ -86,7 +84,6 @@ export default async function teamPermanentDeleter(team: Team) {
userId: userIds, userId: userIds,
}, },
force: true, force: true,
// @ts-expect-error ts-migrate(7005) FIXME: Variable 'transaction' implicitly has an 'any' typ... Remove this comment to see the full error message
transaction, transaction,
}); });
} }

View File

@@ -343,8 +343,7 @@ describe("#membershipUserIds", () => {
// Make 6 users // Make 6 users
const users = await Promise.all( const users = await Promise.all(
Array(6) Array(6)
// @ts-expect-error ts-migrate(2554) FIXME: Expected 1-3 arguments, but got 0. .fill(undefined)
.fill()
.map(() => .map(() =>
buildUser({ buildUser({
teamId, teamId,

View File

@@ -353,7 +353,7 @@ class Collection extends ParanoidModel {
} }
getDocumentTree = function (documentId: string): NavigationNode { getDocumentTree = function (documentId: string): NavigationNode {
let result: NavigationNode; let result!: NavigationNode;
const loopChildren = (documents: NavigationNode[]) => { const loopChildren = (documents: NavigationNode[]) => {
if (result) { if (result) {
@@ -375,7 +375,6 @@ class Collection extends ParanoidModel {
loopChildren(this.documentStructure); loopChildren(this.documentStructure);
// @ts-expect-error used before undefined
return result; return result;
}; };
@@ -479,7 +478,7 @@ class Collection extends ParanoidModel {
}; };
getDocumentParents = function (documentId: string): string[] | void { getDocumentParents = function (documentId: string): string[] | void {
let result: string[]; let result!: string[];
const loopChildren = (documents: NavigationNode[], path: string[] = []) => { const loopChildren = (documents: NavigationNode[], path: string[] = []) => {
if (result) { if (result) {
@@ -499,7 +498,6 @@ class Collection extends ParanoidModel {
loopChildren(this.documentStructure); loopChildren(this.documentStructure);
} }
// @ts-expect-error used before undefined
return result; return result;
}; };

View File

@@ -3,50 +3,42 @@ import { User } from "@server/models";
type Options = { type Options = {
includeDetails?: boolean; includeDetails?: boolean;
}; };
type UserPresentation = { type UserPresentation = {
id: string; id: string;
name: string; name: string;
avatarUrl: string | null | undefined; avatarUrl: string | null | undefined;
email?: string; createdAt: Date;
lastActiveAt: Date | null;
color: string; color: string;
isAdmin: boolean; isAdmin: boolean;
isSuspended: boolean; isSuspended: boolean;
isViewer: boolean; isViewer: boolean;
language: string; email?: string | null;
language?: string;
}; };
export default ( export default (
user: User, user: User,
options: Options = {} options: Options = {}
): UserPresentation | null | undefined => { ): UserPresentation | null | undefined => {
const userData = {}; const userData: UserPresentation = {
// @ts-expect-error ts-migrate(2339) FIXME: Property 'id' does not exist on type '{}'. id: user.id,
userData.id = user.id; name: user.name,
// @ts-expect-error ts-migrate(2339) FIXME: Property 'createdAt' does not exist on type '{}'. avatarUrl: user.avatarUrl,
userData.createdAt = user.createdAt; color: user.color,
// @ts-expect-error ts-migrate(2339) FIXME: Property 'name' does not exist on type '{}'. isAdmin: user.isAdmin,
userData.name = user.name; isSuspended: user.isSuspended,
// @ts-expect-error ts-migrate(2339) FIXME: Property 'color' does not exist on type '{}'. isViewer: user.isViewer,
userData.color = user.color; createdAt: user.createdAt,
// @ts-expect-error ts-migrate(2339) FIXME: Property 'isAdmin' does not exist on type '{}'. lastActiveAt: user.lastActiveAt,
userData.isAdmin = user.isAdmin; };
// @ts-expect-error ts-migrate(2339) FIXME: Property 'isViewer' does not exist on type '{}'.
userData.isViewer = user.isViewer;
// @ts-expect-error ts-migrate(2339) FIXME: Property 'isSuspended' does not exist on type '{}'... Remove this comment to see the full error message
userData.isSuspended = user.isSuspended;
// @ts-expect-error ts-migrate(2339) FIXME: Property 'avatarUrl' does not exist on type '{}'.
userData.avatarUrl = user.avatarUrl;
// @ts-expect-error ts-migrate(2339) FIXME: Property 'lastActiveAt' does not exist on type '{}... Remove this comment to see the full error message
userData.lastActiveAt = user.lastActiveAt;
if (options.includeDetails) { if (options.includeDetails) {
// @ts-expect-error ts-migrate(2339) FIXME: Property 'email' does not exist on type '{}'.
userData.email = user.email; userData.email = user.email;
// @ts-expect-error ts-migrate(2339) FIXME: Property 'language' does not exist on type '{}'.
userData.language = userData.language =
user.language || process.env.DEFAULT_LANGUAGE || "en_US"; user.language || process.env.DEFAULT_LANGUAGE || "en_US";
} }
// @ts-expect-error ts-migrate(2740) FIXME: Type '{}' is missing the following properties from... Remove this comment to see the full error message
return userData; return userData;
}; };

View File

@@ -33,7 +33,7 @@ export default class NotificationsProcessor {
async documentUpdated(event: DocumentEvent | RevisionEvent) { async documentUpdated(event: DocumentEvent | RevisionEvent) {
// never send notifications when batch importing documents // never send notifications when batch importing documents
// @ts-expect-error ts-migrate(2339) FIXME: Property 'data' does not exist on type 'DocumentEv... Remove this comment to see the full error message // @ts-expect-error ts-migrate(2339) FIXME: Property 'data' does not exist on type 'DocumentEv... Remove this comment to see the full error message
if (event.data && event.data.source === "import") return; if (event.data?.source === "import") return;
const [document, team] = await Promise.all([ const [document, team] = await Promise.all([
Document.findByPk(event.documentId), Document.findByPk(event.documentId),
Team.findByPk(event.teamId), Team.findByPk(event.teamId),

View File

@@ -1,4 +1,3 @@
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import Attachment from "@server/models/Attachment"; import Attachment from "@server/models/Attachment";
import webService from "@server/services/web"; import webService from "@server/services/web";

View File

@@ -1,4 +1,3 @@
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import webService from "@server/services/web"; import webService from "@server/services/web";
import { buildUser, buildTeam } from "@server/test/factories"; import { buildUser, buildTeam } from "@server/test/factories";

View File

@@ -1,4 +1,3 @@
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { v4 as uuidv4 } from "uuid"; import { v4 as uuidv4 } from "uuid";
import webService from "@server/services/web"; import webService from "@server/services/web";

View File

@@ -1,4 +1,3 @@
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { Document, CollectionUser, CollectionGroup } from "@server/models"; import { Document, CollectionUser, CollectionGroup } from "@server/models";
import webService from "@server/services/web"; import webService from "@server/services/web";

View File

@@ -1,4 +1,3 @@
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { import {
Document, Document,

View File

@@ -1,4 +1,3 @@
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import webService from "@server/services/web"; import webService from "@server/services/web";
import { buildEvent, buildUser } from "@server/test/factories"; import { buildEvent, buildUser } from "@server/test/factories";

View File

@@ -1,4 +1,3 @@
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { Collection, User, Event, FileOperation } from "@server/models"; import { Collection, User, Event, FileOperation } from "@server/models";
import webService from "@server/services/web"; import webService from "@server/services/web";

View File

@@ -1,4 +1,3 @@
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { Event } from "@server/models"; import { Event } from "@server/models";
import webService from "@server/services/web"; import webService from "@server/services/web";

View File

@@ -1,4 +1,3 @@
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { IntegrationAuthentication, SearchQuery } from "@server/models"; import { IntegrationAuthentication, SearchQuery } from "@server/models";
import webService from "@server/services/web"; import webService from "@server/services/web";

View File

@@ -1,4 +1,3 @@
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import webService from "@server/services/web"; import webService from "@server/services/web";
import { flushdb } from "@server/test/support"; import { flushdb } from "@server/test/support";

View File

@@ -1,4 +1,3 @@
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import webService from "@server/services/web"; import webService from "@server/services/web";
import { import {

View File

@@ -1,4 +1,3 @@
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import webService from "@server/services/web"; import webService from "@server/services/web";
import { flushdb, seed } from "@server/test/support"; import { flushdb, seed } from "@server/test/support";

View File

@@ -1,4 +1,3 @@
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { Revision } from "@server/models"; import { Revision } from "@server/models";
import webService from "@server/services/web"; import webService from "@server/services/web";

View File

@@ -1,4 +1,3 @@
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { CollectionUser } from "@server/models"; import { CollectionUser } from "@server/models";
import webService from "@server/services/web"; import webService from "@server/services/web";

View File

@@ -1,4 +1,3 @@
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import webService from "@server/services/web"; import webService from "@server/services/web";
import { flushdb, seed } from "@server/test/support"; import { flushdb, seed } from "@server/test/support";

View File

@@ -1,4 +1,3 @@
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import webService from "@server/services/web"; import webService from "@server/services/web";
import { buildTeam, buildAdmin, buildUser } from "@server/test/factories"; import { buildTeam, buildAdmin, buildUser } from "@server/test/factories";

View File

@@ -1,5 +1,4 @@
import { subDays } from "date-fns"; import { subDays } from "date-fns";
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { Document, FileOperation } from "@server/models"; import { Document, FileOperation } from "@server/models";
import webService from "@server/services/web"; import webService from "@server/services/web";

View File

@@ -1,4 +1,3 @@
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { View, CollectionUser } from "@server/models"; import { View, CollectionUser } from "@server/models";
import webService from "@server/services/web"; import webService from "@server/services/web";

View File

@@ -1,4 +1,3 @@
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import webService from "@server/services/web"; import webService from "@server/services/web";
import { buildUser, buildCollection } from "@server/test/factories"; import { buildUser, buildCollection } from "@server/test/factories";

View File

@@ -1,4 +1,3 @@
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import mailer from "@server/mailer"; import mailer from "@server/mailer";
import webService from "@server/services/web"; import webService from "@server/services/web";

View File

@@ -31,8 +31,7 @@ router.post("email", errorHandling(), async (ctx) => {
}); });
if (users.length) { if (users.length) {
// @ts-expect-error ts-migrate(7034) FIXME: Variable 'team' implicitly has type 'any' in some ... Remove this comment to see the full error message let team!: Team | null;
let team;
if (isCustomDomain(ctx.request.hostname)) { if (isCustomDomain(ctx.request.hostname)) {
team = await Team.scope("withAuthenticationProviders").findOne({ team = await Team.scope("withAuthenticationProviders").findOne({
@@ -58,7 +57,6 @@ router.post("email", errorHandling(), async (ctx) => {
// If there are multiple users with this email address then give precedence // If there are multiple users with this email address then give precedence
// to the one that is active on this subdomain/domain (if any) // to the one that is active on this subdomain/domain (if any)
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'user' implicitly has an 'any' type.
let user = users.find((user) => team && user.teamId === team.id); let user = users.find((user) => team && user.teamId === team.id);
// A user was found for the email address, but they don't belong to the team // A user was found for the email address, but they don't belong to the team
@@ -132,8 +130,7 @@ router.get("email.callback", async (ctx) => {
assertPresent(token, "token is required"); assertPresent(token, "token is required");
try { try {
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'string | string[] | undefined' i... Remove this comment to see the full error message const user = await getUserForEmailSigninToken(token as string);
const user = await getUserForEmailSigninToken(token);
if (!user.team.guestSignin) { if (!user.team.guestSignin) {
return ctx.redirect("/?notice=auth-error"); return ctx.redirect("/?notice=auth-error");
@@ -153,6 +150,7 @@ router.get("email.callback", async (ctx) => {
await user.update({ await user.update({
lastActiveAt: new Date(), lastActiveAt: new Date(),
}); });
// set cookies on response and redirect to team subdomain // set cookies on response and redirect to team subdomain
await signIn(ctx, user, user.team, "email", false, false); await signIn(ctx, user, user.team, "email", false, false);
} catch (err) { } catch (err) {

View File

@@ -1,3 +1,4 @@
import Router from "koa-router";
import { signin } from "@shared/utils/routeHelpers"; import { signin } from "@shared/utils/routeHelpers";
import { requireDirectory } from "@server/utils/fs"; import { requireDirectory } from "@server/utils/fs";
@@ -6,7 +7,7 @@ interface AuthenicationProvider {
name: string; name: string;
enabled: boolean; enabled: boolean;
authUrl: string; authUrl: string;
router: any; router: Router;
} }
const providers: AuthenicationProvider[] = []; const providers: AuthenicationProvider[] = [];

View File

@@ -1,4 +1,3 @@
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'fetc... Remove this comment to see the full error message
import TestServer from "fetch-test-server"; import TestServer from "fetch-test-server";
import { buildShare, buildDocument } from "@server/test/factories"; import { buildShare, buildDocument } from "@server/test/factories";
import { flushdb } from "@server/test/support"; import { flushdb } from "@server/test/support";

View File

@@ -47,8 +47,7 @@ export default function init() {
name: event.name, name: event.name,
modelId: event.modelId, modelId: event.modelId,
}); });
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'error' implicitly has an 'any' type. processor.on(event).catch((error: Error) => {
processor.on(event).catch((error) => {
Logger.error( Logger.error(
`Error processing ${event.name} in ${event.service}`, `Error processing ${event.name} in ${event.service}`,
error, error,

View File

@@ -8,26 +8,14 @@ declare module "formidable/lib/file";
declare module "socket.io-client"; declare module "socket.io-client";
declare module "@tommoor/remove-markdown" {
export default function removeMarkdown(
text: string,
options?: {
stripHTML: boolean;
}
): string;
}
declare module "socket.io-redis" {
import { Redis } from "ioredis";
type Config = {
pubClient: Redis;
subClient: Redis;
};
const socketRedisAdapter: (config: Config) => void;
export = socketRedisAdapter;
}
declare module "oy-vey"; declare module "oy-vey";
declare module "fetch-test-server";
declare module "joplin-turndown-plugin-gfm" {
import { Plugin } from "turndown";
export const strikethrough: Plugin;
export const tables: Plugin;
}

12
server/typings/socketio-redis.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
declare module "socket.io-redis" {
import { Redis } from "ioredis";
type Config = {
pubClient: Redis;
subClient: Redis;
};
const socketRedisAdapter: (config: Config) => void;
export = socketRedisAdapter;
}

View File

@@ -0,0 +1,8 @@
declare module "@tommoor/remove-markdown" {
export default function removeMarkdown(
text: string,
options?: {
stripHTML: boolean;
}
): string;
}

View File

@@ -20,7 +20,6 @@ export default async function collectionIndexing(teamId: string) {
sortableCollections = naturalSort( sortableCollections = naturalSort(
sortableCollections, sortableCollections,
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type '(collection: any) => any' is not... Remove this comment to see the full error message
(collection) => collection[0].name (collection) => collection[0].name
); );

View File

@@ -8,8 +8,8 @@ export function getCookieDomain(domain: string) {
export function isCustomDomain(hostname: string) { export function isCustomDomain(hostname: string) {
const parsed = parseDomain(hostname); const parsed = parseDomain(hostname);
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'string | undefined' is not assig... Remove this comment to see the full error message
const main = parseDomain(process.env.URL); const main = parseDomain(process.env.URL);
return ( return (
parsed && main && (main.domain !== parsed.domain || main.tld !== parsed.tld) parsed && main && (main.domain !== parsed.domain || main.tld !== parsed.tld)
); );

View File

@@ -1,16 +1,14 @@
import { Node } from "prosemirror-model";
import { parser } from "rich-markdown-editor"; import { parser } from "rich-markdown-editor";
export default function parseDocumentIds(text: string): string[] { export default function parseDocumentIds(text: string): string[] {
const value = parser.parse(text); const value = parser.parse(text);
// @ts-expect-error ts-migrate(7034) FIXME: Variable 'links' implicitly has type 'any[]' in so... Remove this comment to see the full error message const links: string[] = [];
const links = [];
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'node' implicitly has an 'any' type. function findLinks(node: Node) {
function findLinks(node) {
// get text nodes // get text nodes
if (node.type.name === "text") { if (node.type.name === "text") {
// get marks for text nodes // get marks for text nodes
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'mark' implicitly has an 'any' type.
node.marks.forEach((mark) => { node.marks.forEach((mark) => {
// any of the marks links? // any of the marks links?
if (mark.type.name === "link") { if (mark.type.name === "link") {
@@ -22,7 +20,6 @@ export default function parseDocumentIds(text: string): string[] {
const lastToken = tokens[tokens.length - 1]; const lastToken = tokens[tokens.length - 1];
// don't return the same link more than once // don't return the same link more than once
// @ts-expect-error ts-migrate(7005) FIXME: Variable 'links' implicitly has an 'any[]' type.
if (!links.includes(lastToken)) { if (!links.includes(lastToken)) {
links.push(lastToken); links.push(lastToken);
} }
@@ -39,6 +36,5 @@ export default function parseDocumentIds(text: string): string[] {
} }
findLinks(value); findLinks(value);
// @ts-expect-error ts-migrate(7005) FIXME: Variable 'links' implicitly has an 'any[]' type.
return links; return links;
} }

View File

@@ -1,14 +1,12 @@
import { Node } from "prosemirror-model";
import { parser } from "rich-markdown-editor"; import { parser } from "rich-markdown-editor";
export default function parseImages(text: string): string[] { export default function parseImages(text: string): string[] {
const value = parser.parse(text); const value = parser.parse(text);
// @ts-expect-error ts-migrate(7034) FIXME: Variable 'images' implicitly has type 'any[]' in s... Remove this comment to see the full error message const images: string[] = [];
const images = [];
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'node' implicitly has an 'any' type. function findImages(node: Node) {
function findImages(node) {
if (node.type.name === "image") { if (node.type.name === "image") {
// @ts-expect-error ts-migrate(7005) FIXME: Variable 'images' implicitly has an 'any[]' type.
if (!images.includes(node.attrs.src)) { if (!images.includes(node.attrs.src)) {
images.push(node.attrs.src); images.push(node.attrs.src);
} }
@@ -24,6 +22,5 @@ export default function parseImages(text: string): string[] {
} }
findImages(value); findImages(value);
// @ts-expect-error ts-migrate(7005) FIXME: Variable 'images' implicitly has an 'any[]' type.
return images; return images;
} }

View File

@@ -15,8 +15,7 @@ describe("Miro", () => {
test("to extract the domain as part of the match for later use", () => { test("to extract the domain as part of the match for later use", () => {
expect( expect(
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'. "https://realtimeboard.com/app/board/o9J_k0fwiss=".match(match)?.[1]
"https://realtimeboard.com/app/board/o9J_k0fwiss=".match(match)[1]
).toBe("realtimeboard"); ).toBe("realtimeboard");
}); });

View File

@@ -98,10 +98,7 @@ describe("#parseDomain", () => {
}); });
it("should return null if the given value is not a string", () => { it("should return null if the given value is not a string", () => {
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'undefined' is not assignable to ... Remove this comment to see the full error message
expect(parseDomain(undefined)).toBe(null); expect(parseDomain(undefined)).toBe(null);
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type '{}' is not assignable to paramet... Remove this comment to see the full error message
expect(parseDomain({})).toBe(null);
expect(parseDomain("")).toBe(null); expect(parseDomain("")).toBe(null);
}); });

View File

@@ -9,9 +9,10 @@ type Domain = {
// we originally used the parse-domain npm module however this includes // we originally used the parse-domain npm module however this includes
// a large list of possible TLD's which increase the size of the bundle // a large list of possible TLD's which increase the size of the bundle
// unnecessarily for our usecase of trusted input. // unnecessarily for our usecase of trusted input.
export function parseDomain(url: string): Domain | null | undefined { export function parseDomain(url?: string): Domain | null | undefined {
if (typeof url !== "string") return null; if (typeof url !== "string") return null;
if (url === "") return null; if (url === "") return null;
// strip extermeties and whitespace from input // strip extermeties and whitespace from input
const normalizedDomain = trim(url.replace(/(https?:)?\/\//, "")); const normalizedDomain = trim(url.replace(/(https?:)?\/\//, ""));
const parts = normalizedDomain.split("."); const parts = normalizedDomain.split(".");

View File

@@ -38,7 +38,6 @@ describe("#naturalSort", () => {
name: "Mark", name: "Mark",
}, },
]; ];
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type '(item: any) => any' is not assig... Remove this comment to see the full error message
expect(naturalSort(items, (item) => item.name)).toEqual([ expect(naturalSort(items, (item) => item.name)).toEqual([
{ {
name: "Joan", name: "Joan",

View File

@@ -27,7 +27,7 @@ function getSortByField<T>(
function naturalSortBy<T>( function naturalSortBy<T>(
items: T[], items: T[],
key: string | (() => string), key: string | ((item: T) => string),
sortOptions?: NaturalSortOptions sortOptions?: NaturalSortOptions
): T[] { ): T[] {
if (!items) return []; if (!items) return [];

View File

@@ -1,6 +1,7 @@
import path from "path"; import path from "path";
// @ts-expect-error ts-migrate(2724) FIXME: '"jszip"' has no exported member named 'ZipObject'... Remove this comment to see the full error message import JSZip, { JSZipObject } from "jszip";
import JSZip, { ZipObject } from "jszip";
type ItemType = "collection" | "document" | "attachment";
export type Item = { export type Item = {
path: string; path: string;
@@ -8,9 +9,8 @@ export type Item = {
name: string; name: string;
depth: number; depth: number;
metadata: Record<string, any>; metadata: Record<string, any>;
type: "collection" | "document" | "attachment"; type: ItemType;
item: JSZipObject;
item: ZipObject;
}; };
export async function parseOutlineExport( export async function parseOutlineExport(
@@ -47,7 +47,7 @@ export async function parseOutlineExport(
); );
} }
let type; let type: ItemType | undefined;
if (depth === 0 && item.dir && name) { if (depth === 0 && item.dir && name) {
type = "collection"; type = "collection";
@@ -70,7 +70,6 @@ export async function parseOutlineExport(
dir, dir,
name, name,
depth, depth,
// @ts-expect-error ts-migrate(2322) FIXME: Type 'string' is not assignable to type '"collecti... Remove this comment to see the full error message
type, type,
metadata, metadata,
item, item,

View File

@@ -3170,10 +3170,10 @@
"@types/history" "*" "@types/history" "*"
"@types/react" "*" "@types/react" "*"
"@types/react-table@^7.7.8": "@types/react-table@^7.7.9":
version "7.7.8" version "7.7.9"
resolved "https://registry.yarnpkg.com/@types/react-table/-/react-table-7.7.8.tgz#b1aa5fb7a54432969262d2306b87fdbb9a5ee647" resolved "https://registry.yarnpkg.com/@types/react-table/-/react-table-7.7.9.tgz#ea82875775fc6ee71a28408dcc039396ae067c92"
integrity sha512-OMhbPlf+uUGte3M1WdArEKeBkyQ1XJxKvFYs+o1dGGGyaSVIqxPPQmBZ6Skkw0V9y0F/kOY7rnTD8r9GbfpBOg== integrity sha512-ejP/J20Zlj9VmuLh73YgYkW2xOSFTW39G43rPH93M4mYWdMmqv66lCCr+axZpkdtlNLGjvMG2CwzT4S6abaeGQ==
dependencies: dependencies:
"@types/react" "*" "@types/react" "*"