Skip to content

Commit

Permalink
remove a lot of ts-ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
heybereket committed May 29, 2023
1 parent ca294c7 commit c2a480a
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 37 deletions.
20 changes: 7 additions & 13 deletions components/modals/EditProfileModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,13 @@ const ModalBody = (props: {
avatar: string;
}) => {
const { data: session } = useSession();
// @ts-ignore
const [username, setUsername] = useState<string>(session?.user?.username);
const [username, setUsername] = useState<string>(session?.user?.username as string);
const [displayName, setDisplayName] = useState<string>(
session?.user?.name as string
);
const [avatarURL, setAvatarURL] = useState<string>();
const [teamNumber, setTeamNumber] = useState<string>(
// @ts-ignore
session?.user?.teamNumber as string
session?.user.teamNumber as string
);
const [errorMessage, setErrorMessage] = useState<string>();
const [deletedHover, setDeletedHover] = useState(false);
Expand All @@ -107,15 +105,11 @@ const ModalBody = (props: {
};

const updateInfo = async (): Promise<void> => {
//@ts-ignore
const existingUsername = session.user?.username;
//@ts-ignore
const existingDisplayName: string | null | undefined = session.user?.name;
//@ts-ignore
const existingAvatarURL: string | null | undefined = session.user?.image;
const existingTeamNumber: string | null | undefined =
//@ts-ignore
session.user?.teamNumber;
const existingUsername = session?.user.username;
const existingDisplayName: string | null | undefined = session?.user.name;
const existingAvatarURL: string | null | undefined = session?.user.image;
const existingTeamNumber: string | number | null | undefined =
session?.user.teamNumber;

if (!username || !displayName || !avatarURL) {
return setErrorMessage("Fields left blank");
Expand Down
1 change: 0 additions & 1 deletion lib/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ type GlobalThisWithPrismaClient = typeof globalThis & {
[prismaClientPropertyName]: PrismaClient;
};

// @ts-ignore
const getPrismaClient = (): PrismaClient<
Prisma.PrismaClientOptions,
Prisma.GetEvents<Prisma.LogLevel | Prisma.LogDefinition>,
Expand Down
1 change: 0 additions & 1 deletion pages/api/@me/apiKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default async function handler(
const apiKey = await db.apiKey.create({
data: {
key: key,
// @ts-ignore
userId: session.user.id,
},
});
Expand Down
6 changes: 2 additions & 4 deletions pages/api/@me/favourites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export default async function getUserFavourites(
const data: (User & { favouritedTeams: FavouritedTeam[] }) | null =
await db.user.findUnique({
where: {
// @ts-ignore
id: session?.user?.id,
},
include: {
Expand All @@ -40,7 +39,7 @@ export default async function getUserFavourites(
const existingTeam = await db.favouritedTeam.findUnique({
where: {
// @ts-ignore
userId: session?.user.id,
userId: session.user.id,
team_number: body.team_number,
},
});
Expand All @@ -50,8 +49,7 @@ export default async function getUserFavourites(
} else {
const data: FavouritedTeam = await db.favouritedTeam.create({
data: {
// @ts-ignore
userId: session?.user.id,
userId: session.user.id,
team_number: body.team_number,
nickname: body.nickname,
city: body.city,
Expand Down
4 changes: 1 addition & 3 deletions pages/api/@me/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ export default async function getUserData(
if (req.method === "GET") {
const me: User | null = await db.user.findUnique({
where: {
// @ts-ignore
id: session.user?.id,
id: session.user.id,
},
});

Expand All @@ -29,7 +28,6 @@ export default async function getUserData(
if (req.method === "DELETE") {
await db.user.delete({
where: {
// @ts-ignore
id: session.user?.id,
},
});
Expand Down
1 change: 0 additions & 1 deletion pages/api/@me/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default async function marketplaceAPI(

const post: Post = await db.post.create({
data: {
// @ts-ignore
authorId: session.user?.id,
title: body.title,
content: body.content,
Expand Down
3 changes: 1 addition & 2 deletions pages/api/@me/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ export default async function UpdateUser(

await db.user.update({
where: {
// @ts-ignore
id: session.user?.id,
id: session.user.id,
},
data: {
...body,
Expand Down
1 change: 0 additions & 1 deletion pages/api/admin/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default async function getDistricts(
authOptions
)) as Session;

// @ts-ignore
if (!session.user.admin) res.status(200).send("You can't run this action!");

switch (table) {
Expand Down
6 changes: 2 additions & 4 deletions pages/api/teams/socials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export default async function addSocials(
type: social.type,
handle: social.handle,
teamId: Number(team),
// @ts-ignore
userId: session.user?.id,
userId: session.user.id,
},
});
})
Expand All @@ -55,8 +54,7 @@ export default async function addSocials(
type: social.type,
handle: social.handle,
teamId: Number(team),
// @ts-ignore
userId: session.user?.id,
userId: session.user.id,
},
});
})
Expand Down
3 changes: 1 addition & 2 deletions pages/event/[event]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ export default function EventsPage({
{activeTab === 5 && (
<TeamsTab
teams={eventTeams}
// @ts-ignore
favourites={user?.favouritedTeams}
/>
)}
Expand Down Expand Up @@ -167,7 +166,7 @@ export const getServerSideProps: GetServerSideProps = async (
},
include: {
favouritedTeams: true,
}
},
});

return {
Expand Down
1 change: 0 additions & 1 deletion pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export const getServerSideProps: GetServerSideProps = async ({
})
| null = await db.user.findUnique({
where: {
// @ts-ignore
id: session.user.id,
},
include: {
Expand Down
3 changes: 1 addition & 2 deletions pages/marketplace/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ export const getServerSideProps: GetServerSideProps = async ({
if (session) {
user = await db.user.findUnique({
where: {
// @ts-ignore
id: session.user?.id,
id: session.user.id,
},
});
}
Expand Down
1 change: 0 additions & 1 deletion pages/rookies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ export const getServerSideProps: GetServerSideProps = async ({
const user: (User & { favouritedTeams: FavouritedTeam[] }) | null =
await db.user.findUnique({
where: {
// @ts-ignore
id: session.user.id,
},
include: {
Expand Down
1 change: 0 additions & 1 deletion pages/teams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ export const getServerSideProps: GetServerSideProps = async ({
const user: (User & { favouritedTeams: FavouritedTeam[] }) | null =
await db.user.findUnique({
where: {
// @ts-ignore
id: session.user.id,
},
include: {
Expand Down
2 changes: 2 additions & 0 deletions types/next-auth.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ declare module "next-auth" {

interface ScoutMachineUser extends User {
username: string;
admin: boolean;
teamNumber: number | string | null | undefined;
}
}

1 comment on commit c2a480a

@vercel
Copy link

@vercel vercel bot commented on c2a480a May 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.