Connect, collaborate, and grow with a community of TypeScript developers
Fix typescript and linter warnings/errors (#37)
Sean Boult31f12a2a5ee6
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex dea22804..523977cb 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -3,7 +3,9 @@ name: CIon: [ push, pull_request ]env:- DATABASE_URL: 'https://fake.com'+ DATABASE_URL: 'mysql://fake.com'+ GITHUB_ID: 'xd'+ GITHUB_SECRET: 'lmao'jobs:build:@@ -14,8 +16,25 @@ jobs:uses: actions/checkout@v2- uses: pnpm/action-setup@v2+ name: Install pnpm+ id: pnpm-installwith:version: 8+ run_install: false++ - name: Get pnpm store directory+ id: pnpm-cache+ shell: bash+ run: |+ echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT++ - uses: actions/cache@v3+ name: Setup pnpm cache+ with:+ path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}+ key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}+ restore-keys: |+ ${{ runner.os }}-pnpm-store-- name: Install Dependenciesrun: pnpm idiff --git a/src/app/explore/page.tsx b/src/app/explore/page.tsxindex f9a7395d..550f9847 100644--- a/src/app/explore/page.tsx+++ b/src/app/explore/page.tsx@@ -1,5 +1,6 @@import { Explore } from '~/components/explore';+export const dynamic = 'force-dynamic';export default function Page() {return <Explore />;}diff --git a/src/app/profile/page.tsx b/src/app/profile/page.tsxindex e7a0be86..cfa5ab5b 100644--- a/src/app/profile/page.tsx+++ b/src/app/profile/page.tsx@@ -1,6 +1,6 @@import Head from 'next/head';-export default async function Profile() {+export default function Profile() {return (<div><Head>diff --git a/src/components/challenge/editor/index.tsx b/src/components/challenge/editor/index.tsxindex 7ac1038c..02242093 100644--- a/src/components/challenge/editor/index.tsx+++ b/src/components/challenge/editor/index.tsx@@ -142,7 +142,7 @@ const onMount =}});- editor.getModel()?.onDidChangeContent(() => _runCommand());+ editor.getModel()?.onDidChangeContent(() => void _runCommand());monaco.languages.registerInlayHintsProvider('typescript',diff --git a/src/components/challenge/share-form.tsx b/src/components/challenge/share-form.tsxindex 045f9962..43347ca5 100644--- a/src/components/challenge/share-form.tsx+++ b/src/components/challenge/share-form.tsx@@ -4,16 +4,16 @@ import { Button } from '../ui/button';export function ShareForm() {const url = window.location.href;- const copyToClipboard = () => {+ const copyToClipboard = async (): Promise<void> => {if (navigator.clipboard) {- navigator.clipboard.writeText(url);+ await navigator.clipboard.writeText(url);}};return (<div>- <p>Copy this challenge url so to share with your friends!</p>- <Button className="ml-auto mt-4 block" onClick={copyToClipboard}>+ <p>Copy this challenge url to share with your friends!</p>+ <Button className="block ml-auto mt-4" onClick={() => void copyToClipboard}>Copy to Clipboard</Button></div>diff --git a/src/components/explore/difficulty-badge.tsx b/src/components/explore/difficulty-badge.tsxindex 366e831b..110340e2 100644--- a/src/components/explore/difficulty-badge.tsx+++ b/src/components/explore/difficulty-badge.tsx@@ -1,4 +1,4 @@-import { Difficulty } from '@prisma/client';+import { type Difficulty } from '@prisma/client';import { Badge } from '../ui/badge';interface Props {diff --git a/src/components/explore/explore-card-skeleton.tsx b/src/components/explore/explore-card-skeleton.tsxindex a6614db3..dafde909 100644--- a/src/components/explore/explore-card-skeleton.tsx+++ b/src/components/explore/explore-card-skeleton.tsx@@ -1,4 +1,4 @@-import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../ui/card';+import { Card, CardDescription, CardHeader, CardTitle } from '../ui/card';export function ExploreCardSkeleton() {return (diff --git a/src/components/explore/explore-card.tsx b/src/components/explore/explore-card.tsxindex b2bcb3b5..2cfd75c6 100644--- a/src/components/explore/explore-card.tsx+++ b/src/components/explore/explore-card.tsx@@ -1,6 +1,6 @@import { ArrowBigUp } from 'lucide-react';-import { Challenges } from '.';+import { type Challenges } from '.';import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '../ui/card';import { DifficultyBadge } from './difficulty-badge';@@ -46,29 +46,31 @@ const rtf = new Intl.RelativeTimeFormat('en', {});// TODO: typescript-const getRelativeTime = (date) => {+const getRelativeTime = (date: Date) => {const now = new Date();+ // @ts-ignoreconst elapsed = date - now;// "Math.abs" accounts for both "past" & "future" scenariosfor (const u in units)+ // @ts-ignoreif (Math.abs(elapsed) > units[u] || u == 'second')+ // @ts-ignorereturn rtf.format(Math.round(elapsed / units[u]), u);};export function ExploreCard({ challenge }: Props) {return (<Card- className={`group duration-300 hover:bg-card-hovered group-focus:bg-card-hovered ${- SHADOWS_BY_DIFFICULTY[challenge.difficulty]- } ${BORDERS_BY_DIFFICULTY[challenge.difficulty]}`}+ className={`group duration-300 hover:bg-card-hovered group-focus:bg-card-hovered ${SHADOWS_BY_DIFFICULTY[challenge.difficulty]+ } ${BORDERS_BY_DIFFICULTY[challenge.difficulty]}`}><CardHeader className="grid items-start gap-4 space-y-0"><div className="space-y-1"><CardTitle>{challenge.name}</CardTitle><CardDescription className="relative h-48 overflow-hidden pb-4"><div className="pointer-events-none absolute inset-0 h-full w-full shadow-[inset_0_-1.5rem_1rem_-0.5rem_hsl(var(--card))] duration-300 group-hover:shadow-[inset_0_-1.5rem_1rem_-0.5rem_hsl(var(--card-hovered))] group-focus:shadow-[inset_0_-1.5rem_1rem_-0.5rem_hsl(var(--card-hovered))]" />- {challenge.description}+ {challenge.description?.toString()}</CardDescription></div></CardHeader>diff --git a/src/components/user/profile.tsx b/src/components/user/profile.tsxindex 15c652ee..51fa6629 100644--- a/src/components/user/profile.tsx+++ b/src/components/user/profile.tsx@@ -1,5 +1,6 @@import { notFound } from 'next/navigation';import { prisma } from '~/server/db';+import Image from 'next/image';interface Props {username: string;@@ -21,7 +22,7 @@ export async function Profile({ username: usernameFromQuery }: Props) {return (<><h1>{user.id}</h1>- <img src={user.image ?? ''} />+ <Image alt="user avatar" src={user.image ?? ''} /><p>{user.email}</p>diff --git a/src/server/api/trpc.ts b/src/server/api/trpc.tsindex 680e7919..da8548e5 100644--- a/src/server/api/trpc.ts+++ b/src/server/api/trpc.ts@@ -9,7 +9,6 @@import { initTRPC, TRPCError } from '@trpc/server';import { type CreateNextContextOptions } from '@trpc/server/adapters/next';-import { type Session } from 'next-auth';import superjson from 'superjson';import { ZodError } from 'zod';import { getServerAuthSession } from '~/server/auth';diff --git a/src/utils/redirectIf.ts b/src/utils/redirectIf.tsdeleted file mode 100644index 8bffc09a..00000000--- a/src/utils/redirectIf.ts+++ /dev/null@@ -1,57 +0,0 @@-import type { GetServerSidePropsContext } from 'next';-import { getSession } from 'next-auth/react';--interface RedirectIfOptions {- unauthenticated?: boolean;- is?: UserType;- not?: UserType;-}--export const redirectIf =- (conditions: RedirectIfOptions, redirect: string = '/home') =>- async (ctx: GetServerSidePropsContext) => {- const session = await getSession(ctx);-- if (conditions.unauthenticated) {- // if (fullSession) {- // return {- // redirect: {- // destination: redirect,- // permanent: false,- // },- // };- // }- } else if (!fullSession) {- // return {- // redirect: {- // destination: `/auth/signin?redirect=${encodeURIComponent(ctx.resolvedUrl)}`,- // permanent: false,- // },- // };- }-- if (- (conditions.is && session?.user?.type === conditions.is) ||- (conditions.not && session?.user.type !== conditions.not)- ) {- return {- redirect: {- destination: redirect,- permanent: false,- },- };- }-- return {- props: {},- };- };--export const authenticatedRoute = redirectIf({});-export const unauthenticatedRoute = redirectIf({ unauthenticated: true });--export const creatorRoute = redirectIf({ not: UserType.CREATOR }, '/creator/apply');--export const creatorPendingRoute = redirectIf({ not: UserType.CREATOR_PENDING }, '/creator');--export const nonCreatorRoute = redirectIf({ is: UserType.CREATOR }, '/creator');