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

Type 'string | null' is not assignable to type 'string | undefined'.

Argument of type 'Quest' is not assignable to parameter of type '{ id: string; title?: string | undefined; rating?: number | undefined; rating_denominator?: number | undefined; reward_xp?: number | undefined; goal?: string | undefined; target?: Date | undefined; ... 7 more ...; objectives?: { ...; }[] | undefined; }'. Types of property 'description' are incompatible. Type 'string | null' is not assignable to type 'string | undefined'. Type 'null' is not assignable to type 'string | undefined'.ts(2345) ...

Matching types to Prisma models

I have a T3 boilerplate with Prisma and PlanetScale as per Theo's T3 Stack Tutorial. I'm trying to create a dynamic route for a product under /shop that will accept a router query of the product ID. What is the best practice in this environment to create a type for a product, but using the already-existing model in the prisma schema? I could just create my own type, of course, but then that seems like it's a duplication of effort (creating the prisma model AND the type, and having to update both...
Solution:
You can just import the model type from prisma like
import { Product } from '@prisma/client'
import { Product } from '@prisma/client'
where you have a prisma model named "Product"

need key value pair database like redis

need key value pair datastore like redis which is similar to python dictionary and should be cleint based And it would be very good if you also send free service hosting for it...

How do I solve this error

I have installed daisyui already. Already tried the suggested fix

"Unsafe assignment of `any` value

I am using latest create-t3-app with prisma, tailwind nextAuth and trpc

Clerk + Next.js app router <SignedOut> children not rendered after <UserButton> sign out

Hi there! I'm currently building an app with Clerk and I've got signing in working however when I sign out using the <UserButton> component however after the redirect, my sign in button isn't rendered until a refresh of the page. Here's my code: ```tsx <SignedOut>...

turbo repo built lint error

I was setting up ct3turbo when I saw the GitHub action workflow is showing errors, how do I fix it?

changing col-span with template literal

any idea why this isnt working?
Solution:
Dynamic class names like that don't quite work with Tailwind, it decides on build time what classes to compile, there are some workarounds here https://stackoverflow.com/questions/69687530/dynamically-build-classnames-in-tailwindcss

[Solved] T3 Stack PWA ??

Does anybody know how to turn a t3 site into a PWA? I am using next-pwa but I am getting a few errors. Here is the error I am getting.
Argument of type '{ reactStrictMode: boolean; images: { remotePatterns: { protocol: string; hostname: string; }[]; }; pwa: { dest: string; register: boolean; skipWaiting: boolean; disable: boolean; }; i18n: { locales: string[]; defaultLocale: string; }; }' is not assignable to parameter of type 'PWAConfig'.
Object literal may only specify known properties, and 'reactStrictMode' does not exist in type 'PWAConfig'.
Argument of type '{ reactStrictMode: boolean; images: { remotePatterns: { protocol: string; hostname: string; }[]; }; pwa: { dest: string; register: boolean; skipWaiting: boolean; disable: boolean; }; i18n: { locales: string[]; defaultLocale: string; }; }' is not assignable to parameter of type 'PWAConfig'.
Object literal may only specify known properties, and 'reactStrictMode' does not exist in type 'PWAConfig'.
...

tRPC Error: Invalid hook call.

Sorry for the noob question I just cant figure out how to do this I have the following tRPC route: export const appsRouter = createTRPCRouter({ search: publicProcedure.input(z.string()).query(async ({ input, ctx }) => { console.log("input", input); return await ctx.prisma.app.findMany({...

Stack?

Hey how would I go about creating a website where you can post minecraft servers and include a image and other users can vote for a server? Is this stack good? - Planet Scale - uploadthing.com...

How would I order by the role?

Hello, I'm trying to set up an API, where I return some users. I've got it working, where it returns the right users, with their roles. But I would like to order them so the role "ADMIN" comes first. I know there is orderBy, but every time I use it, it just sends a bunch of errors. Maybe I'm on a completely wrong track? What I'm currently doing to get the user: ```js...

Prisma Create with Connect Issue

Hey! I wasn't able to find another thread explaining this, but I'd love help with this! I have two tables in my database right now, they are Org and OrgType (in Prisma). Here is how they look right now:...

Generating image background job

I'm making a game where you can create levels in HTML5 Canvas and upload them to the api. I will need to generate an image for the level and I thought about using playwright to take a screenshots of the game via this playwright browser instance. Doing this in a serverless function doesn't really scale because it can take some time to generate it so I thought about having a background job for this. What are some helpful services to aid doing this?

Help with Vercel deployment

Hi folks, I am having issues deploying to vercel. I keep getting this error:

My DB shouldn’t be this slow, RIGHT❓

A fresh DB (pscale) and Table with just two entries, but takes 10s to fetch them (prisma studio) I’m referring to dev mode, fetch through prisma studio, I haven’t deployed yet - so didn’t check prod. It’s a user table with 4 one to many relationships, and a few fields....

❌ tRPC failed on profile.getUserByUsername: No "query"-procedure on path "profile.getUserByUsername"

I am a bit lost. This is the profileRouter. export const profileRouter = createTRPCRouter({...

Help with Prisma Validator static evaluation

I am trying to build a helper function that will allow me to abstract away some deeply nested includes for a data type. However I'm trying to make this reusable like in the following snippet ```typescript export const helper = (include: boolean) => { return Prisma.validator<Prisma.SomeInclude>()({...

Does invalidate(); perform an actual refetch?

I am half way into the course video and I see void ctx.post.getAll.invalidate(); to show the new post we are making. Isn't this just refetching? Wouldn't it be better to have a local state/catch being updated when successful vs trying to refetch everything all over again? just seems very costly especially if an app grows. Please let me know if I am wrong in my thinking or how I should be thinking when we consider refetching data once successful. Thank you
Solution:
on personal projects where I know perfectly the architecture and every API call being made, I always update the cache, and set the stale duration to Infinity. On enterprise projects where 50 devs work on the same app, sometimes it's just a mess and you'd have to update 7 different cache entries and know exactly how the data is structured in each, so we tend to just invalidate

SWR - array of data in one request, one item from array in another

So I am using SWR in my nextJS app and I have two routes GET /courses gets all classes you are enrolled in (of type CourseData[]) GET /courses/:course_id gets specific details for one course (of type CourseData)...