Theo's Typesafe Cult

TTC

Theo's Typesafe Cult

Join the community to ask questions about Theo's Typesafe Cult and get answers from other members.

Join

useQuery with useState

hey all!, my question is how to optimize the useQuery search because now whenever the input changes the state changes and the useQuery refires but that too much load on the server in my opinion. what is the best approach to this kind of situation ?

Decimal in Prisma

Has anyone dealt with Decimal in Prisma? I am having issues with it when I retrieve results and try to display it in a react component.

How to add routing to a Vite VanillaJS app?

Is there a way to have native (i.e. without js) routing in a VanillaJS Vite app? I just want to have an index.html which contains <a href=/about> that links to about.html. I could do it with JS but I really want to keep native routing....

Type 'ZodObject{ id ZodNumber; first_name ... missing but required in _procedure

So im trying to pass the logic I had on my Nest + Prisma + GraphQL to the ct3 stack and im a beginner with trpc which makes it even more exciting! The objective of my web application is to have a system where users can manage their workout and meal plans and, in case they dont have no idea of what they are doing, give them plan suggestions based on their weight, daily activity, etc. I installed the package zod-prisma so i dont have to write everything by hand. So based on my Prisma model i have ```ts...

How to implement cursor-based infinite scrolling with prisma + useInfinitequery

How to implement cursor based infinite scrolling in this scenario? Imagine I have this schema: ```typescript model MockUser {...

useMutation invalidation fails

```const { mutate: updateUserData } = trpc.userInfo.updateUserInfo.useMutation({ async onMutate(newUserData) { // Cancel any outgoing refetches (so they don't overwrite our optimistic update) utils.userInfo.getCurrentUser.cancel(); const previousUserData = utils.userInfo.getCurrentUser.getData();...

trpc.user.getUser.useQuery

Does anyone know how to call onSuccess using the above wrapper of useQuery?

Conditional rendering on TS type

Hey everyone, I have a timeline that has multiple types coming over the wire in a list, and I need to render different ones depending on the type that it is. I seem to be getting an error on this, but not entirely sure how to correct. I tried using a comparison on typeof, but because that's comparing strings, it doesn't recognise that it's actually acting to guard the type. the TimelineUpdate type just requires a WrittenUpdate and as it's type, and the WrittenUpdate type is imported from @prisma/client at the top of this file Thanks 🙏...

Best state management for react chrome extensions?

Im looking into making a chrome extension. It will be handling a somewhat complex state, shared between background scripts, and the popup UI for the user. So my question is, how do i handle shared typesafe and persisting state across script in a chrome extension? Can't seem to find any good resources on this. ...

useQuery error

```const { data: user, isError } = trpc.userInfo.getUser.useQuery( [reactQueryKeys.currentUser], { onSuccess: (data) => { console.log("sadfdfhhsdf");...

how to delete user (next-auth)

Doesn't seem like next-auth provides a delete user method at the moment. Right now, I'm just deleting the user in the User table and the Account and Sessions cascade delete. I'm wondering though, from the Oauth account end, say someone's Gmail account, is there anything that needs to be done there to revoke permissions?

Passing URL Params to TRPC causes Error on First Render, as URL-Param is undefined

I am not sure if I am missing something, but I can't get this to work. I am getting some id passed down in my url params, and I want to pass down that id to trpc, to fetch some data from my database: ``` const Home: NextPage = () => { const router = useRouter()...

tRPC Input from a Prisma Schema

Is there any way to tell tRPC (zod technically i guess) to expect a tRPC schema as a type? like procedure.input({myType: z.tRPC(myType)}).query() or something...

ts, mjs, js

When do I use which file extensions?

Git rebase workflow

Hi all, Company is looking at adopting a more structured git workflow. One method we are looking at is creating local branches for development and then rebasing on main. One downside that was brought up was that since our feature branches would be local we can't have any collaboration with them (not a big deal imo) and that it makes transferring our work from different workstations difficult (this one is a big deal). If we want to adopt a rebasing strategy, what is the recommended approach for collaboration?...

Zustand with typescript

I honestly do not know what is wrong in here.

Re fetch an enabled tRPC query.

Hi, im running into an issue where I want to refetch a query that lists all users when a new user is added, but it only refetches when the query is disabled. this is some code I have for it. ```javascript //Queries const createInvestor = trpc.admin.investors.createOne.useMutation();...

adding typescript to a vite setup in progress

I have this project started with vite and after two moths of working with it, I finally realised that I really need typescript. the problem is I can get vite to recognise typescript....

Deploying the t3-App on Vercel

I'm having a t3-app with the database hosted on planetscale and the app on vercel. Everything works well on the dev server but I cant make the connection to the db once I deploy it to vercel. I have mysql as my provider, and relationMode set to prisma. I have added the env variables on the .env file and on vercel dashboard. However once I deploy it to vercel I'm getting this error on the web console.

Adapt create t3 for mobile backend app?

Im building a fitness application right now with nest, prisma and graphql for my backend. Ive gotten highly interested in changing my code for this specific one. Im just wondering, i also want to adapt my endpoints to a mobile app in the future, ill think if i go native code or not. From what i see in the code, this is not possible to do with create t3, right ? Since there aren't declared endpoins ? I saw tcrp can be extended to have declarative rest endpoints, but would this still be a good solution if one was thinking about building a mobile version of the web app in the future? Would a mobile app be able to consume the server part of this mono repo ?...