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

Can typescript infer from ternary operator?

Const example = test === true ? {count: 5} : {string: "string"} Is that possible to somehow get this working....

Server only dependencies

Hi, I wanted to ask if there is something like server only dependencies, for example, I don't want to be able to use or even import something like bcrypt on the client side, and also, it shouldn't be included in the client bundle... How can I achieve that?
Solution:
Do you need server-only? Using it makes sure your file is never imported from the client. https://nextjs.org/docs/getting-started/react-essentials#the-server-only-package...

How to wait for state to update without useEffect?

Basically I have custom hook that looks like this: ```ts const [data, setData] = useState<ResponseType | null>(null) const [isLoading, setLoading] = useState(false) const [isRunning, setRunning] = useState(false)...

Why keyof Record wont actually give the keys of the record ?

I have this exemple : ```ts type GlobalStuff = { description : C,...

Nested Generic Inference

Got a question on the correct way to type generics when you've got one generic inside another. A few examples of implementations. I'm mainly confused why example 1 isn't able to infer the type of inner correctly. Is there a correct way of doing this? ...

Pusher with trpc

I'm making a t3 app and I want to use pusher channels, How can I use it with trpc for the channel autherization? I need to run checks using prisma and I need the context trpc provides to get data from the database to see if the user should be able to connect to a pusher channel

Testing a React Webapp

Any suggestions on a framework to test a React web app? Users report bugs like buttons not working or graphs not rendering which I’d like to prevent. I have error reporting but how can I catch this before my users do?

Ability to set column width and `className` for <th> and <td> in shadcn-ui Data Table

Hi, I am unable to add classNames to <th> and <td> in shadcn-ui Data Table, I used the same method as used on https://ui.shadcn.com/docs/components/data-table#basic-table but I am unable to set classNames in the above stated elements

Issue with trying to build with Nextauth

So my code in auth.ts looks like this ```ts providers: [ CredentialsProvider({ id: 'credentials',...

'id' does not exist in type 'UseTRPCMutationOptions<{ id: string; title?: string | undefined; ...

in pages/quest/[id].tsx ``` type Props = { quest: QuestWithObjectives; onClose: () => void;...
Solution:
Hi, friend I don't know if this will fix you problema but what you are doing here is very problematic: ```tsx const onSubmit: SubmitHandler<QuestUpdateInput> = async (data) => {...

What are your favorite libraries from the React Ecosystem

Didn't want to post a question in #tech-discussion

GCP Private service connect

I am trying to setup a nats Jetstream cluster behind private service connect, realistically I would like to expose each node as a service and create an endpoint for each one. I was able to get one working node working, but I am struggling to get two nodes working. Right now they are just vms. It seems as if I would need to do a load balancer for each node, is there anyway to set this up where I can have one endpoint per a node, the nodes will talk amongst themselves and will load balance on there own, so I don't realistically need an lb, but private service connect seems to require one for a publisher service. I know this is primarily web dev, but figured I had a chance to run into at least one person that may know GCP and would be able to throw ideas around/talk through my solution this far....

help with prisma planetscale schema

Hello everyone, im trying to implement nested comments on my post object, this is currently my implementation without comments.. ```javascript datasource db {...

Warning: Prop `id` did not match. Server: "radix-:R36qcq:" Client: "radix-:Rcr9j9:"

I added the dark mode switch from shadcn-ui to my project and now I have this warning in my console...
Solution:
:D

framer motion stuff

So I've got this title thingy ```tsx 'use client'; import { bodoni_moda } from '@/lib/fonts';...

Converting api data to a zod object

Hi. currently trying to build a lil poke app using the nextjs app directory, typescript, and zod. What's the quickest way to convert json to a zod object because the pokeapi data for ONE pokemon looks... scary

How do you monitor tech news?

Like any field, it's always important to keep up with the latest news in the tech world. How do you get the most valuable information in a convenient and productive way? What tools (news aggregator, etc.)? What media? What sources (beside Theo of course 😁 )?