tRPC losing types on t3-turbo

I'm trying the t3 turbo repo, trpc loses type defs out of nowhere on nextjs, types work fine on expo, has anyone else experienced this? im not sure what information im suppose to give cause i have no idea what is even causing this. Thanks for any help. Using the latest version of t3-turbo
10 Replies
shu
shuOP2y ago
in expo
shu
shuOP2y ago
shu
shuOP2y ago
in nextjs
shu
shuOP2y ago
shu
shuOP2y ago
auth router
import bcrypt from "bcryptjs";
import { z } from "zod";

import { createTRPCRouter, protectedProcedure, publicProcedure } from "../trpc";

export const authRouter = createTRPCRouter({
getSession: publicProcedure.query(({ ctx }) => {
return ctx.session;
}),

register: publicProcedure.input(z.object({ email: z.string(), password: z.string() })).mutation(async ({ ctx, input }) => {
const user = await ctx.prisma.user.findUnique({ where: { email: input.email } });

if (user) {
return null;
}

const salt = bcrypt.genSaltSync(10);
const hashedPassword = bcrypt.hashSync(input.password, salt);

return ctx.prisma.user.create({ data: { email: input.email, password: hashedPassword } });
}),

authorize: publicProcedure.input(z.object({ email: z.string(), password: z.string() })).mutation(async ({ ctx, input }) => {
const user: { email: string, password: string} | null = await ctx.prisma.user.findUnique({ where: { email: input.email } });

if (!user) {
return null;
}

const auth = bcrypt.compareSync(input.password, user.password);

if (auth) {
return user;
} else {
return null;
}
}),
});
import bcrypt from "bcryptjs";
import { z } from "zod";

import { createTRPCRouter, protectedProcedure, publicProcedure } from "../trpc";

export const authRouter = createTRPCRouter({
getSession: publicProcedure.query(({ ctx }) => {
return ctx.session;
}),

register: publicProcedure.input(z.object({ email: z.string(), password: z.string() })).mutation(async ({ ctx, input }) => {
const user = await ctx.prisma.user.findUnique({ where: { email: input.email } });

if (user) {
return null;
}

const salt = bcrypt.genSaltSync(10);
const hashedPassword = bcrypt.hashSync(input.password, salt);

return ctx.prisma.user.create({ data: { email: input.email, password: hashedPassword } });
}),

authorize: publicProcedure.input(z.object({ email: z.string(), password: z.string() })).mutation(async ({ ctx, input }) => {
const user: { email: string, password: string} | null = await ctx.prisma.user.findUnique({ where: { email: input.email } });

if (!user) {
return null;
}

const auth = bcrypt.compareSync(input.password, user.password);

if (auth) {
return user;
} else {
return null;
}
}),
});
Liam
Liam2y ago
Some basic stuff that might help is making sure your typescript version is up to date and then try restarting the TS server using the vscode command pallete.
shu
shuOP2y ago
I did get a notification from vscode asking about the typescript version, that might be something...i tried restarting the TS server multiple times, and even restarting vscode altogether did not change anything
Liam
Liam2y ago
Make sure you are using the projects version, not a globally installed one. You can do this through the command palette too. iirc its something like "select workspace TS version" or something.
shu
shuOP2y ago
Just checked it out, both workspace and global ts version is the same (5.0.4), tried using the workspace version and restarting tsserver and vscode but its still the same...
shu
shuOP2y ago
The AppRouter in utils/api.ts is throwing a type error
Want results from more Discord servers?
Add your server