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

Is it possible to infer a const type from a Set?

Say I have const foo = new Set([1,2,3]) how can I infer the type of foo as const? For example, const bar = [...foo.keys()] as const is of type number[] instead of type 1 | 2 | 3....

Where to start for frontend

So im trying to decide where to start for the frontend side of development. I decided i wanted to do Actix Web a rust language library for the backend. The reason i wanted to at least do the backend as rust is cause i heard its faster and i want to learn more and use rust. Although i cannot decide what to do for the frontend. Should i use react or what should i use? Haven't ever really messed with react or Javascript this is my first web project

Next app deployment issue on vercel

In my next app, there is an api endpoint "posts" that return posts from the database. I used prisma and planetscale. When I deployed to vercel, api routes with no database querying are working but the one's with prisma code in it are not working (500 Internal Error). Note that I added env variables on vercel. So, I copied production branch env variable to local pc and ran "next build" and then "next start". The production build is working completely fine. It is not only working on vercel. Can an...

learning t3 stack, specifically fetching data from API

Hey guys, so I'm doing a little project, and I want to fetch data from free api website. I know that one of the part of T3 is TRPC, but it seems pretty confusing. What should I learn about to be able to fetch data I want? Or should I just use react query withotu TRPC? is this possible?

Next.js - ReactQuery data is being refetched everytime route changes.

Hello. I made this simple demo, where react query forces refetch every time route changes, I want to disable this behavior. Is it possible? It does refetch only when previous response has been unsuccessful. In my specific example where I am getting user from API, I don't really want this kind of behavior, because it shows loading animation on every page change. My default query client options:...

Is there a way to add only a specific addon to an already existing ct3a app?

Imagine I didn't select next-auth at the start and would like to add it later -- any command for that? Is this codemod the recommended way? https://github.com/kroucher/ct3a-codemod...

rcTable Rerenders useEffect

hi guys, in these couple of days i tried to solve this problem of rerenders in my code, i don't understand the reason for it..., i tried to check if there was like a return statement after the hook or a rule that breaks the hook rules in every component logged in the error but nothing...

Case sensitive search in MySQL with Prisma

Hey guys, how can you implement case-sensitive search in MySQL adapter for Prisma? I see that they disabked mode property where you could set sensitivity in something like Postgres. Is there any way you can do case-sensitive search? Thanks!...

Learning Choices

I am a noobish programmer with some Javascript CSS and Html experience my next question is do I learn typescript next or a framework (if so which one and why, I am willing to hear opinions)

Using tRPC with a request to an external API

I have an API route that hits a third-party API. What role can tRPC play in this request? Can I create a new query in and move this fetch to the resolve or am I not thinking about this correctly?

How to prevent prerender error for static page that fetches data from serverless API

I'm trying to have a static props get defined by data retrieved from an endpoint on /api/hello from a t3 app. Running next dev works just fine, but when running vercel build, I get this error: ``` Error occurred prerendering page "/en". Read more: https://nextjs.org/docs/messages/prerender-error TypeError: fetch failed at Object.processResponse (node:internal/deps/undici/undici:5536:34)...

Optimize Images (T3 Stack + S3 + CloudFront)

How would you go about optimizing images? Right now I'm just fetching each link from S3 and then map through the links array and use that as src (example: https://jibberish.cloudfront.com/${link}) (i'm using next/image but that's slow when loading, like really slow) I'm begginer/intermediate so try and explain thoroughly....

trpc v10 Invalidating all queries from given router

Is it possible to invalidate all the queries under given router? Similarly as it is in react-query: https://tanstack.com/query/v4/docs/guides/query-invalidation Can I use query-client in trpc in the same way?...

Prisma Update many WHERE with LIMIT?

Got a table full of records that can be assigned to a user, by default they have no user assigned to them. I would like to run something like the following to make sure only X amount of records can be assigned at once. UPDATE"verificaiton SET userID = ${userId} WHERE verificaitonSessionId IS NULL LIMIT ${input.limit} i cant believe that prisma does not allow this? Im i going mad? https://github.com/prisma/prisma/issues/8359v...

.env variables failed to load

I want to fill my Railway Postgres database with data which I have locally. I have followed nexxel's create-t3-app tut to create a database added all the env variables but this is happening.

nextauth session props problem

Hey Guys I have code like that `const MyApp: AppType = ({ Component, pageProps: { session, ...pageProps }, }) => { return (...

How to Pass (Dynamic) Variables in trpc.useQuery()?

I know I can do this: const findSubscriber = trpc.useQuery(["subscriber.find", { email: "elsa@prisma.io" }]); But what if I want the user to type in an email & then see if that email exists with subscriber.find ? So I want to execute my query conditionally, that is, only in an onClick, as I don't have the user input before that....

how do you add `prettier-plugin-tailwindcss` to an existing ct3a app?

ive installed the plugin (pnpm add -D prettier prettier-plugin-tailwindcss). docs say plugins aren't automatically used from node_modules with yarn or pnpm, so need to make a prettier.config.js, but eslint doesn't like that:
Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser. The file does not match your project config: prettier.config.js. The file must be included in at least one of the projects provided....

_app

Stale Environment Varaibles. Hey everyone, I had a quick question about stale environment variables when using CT3A. For some reason when I update my .env file it seems like I have stale variables and the updates don't take effect. I tested this with printenv and it seems my current work around is to - remove yarn.lock - remove node_modules...