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
shu16mo ago
in expo
shu
shu16mo ago
shu
shu16mo ago
in nextjs
shu
shu16mo ago
shu
shu16mo 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
Liam16mo 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
shu16mo 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
Liam16mo 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
shu16mo 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
shu16mo ago
The AppRouter in utils/api.ts is throwing a type error
Want results from more Discord servers?
Add your server