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

cant access user id in router ctx

Hello, I'm using default T3 create app, and I'm trying to access user id so that I can fetch entity related to User, but my ctx type is not overwritten by Session type from next-auth.d.ts Anyone similar problem?...

Force every value of union type in an array

Let's say that I had the following union type:
type Name = "John" | "Sean" | "Theo";
type Name = "John" | "Sean" | "Theo";
If I wanted to have an array that accepted a list of those values I would do something like this...

Filedownload through tRPC

I try to get a Filedownload working through tRPC. Currently i'm using useMutation in the Frontend. If invoked, the mutation leads to a fs.readFileSync and converts it to an ascii String. I think this is not ideal since in the Frontend i use useEffect to look after the Change of the mutation to then create a blob and a link to the Blob to download the file. Ideally i would like to use fs.createReadStream to send the Data as chunks and directly download the Data instead of waiting to recieve it and then have an instant download on my hand. I'm very open to ideas since finding little Documentation for that problem....

Component cannot be used as JSX Component. Its Instance type is not a valid JSX element

Yesterday, in a separate folder, I initialized CRA + installed Material UI. Unfortunately (I think) this made me sprinkle the rest of the projects in separate folders. I think I've searched all over the internet. I used "resolutions", nothing helps.... Of course, I cloned the repository, removed node modules, installed again and so on. package.json file:...

Typesafe query keys

Hey I am curious how do you guys manage your query keys and keep track of them. In a complex application managing them and keeping track of which one to invalidate seems hard for me. Is there an option to make them somehow typesafe? I haven't found any good articles on this topic :/

Passing `initialData` to react-query from `getServerSideProps` "Text content did not match" error

I have a newsfeed-like page with infinite scroll. I'm sending a request to my Laravel backend API from getServerSideProps and passing the results to the page component with props. Then I'm passing those props to react-query's useInfiniteQuery by setting its initialData to the object I got from getServerSideProps. This works fine but when anything changes in the database, I'm getting a "Text content did not match" error because the page source generated by NextJS doesn't match whatever is rendered client-side. I've logged everything out and it goes like this: the browser is always getting the correct data. It receives correct data from getServerSideProps, then react-query fetches some data on the first render which is again, up-to-date data. ...

Prisma CreateMany with a relation (connect)

Hi everyone, in Prisma is there a way to createMany with relation - using connect i assume? Basically this a million times: I read the documentation and there doesn't seem to be "nested createMany" but i think that's not that im doing (or is it? seems like this is too common an operation to not have a create-many)......

Neovim initial setup help?

I'm new to neovim and trying to configure my setup for t3 stack web development. Any help would be great....

Next.js conditional render

Am I doing it right? Just wanted to render proper content in 'Auth' boilerplate component, based on actual route (page). Or maybe it is not a recommended approach?...

Zustand Electron Middleware

I know that this is not the right place to ask zustand or state management related questions but maybe I would find someone who worked on something similar before and prepared to give a helping hand. I'm trying to build a zustand middleware to sync state between the main process and the renderer process of an Electron app, and I'm having a hard time with typescript. The middleware works as expected except I can't use it with any other middleware, Typescript get's really mad when I do....

mutation.isSuccess not working

I have a submit function that when called, I want to do a mutation. If a successfull mutation, I want to do some action and if error I want to do a different action. My code currently is not catching the mutation.isSuccess even though there are no errors. ```js...

Should React-Query only be used for APIs and not other async operations?

I'm working on a project involving connecting to a bluetooth device, which is an async process. I've opted to use react query to get the same state management that I'd expect from an API call, but I'm getting some pushback from the other devs on my team saying it should just be used for API management. Curious what everyone else's thoughts were because I always operated under the thought that react-query is state management for anything async, not just APIs

Add redirects rule inside t3 app

Hi how can I add a redirects rule in the t3 next.config file. Currently my file looks like this: ```ts...

nanoid prisma schema /w planetscale

Hey gang, does anyone know how I can define a nanoid field with prisma if I am using planetscale? From the create-t3-stack example: ``` model User { id String @id @default(cuid())...

My company wants us to install Vanta Agent on our laptops

I am at an early start up, seed round. They are asking us to install Vanta , but we weren't provided company laptops. I don't really feel comfortable installing it on my personal laptop. I've interned at a well-known place before, so I thought I'd be getting a company laptop or tech stipend for one at this place. My laptop is 16gb ram and I run docker, db, and 3-5 microservices at a time, so sometimes my tools crash. I am considering getting a new laptop just for the job, but they just started l...

What is the `:::tip` syntax in markdown called and how do I use it?

I saw it in the astro docs, but it's not part of the default markdown spec. I tried to search for it, but it's hard to search for special characters.

Creating a related record with Prisma returning all records / how to get just one?

Hi folks! I'm pretty new to prisma so i have something a little annoying happening, love your guidance. I'm running some reporting - one batch has many reports... so first i create the batch ```js...

Issue adding import path to tsconfig.js

I wanted to create a path I can import my ui components from to make imports cleaner. Wanted to call the path "@ui" for ".src/components/ui/" but running into compiler issues. My tsconfig.json looks like ```...

getStaticProps next 13 with tRPC

I'm not being able to find a solution to get this working, I'm using create-t3-turbo but the createTRPCContext function takes req and res which are not accessible with the getStaticProps. Not only that but the Can't resolve v8 error also appears when trying to use getStaticProps Any ideas?...

Login in with credentials with next auth

Hello! I'm trying to learn how to use next auth with credentials. So i got this next auth settings: ```export const authOptions: NextAuthOptions = { session: { strategy: "jwt", }, providers: [...