⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
Fix some any types
Isaac Wise0b8a9b431046
diff --git a/components/CollectionListing.tsx b/components/CollectionListing.tsxindex b26e8cf4..1e14b8f9 100644--- a/components/CollectionListing.tsx+++ b/components/CollectionListing.tsx@@ -232,8 +232,8 @@ const renderItem = (<div ref={provided.innerRef} {...provided.draggableProps} className="mb-1"><divclassName={`${currentPath === `/collections/${collection.id}`- ? "bg-primary/20 is-active"- : "hover:bg-neutral/20"+ ? "bg-primary/20 is-active"+ : "hover:bg-neutral/20"} duration-100 flex gap-1 items-center pr-2 pl-1 rounded-md`}>{Icon(item as ExtendedTreeItem, onExpand, onCollapse)}diff --git a/components/InputSelect/CollectionSelection.tsx b/components/InputSelect/CollectionSelection.tsxindex 99b999e3..37899ee3 100644--- a/components/InputSelect/CollectionSelection.tsx+++ b/components/InputSelect/CollectionSelection.tsx@@ -4,17 +4,17 @@ import { useEffect, useState } from "react";import { styles } from "./styles";import { Options } from "./types";import CreatableSelect from "react-select/creatable";-import Select from "react-select";+import Select, { ActionMeta } from "react-select";type Props = {- onChange: any;+ onChange: (newValue: unknown, actionMeta: ActionMeta<unknown>) => void;showDefaultValue?: boolean;defaultValue?:- | {- label: string;- value?: number;- }- | undefined;+ | {+ label: string;+ value?: number;+ }+ | undefined;creatable?: boolean;};@@ -107,7 +107,7 @@ export default function CollectionSelection({components={{Option: customOption,}}- // menuPosition="fixed"+ // menuPosition="fixed"/>);} else {@@ -123,7 +123,7 @@ export default function CollectionSelection({components={{Option: customOption,}}- // menuPosition="fixed"+ // menuPosition="fixed"/>);}diff --git a/components/InputSelect/TagSelection.tsx b/components/InputSelect/TagSelection.tsxindex d901b404..104e92b8 100644--- a/components/InputSelect/TagSelection.tsx+++ b/components/InputSelect/TagSelection.tsx@@ -3,9 +3,10 @@ import { useEffect, useState } from "react";import CreatableSelect from "react-select/creatable";import { styles } from "./styles";import { Options } from "./types";+import { ActionMeta } from "react-select";type Props = {- onChange: any;+ onChange: (newValue: unknown, actionMeta: ActionMeta<unknown>) => void;defaultValue?: {value: number;label: string;diff --git a/components/LinkViews/LinkCard.tsx b/components/LinkViews/LinkCard.tsxindex 70f553c9..ba052c2f 100644--- a/components/LinkViews/LinkCard.tsx+++ b/components/LinkViews/LinkCard.tsx@@ -85,7 +85,7 @@ export default function LinkCard({ link, flipDropdown, editMode }: Props) {const permissions = usePermissions(collection?.id as number);useEffect(() => {- let interval: any;+ let interval: NodeJS.Timeout | null = null;if (isVisible &&diff --git a/components/LinkViews/LinkMasonry.tsx b/components/LinkViews/LinkMasonry.tsxindex 022ac938..335e061e 100644--- a/components/LinkViews/LinkMasonry.tsx+++ b/components/LinkViews/LinkMasonry.tsx@@ -84,7 +84,7 @@ export default function LinkMasonry({ link, flipDropdown, editMode }: Props) {const permissions = usePermissions(collection?.id as number);useEffect(() => {- let interval: any;+ let interval: NodeJS.Timeout | null = null;if (isVisible &&diff --git a/components/ModalContent/PreservedFormatsModal.tsx b/components/ModalContent/PreservedFormatsModal.tsxindex 4414b379..58a71ba4 100644--- a/components/ModalContent/PreservedFormatsModal.tsx+++ b/components/ModalContent/PreservedFormatsModal.tsx@@ -104,7 +104,7 @@ export default function PreservedFormatsModal({ onClose, activeLink }: Props) {);})();- let interval: any;+ let interval: NodeJS.Timeout | null = null;if (!isReady()) {interval = setInterval(async () => {diff --git a/components/PreserverdFormatRow.tsx b/components/PreserverdFormatRow.tsxindex e28d43dd..d35bfe65 100644--- a/components/PreserverdFormatRow.tsx+++ b/components/PreserverdFormatRow.tsx@@ -4,10 +4,8 @@ import {ArchivedFormat,LinkIncludingShortenedCollectionAndTags,} from "@/types/global";-import toast from "react-hot-toast";import Link from "next/link";import { useRouter } from "next/router";-import { useSession } from "next-auth/react";type Props = {name: string;@@ -24,7 +22,6 @@ export default function PreservedFormatRow({activeLink,downloadable,}: Props) {- const session = useSession();const { getLink } = useLinkStore();const [link, setLink] =@@ -36,19 +33,15 @@ export default function PreservedFormatRow({useEffect(() => {(async () => {- const data = await getLink(link.id as number, isPublic);- setLink(- (data as any).response as LinkIncludingShortenedCollectionAndTags- );+ const { data } = await getLink(link.id as number, isPublic);+ setLink(data as LinkIncludingShortenedCollectionAndTags);})();- let interval: any;+ let interval: NodeJS.Timeout | null = null;if (link?.image === "pending" || link?.pdf === "pending") {interval = setInterval(async () => {- const data = await getLink(link.id as number, isPublic);- setLink(- (data as any).response as LinkIncludingShortenedCollectionAndTags- );+ const { data } = await getLink(link.id as number, isPublic);+ setLink(data as LinkIncludingShortenedCollectionAndTags);}, 5000);} else {if (interval) {diff --git a/components/ReadableView.tsx b/components/ReadableView.tsxindex b862b383..7b827a27 100644--- a/components/ReadableView.tsx+++ b/components/ReadableView.tsx@@ -75,7 +75,7 @@ export default function ReadableView({ link }: Props) {useEffect(() => {if (link) getLink(link?.id as number);- let interval: any;+ let interval: NodeJS.Timeout | null = null;if (link &&(link?.image === "pending" ||diff --git a/e2e/data/user.ts b/e2e/data/user.tsindex 3ae0b73e..cc155ae9 100644--- a/e2e/data/user.ts+++ b/e2e/data/user.ts@@ -2,19 +2,17 @@ import axios, { AxiosError } from "axios"axios.defaults.baseURL = "http://localhost:3000"-export async function seedUser (username?: string, password?: string, name?: string) {+export async function seedUser(username?: string, password?: string, name?: string) {try {return await axios.post("/api/v1/users", {username: username || "test",password: password || "password",name: name || "Test User",})- } catch (e: any) {- if (e instanceof AxiosError) {- if (e.response?.status === 400) {- return- }- }- throw e+ } catch (error) {+ const axiosError = error as AxiosError;+ if (axiosError && axiosError.response?.status === 400) return++ throw error}}\ No newline at end of filediff --git a/lib/api/controllers/dashboard/getDashboardData.ts b/lib/api/controllers/dashboard/getDashboardData.tsindex 3b0f7517..8e19ae3b 100644--- a/lib/api/controllers/dashboard/getDashboardData.ts+++ b/lib/api/controllers/dashboard/getDashboardData.ts@@ -1,11 +1,11 @@import { prisma } from "@/lib/api/db";-import { LinkRequestQuery, Sort } from "@/types/global";+import { LinkRequestQuery, Order, Sort } from "@/types/global";export default async function getDashboardData(userId: number,query: LinkRequestQuery) {- let order: any;+ let order: Order = { id: "desc" };if (query.sort === Sort.DateNewestFirst) order = { id: "desc" };else if (query.sort === Sort.DateOldestFirst) order = { id: "asc" };else if (query.sort === Sort.NameAZ) order = { name: "asc" };diff --git a/lib/api/controllers/dashboard/getDashboardDataV2.ts b/lib/api/controllers/dashboard/getDashboardDataV2.tsindex 6d2fb027..ef58be4c 100644--- a/lib/api/controllers/dashboard/getDashboardDataV2.ts+++ b/lib/api/controllers/dashboard/getDashboardDataV2.ts@@ -1,23 +1,23 @@import { prisma } from "@/lib/api/db";-import { LinkRequestQuery, Sort } from "@/types/global";+import { LinkRequestQuery, Order, Sort } from "@/types/global";type Response<D> =| {- data: D;- message: string;- status: number;- }+ data: D;+ message: string;+ status: number;+ }| {- data: D;- message: string;- status: number;- };+ data: D;+ message: string;+ status: number;+ };export default async function getDashboardData(userId: number,query: LinkRequestQuery): Promise<Response<any>> {- let order: any;+ let order: Order = { id: "desc" };if (query.sort === Sort.DateNewestFirst) order = { id: "desc" };else if (query.sort === Sort.DateOldestFirst) order = { id: "asc" };else if (query.sort === Sort.NameAZ) order = { name: "asc" };diff --git a/lib/api/controllers/links/getLinks.ts b/lib/api/controllers/links/getLinks.tsindex 561c9198..0427ba59 100644--- a/lib/api/controllers/links/getLinks.ts+++ b/lib/api/controllers/links/getLinks.ts@@ -1,11 +1,11 @@import { prisma } from "@/lib/api/db";-import { LinkRequestQuery, Sort } from "@/types/global";+import { LinkRequestQuery, Order, Sort } from "@/types/global";export default async function getLink(userId: number, query: LinkRequestQuery) {const POSTGRES_IS_ENABLED =process.env.DATABASE_URL?.startsWith("postgresql");- let order: any;+ let order: Order = { id: "desc" };if (query.sort === Sort.DateNewestFirst) order = { id: "desc" };else if (query.sort === Sort.DateOldestFirst) order = { id: "asc" };else if (query.sort === Sort.NameAZ) order = { name: "asc" };diff --git a/lib/api/controllers/public/links/getPublicLinksUnderCollection.ts b/lib/api/controllers/public/links/getPublicLinksUnderCollection.tsindex d93e804d..b03de3a0 100644--- a/lib/api/controllers/public/links/getPublicLinksUnderCollection.ts+++ b/lib/api/controllers/public/links/getPublicLinksUnderCollection.ts@@ -1,5 +1,5 @@import { prisma } from "@/lib/api/db";-import { LinkRequestQuery, Sort } from "@/types/global";+import { LinkRequestQuery, Order, Sort } from "@/types/global";export default async function getLink(query: Omit<LinkRequestQuery, "tagId" | "pinnedOnly">@@ -7,7 +7,7 @@ export default async function getLink(const POSTGRES_IS_ENABLED =process.env.DATABASE_URL?.startsWith("postgresql");- let order: any;+ let order: Order = { id: "desc" };if (query.sort === Sort.DateNewestFirst) order = { id: "desc" };else if (query.sort === Sort.DateOldestFirst) order = { id: "asc" };else if (query.sort === Sort.NameAZ) order = { name: "asc" };diff --git a/lib/client/utils.ts b/lib/client/utils.tsindex e0679333..010372c0 100644--- a/lib/client/utils.ts+++ b/lib/client/utils.ts@@ -7,10 +7,10 @@ export function isPWA() {}export function isIphone() {- return /iPhone/.test(navigator.userAgent) && !(window as any).MSStream;+ return /iPhone/.test(navigator.userAgent) && !(window as unknown as { MSStream?: any }).MSStream;}-export function dropdownTriggerer(e: any) {+export function dropdownTriggerer(e: React.FocusEvent<HTMLElement> | React.MouseEvent<HTMLElement>) {let targetEl = e.currentTarget;if (targetEl && targetEl.matches(":focus")) {setTimeout(function () {diff --git a/lib/shared/getArchiveValidity.ts b/lib/shared/getArchiveValidity.tsindex 8ec8c447..fdf04574 100644--- a/lib/shared/getArchiveValidity.ts+++ b/lib/shared/getArchiveValidity.ts@@ -39,7 +39,7 @@ export function monolithAvailable();}-export function previewAvailable(link: any) {+export function previewAvailable(link: LinkIncludingShortenedCollectionAndTags) {return (link &&link.preview &&diff --git a/types/global.ts b/types/global.tsindex 90c9aef6..3f5cae0d 100644--- a/types/global.ts+++ b/types/global.ts@@ -81,6 +81,8 @@ export enum Sort {DescriptionZA,}+export type Order = { [key: string]: 'asc' | 'desc' };+export type LinkRequestQuery = {sort: Sort;cursor?: number;