mosesintech
TTCTheo's Typesafe Cult
•Created by mosesintech on 2/16/2024 in #questions
tRPC error handling
Anyone have any examples for the above?
If a user inputs data they shouldn't, I get an error but am struggling with doing something meaningful with it.
Just need some example code I can poke around.
3 replies
TTCTheo's Typesafe Cult
•Created by mosesintech on 2/13/2024 in #questions
html-react-parser and "Unsafe call of an `any` typed value".
Hello friends.
I've got Next hooked up to a CMS. I'm using html-react-parser to parse the data for me and return readable content.
The NavMenu component I'm using it in:
The code runs and does what I want it to. (It turns
News & Updates
into News & Updates
).
But the linter doesn't like it: Unsafe call of an
any typed value.eslint@typescript-eslint/no-unsafe-call
I thought it was a local issue, so I restarted the typescript and eslint servers. Restarted vscode. I searched the discord to see if others had the same issue. Tried other nonsense things, but my brain is running out of juice here.
Have y'all run into this?5 replies
TTCTheo's Typesafe Cult
•Created by mosesintech on 9/20/2023 in #questions
TypeScript error: Type 'string' is not assignable to union value
Hello friends.
I've picked up my side project again this week and I'm trying to add a new feature (required field indicator). It's a component library for forms. It's expecting specific form data:
When a user passes in the form data, they may or may not include the
requiredIndicator
. If they do, it can be either "TEXT", "ASTERISK", "CUSTOM" or a null value.
I thought I could tell TypeScript that these are the only 3 string values that it could be and have it work. But when I actually test it out, I get the following error:
Type 'string' is not assignable to type '"TEXT" | "ASTERISK" | "CUSTOM" | null | undefined'.
I've tried a bunch of things and can't seem to sort it out. I think the issue is that because I have no control over the data that the user is passing into the <Form> component, I can't use a type assertion.
I'm thinking that just typing it as 'string' is fine enough. I just thought that TypeScript could do this too.
I could stand to learn more, so I'm open to anything y'all have for me.
Thanks!10 replies
TTCTheo's Typesafe Cult
•Created by mosesintech on 5/17/2023 in #questions
SVGs in Next
Hey friends. I'm working on a new project and having some issues using SVGs. What is your recommended method for using SVGs in Next?
I know there's a lot of answers online, but I'm wondering if there's a specific T3 way of doing this.
Thanks! 😄
5 replies
TTCTheo's Typesafe Cult
•Created by mosesintech on 12/30/2022 in #questions
Anyone have experience sorting out a ChunkLoadError?
I'm working on a little side project in my free time, mostly to expand my skillset and learn new things. Basically, it's an npm package that you give info about a form you want to make and it'll make it for you. I'm lazy loading the form field components so that I only load them when they're needed. All works fine in development, but when I'm using it with real data in production I get this error:
Loading chunk 216 failed. (error: http://localhost:8000/216.index.js)
I don't have a lot of experience with webpack, so I'm guessing it's a config issue but I'm not sure where exactly to look. 216.index.js
does exist in dist
so I'm not sure why it 404s.
Repo: https://github.com/TotalityWorks/wpgravitybundle/tree/feature/typesafe-v1
I'm playing around with it in Gatsby.js. wpgravitybundle@alpha
1 replies