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

UploadDropzone - dragging items from the same page

Salut fellas, Recently I go into UploadDropzone component and I wanted to test it out, however, in my scenario it doesn't really work everywhere. What I am trying to achieve:...

Tailwind .ts config file intellisense not working

When I have tailwind.config.ts from the default t3 create, even with the right extensions installed the intellisense isn't working. There are actually typescript linting errors in the file like saying the import isnt used. Has anyone found a fix to this? I've fixed this by switching the .ts config to a .cjs one

question about public and private procedures in trPC

so in the create-t3-app template there is this comment before the publicprocedures ``` This is the base piece you use to build new queries and mutations on your tRPC API. It does not * guarantee that a user querying is authorized, but you can still access user session data if they...

Can someone explain to me some basic concepts? Eli5

So it seems there are three ways to do data fetching. I am asking about the pages/ dir but I think everything applies to the app/ dir - fetch data in the page itself (getServerSideProps) - Making API routes and then using the api routes in my page - tRPC...

need help with keepPreviousData in trpc client / tanstack query

API call: ``` const [userToFind, setUserToFind] = useState(""); const { data: foundUsers, // array of objects...
Solution:
That is the preferred solution for now, keeping the previous data in a state as you are doing

headless cms to use with t3 stack?

I am writing an e-commerce project and not sure what is the best way to go about it and what to use as a cms that would be intuitive and easy to use for the content people who don’t code. I am thinking of being my own cms, but that seems like too much work for no reason....

How do you approach long async types of operations on t3/next/vercel?

Say I need to run a process that takes 5 minutes, it gets data from DB, does some calculations, generates a CSV and drops it in s3.

Handling Calenders In React

Hey folks is there any React library to handle Calender component like it shows current month and also I provide some dates which it should be highlighted and show in small card like not to take up the entire page

Weird typescript error

Hi all, im getting a typescript error i dont understand why im getting. As you can see selectedQuestion is assigned the type that you can see, ie a object called SeenQuestions along with some type extensions. The type SeenQuestion absolutley has a property called .questionType - so why am i getting this error? Help greatly appreciated...

Source for creating my own create-x-app CLI command?

Is there any good source that dives into creating a CLI command such as create-t3-app? Would be very useful for the company I work at!

Does react 18 `cache()` cache across requests?

title, if I have a function wrapped with cache, does it cache across requests? or just dedupes calls in the same request https://nextjs.org/docs/app/building-your-application/data-fetching/caching#react-cache...

understanding drizzle insert

I am trying to use insert in drizzle orm and it is requiring the id for the model: ```ts export const meetings = mysqlTable("meetings", { id: varchar("id", { length: 255 }).notNull().primaryKey(), clubId: varchar("clubId", { length: 255 }).notNull(),...
Solution:
needed to use .autoincrement() in mysql

Nextjs request's order in async api

I have api endpoint to handle payment webhook requests. So it's multiple requests one by one which changes status of transaction and sometimes mine database updated in a wrong order. How it possible to ensure right order of requests in nextjs 13 ?

Update userId which is used for defining relationships between models

Hey. I’ve got in the situation where I need to replace userIds of a user, that define many relationships, like student-to-teacher, teacher-to-students, students-to-lessons. Obviously, I tried the most forward way of just looking for specific userId across the tables and having it replaced with the new one, but prisma quickly throws an error signifying that I try to push changes that would violate above-mentioned relationships. Any guidance will be really appreciated....

What would be a good budget option for FTS?

Hey all. I have pretty much no idea what im doing in terms of this and wanna hear your thoughts. Currently I am looking at the following Algolia Grow Plan (but seems it could get expensive fast) Orama on Workers?...

PrismaClient unsafe any

I keep getting this error. Linter blocks build. So i did create t3 app without prisma then decided to add it later on. ive done theo's tutorial before and never had this issue. and yes ive googled it before and prismaclient unsafe any leads to no related results. Im pretty sure im missing something really obvious but i cant seem to see it.
Solution:
I keep getting this error. Linter blocks build. So i did create t3 app without prisma then decided to add it later on. ive done theo's tutorial before and never had this issue. and yes ive googled it before and prismaclient unsafe any leads to no related results. Im pretty sure im missing something really obvious but i cant seem to see it.

Setting up vanilla trpc client

So I have a button and when that button is clicked I want it to do some trpc mutation. After doing some searching and seeing this response in a different post here https://discord.com/channels/966627436387266600/1126264396285481151/1126264611008696320 I concluded that the best way to do this was to setup a vanilla trpc client following the linked guide(https://trpc.io/docs/client/vanilla/setup) But after following that guide I get a typescript error when I build and when I try to click the button in the dev environment I get a runtime error. So what am I doing wrong?...
Solution:
alright I solved this myself and yeah, I marked it as noob for a reason so yeah(~ is src dir not unix home dir) ~/utils/api.ts creates the react query version of things and that version has the correct object to pass into createTRPCProxyClient so I just copy pasted it into that resulting in this ```ts export const vanilla_api = createTRPCProxyClient<AppRouter>({...

Challenging recursive TS type

Had an annoying time with this one today at work. See this playground for repro: https://t.ly/C--h One of my APIs has a quirk that the JSON it provides gives every object back wrapped in a surrounding { map: <obj> }. I can write a simple recursive function to mapWrap some data, or to unMapWrap it when I receive it. I can also define a generic type that expresses the relationship between a MapWrapped<T> and the unwrapped type. But I don't know how to make TS understand that the mapWrap<T> function produces the MapWrapped<T> type without casting to any multiple times....

tRPC + next-auth + next app router example application

Hi! Im looking for a demo of trpc with secured procedures and next-auth running together under app router

NextAuth profile images broken

I'm using Spotify as a provider with NextAuth, and after a few months or so, the profile images break. The link to the profile image in my db returns a 404 as Spotify changes the url for the profile images for some reason. A few other providers have this issue as well. I remember seeing an issue in the NextAuth repo that provided some potential solutions you can do to solve this but I can't find it. Does anyone have any recommendations on how to fix this issue?