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

Explicitly specifying an object in Prisma with its foreign relationships

I've set up my schema as an approximation of a directory structure: directories (ADirs) and documents (ADocs). Directories and documents can have a parent directory, which is a foreign key. I can write queries to retrieve directories and their children (childDirs, childDocs) without issue, but if I specify a directory as a state variable in a client component with useState, the type definition for ADir that I get from importing @prisma/clientdoes not have the children as a property. I've circumvented this issue by extending the type with my own interface, but I feel like it's a messy fix. Any tips? Thanks....
Solution:
so then I'd get a type like this
export type Dir = Awaited<ReturnType<typeof getDir>>[number];
export type Dir = Awaited<ReturnType<typeof getDir>>[number];
...

Error when running `drizzle-kit push:mysql` to a Planetscale database

so after reading through the Doc's it looks like i need an SSL cert to run the push however i'm not sure how to configure that with drizzle and from what i've sceen from others they are doing it an easier way. This is the error I get when running drizzle-kit push:mysql: ```bash
drizzle-kit push:mysql...

Headless UI Transitions

Heya, I'm trying to create a simple little animation where a dropdown menu slides down when revealed (similar to an accordion), but I can't seem to get it to properly work. ``` <div className='absolute w-full max-h-32 z-50'> <Transition...
Solution:
I ended up switching over to Framer Motion; ```tsx <Listbox> {({ open }) => ( ...

Counting rows in Drizzle ORM

Hi, I was wondering what the best way to count rows in drizzle is. Thanks for the help!...
Solution:
```ts import { sql } from 'drizzle-orm' import { YOUR_TABLE } from 'schema' const { count } = await db.select({...

Does App Router have getStaticPaths? Does it even need that?

Hello everybody! 👋 I hope you are well! So I'm looking into App Router. I just recently followed the Nextjs Guide and set up a basic blog, put using Pages. Now I'm trying to figure out how to migrate 😅 Pages had this apparently super cool feature to pre-generate my blog posts during the build with getStaticPaths and getStaticProps. I can't seem to find anything like that in App Router, although I'm really unsure if that's even still necessary. Does App Router have something like getStaticPaths? Does it even need that? What's the best way of serving my .md files (blog posts) with remark with App Router? 🤔 ...
Solution:
maybe something like this

Pull template repository

I would like to know if it is possible to use a template repository and after the template repo receives changes if I can "pull" to add the news changes to my personal repo just like reinstalling a library

TypeError: client[procedureType] is not a function weirdness

I'm trying to make an adapter for auth.js and want to call my backend via the adapter with tRPC proxy client. For some weird reason I get this error and don't know why exactly :// if anyone knows what might be going on

Invalid env variables Nextjs

Hi guys ! It's certainly very dumb but I don't figure it out. I have set everything correctly from what I've seen in the docs but when I run one of my scripts where I invoke these variables, I have this: ```:x: Invalid environment variables: { DATABASE_URL: [ 'Required' ],...
Solution:
If you’re running a script outside of nextjs you’ll have to handle reading env from the .env file using library like dotenv when running that script.

Weird type errors with next.js and drizzle

```ts //when I use export const dynamicParams = false; //or export const dynamicParams = true;...

Memoize function in typescript

I want to memoize a pure function in ts that's just a static export without class. Typescript-memoize seems to need a class for the decorator to work. Do I have to wrap my functions into a class and possibly use a singleton or is there a simpler way to pull off memoization?

Clerk: Is it possible to create custom metadata on signup using Clerk?

I need to create a custom metadata "credits" on each new user object, is it possible to achieve that with Clerk? One of my ideas was to call the api route after sign up which will update user object using clerkClient. ```typescript...

best react video player

What is your favorite react video player? And why?

ct3a update/diff tool URL?

I remember someone made a tool where you put in your init version of ct3a and a target version and it pulls a diff so you can manually update. anyone got the link?

How to properly setup next auth for a discord dashboard

Context: - I am setting up a dashboard for a discord bot and I'm using next auth to setup discord oauth - I use prisma as my database adaptor and next 13 app directory as my framework - I am v new to next and next auth so this might be common sense ...

setTimeout with T3 stack not working. Sorry for not got GUD

I am new to TS and i cant get setTimeout to work. It says Argument of type '() => void' is not assignable to parameter of type 'number'.ts(2345) I have googled and tred a lot of other code. I have seahed the t3 doc's. I feel really dumb for not being able to solve this. ...

icon in mobile app

When i am on chrome and click on the Add to home screen the icon that appears is a "1" instead of the logo of my app. I have created a manifest.json the same way you would do in a react app and the meta tags of html seems ok too. Any suggestion what can i do?...

Same side panel on different routes

I have an app where I'm dealing with different kinds of tasks. Whenever I click on a task, I need a side panel to open up where I can edit the task. I need the same panel on routes /a/b/c as well as /d/e. What would be the most general way to build such a panel and activate it?...

How to upload blob from audio recorder?

I've spent all day banging my head on my keyboard trying to upload an audio file to S3/B2 that was recorded from my React app. Then I remembered to try UploadThing. But I've hit another brick wall. How do I upload a blob with UploadThing? I tried startUpload([blob]) but it tells me, "Type 'Blob' is missing the following properties from type 'File': lastModified, webkitRelativePath." (The audio blob comes from https://www.npmjs.com/package/react-audio-voice-recorder.)...

Optimistic updates type error [Symbol.iterator]()

i'm trying to use optimistic updates on my mutations but i'm getting this type error ´´´(GetResult<{ id: string; createdAt: Date; name: string; backgroundImage: string; userId: string; }, unknown> & {})[] | undefined' must have a 'Symbol.iterator' method that returns an iterator.``` i literally just copy and paste as the docs and i don't now what to do...