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

TSConfig Path Alias doesn't resolve in monorepo

Trying to convert my repo to a turborepo, using create-t3-turbo as a baseline. Almost everything worked as expected, until I tried to add custom path aliases inside packages/api. That led to the following error. ``` ../../packages/api/src/trpc/router/meeting/meeting-attendance-link.ts:2:0 Module not found: Can't resolve '@/common/grant-rewards'...

React state management for forms (creation is simple but reusing for editing is hard)

I am constantly building forms for creation and editing of different entities in my web app (like tasks, notes, contacts, etc.). However, I wanted to understand what is the recommended way of managing state of these forms in a way that - 1. Reuses components 2. Is performant Let's take the example of task creation and editing modal. What I currently do - ...

How do you hit trpc endpoints via http request?

I am fairly new to trpc. It's awesome when consuming the API through the client. But what if I want to test the API via postman or make a get request using the browser? For example, with a normal next api route, I could go to localhost:3000/api/hello and it would return the data. Can I do something similar with trpc endpoints? I tried going to localhost:3000/api/trpc/example/hello but that did not work. Thanks in advance!...

Vercel functions - python + node runtimes

I need to have some vercel functions in python, and I'd like to have them live in the same project as my nextjs app. In a clean T3 app, when I make a /api folder with a python handler, I get 404s on all other functions. I think it could have something to do with how the dynamic routes are handled (https://github.com/vercel/vercel/issues/3294), but I just wondered if anyone else has encountered this?

Unsafe assignment of an `any` value

I've been working with the create-t3-turbo template recently and it has some new linting rules I'm not accustomed to. I'm already an anti any zealot, but these new errors have me scratching my head As you can see in the image the linter is complaining that there is an unsafe assignment of an any value but from what I can see everything appears to be typed, and there are no any values to be found. Is this an issue with my linter setup, or can someone help explain what I'm missing. I've checked the typescript rules page for these warnings, but I am not seeing any examples that come close to matching what I have in my code....

rewriting table to use react table

Hi! I have my current table but I wonder if its possible to make it work with react table. Im mostly concerned about one part because currently I have a little small icon that let user add Item to favorites (i use trpc to handle that on click) ``` Tbody Items.map(Item => (<ItemComponent Item={item}/>) Tbody...

Is next-themes worth using?

I've been trying to implement dark/light mode in my app and most of the tutorials I found use next-themes. However, 35kb seems kind of a lot. So my question is, is it worth using or is it better to implement yourself?

Presigned URL file upload Access Denied

Hello, I am able to upload files using a presigned url, but after I block all public access in my aws s3 ui, I am not able to upload the file using my presigned url. I get this this error in my response: ```ts...

Prisma: Asyncronous Extended Fields

Anyone familiar with any better way to accomplish the equivalent of field resolvers with prisma? The Ask I need an async field returned with each user ...

Vscode debugging Nextjs serverside code - debugger does not refresh code (breakpoints hit old code)

When I debug server side Nextjs code (api routes) my breakpoints in Vscode do not work correctly. I cant set breakpoints on most lines and they are jumping in debug. Additionally the debugger stops at code that is not even invoked, so it seems to hit old code. For example it stops at code from a function that I used before but I already changed the code to invoke a different function, so it seems the debugger uses "old code". ...

can i deploy different t3 stack app on different sub domains?

I have deployed several apps on vercel with the t3 stack but i have never deployed with a sub domain So i want to know if i can configure vercel to read the sub domains Example i want to have admin.test.com, user.test.com and exam.test.com...

Does anyone know how to print react docs?

Yeah basically what the title says, I need to print react beta docs and with ctrl+p text gets cut off at the bottom.

create-t3-turbo expo tunnel doesnt fetch on a physical device.

On an emulator it works properly, noticed the same thing on my project, as well as on create-t3-turbo repository, not sure how to properly fix that.

Property 'handle' does not exist on type '{}'

How do i bypass "Property 'handle' does not exist on type '{}'" i am trying to pass the handle value to the session, and the handle value in fact exists in token.user and my code works accordingly as well, however typescript does not let me pass through this error. my code is as follows (this is inside the [nextauth].ts file)...

tsconfig and import statements

All my tests (of the modules) are using import statements... However once i put an import statement in the index.ts i get this error: ``` $ ts-node index.ts...

Proper way to handle TRPC server errors on client?

I have some code that looks a little like this, but I'm not too sure what we should be putting in the catch for typing the error. I'm just using the default t3 stack error formatter. Is there a built in type for the client I can use that doesn't require me to JSON.parse the error object? ```typescript subscribe .mutateAsync({...

adding provider causes type error

when adding a new provider, I get the following error despite having changing the ENV and adding the new environment variables. Type 'string | undefined' is not assignable to type 'string'....

Get Vercel Server IP

Hey guys, API I’m trying to incorporate wants my server IP. As Vercel can’t provide this due to the nature of serverless, is there any work around? Or I really gotta deploy an entire seperate API on Railway or something just for one endpoint?

CODEREVIEW - Typescript noob

in javascript i would write this by first defining the empty object and then filling it up, so as to keep my code DRY typescript doesn't seem to like this... is there a best practice? ```ts...

Protected routes in Nextjs?

In the past I have made protected routes using react router so that if a user is not authenticated and tries to go to a page, they are redirected to the login page and then once logged in, brought to the page they were trying to go. I’m now trying to learn Nextjs and wanna know firstly if this is the best way to ensure authentication, and also the best way to do it with Nextjs routing if it is. I’ve found varying answers online so I figured I’d ask here.