Skip to content
0:00 / 0:00

#typescript#typeinference#zod

You Might Be Using Typescript Wrong...

Theo - t3․gg

576K subscribers • 4 videos on Hallway

YouTube
  • Recommended by 3 people: 3 in engineering communities.
  • Presented by Theo Browne
  • Linked in the descriptioncolinhacks/zod
  • An opinion. It argues one side of a question engineers disagree on.

Intermediate. Assumes working knowledge.

201K views4 years ago3 recommendations

Programming languagesSoftware designTypeScriptSimplicity and complexity

Theo Browne argues against over-annotating TypeScript code, demonstrating how to rely on type inference and use Zod for runtime validation.

I'm getting increasingly tired of the "but TS is so much woooooork" comments so I figured I'd do a rant. If you have friends or coworkers who are using Typescript incorrectly, please send this video to them :) Also please use Zod more it's very good github.com/colinhacks/zod Join the Discord: t3.gg/discord Follow me on Twitter: twitter.com/t3dotgg Follow me on twitch too! twitch.tv/theo (Huge huge huge shout to Idez for this edit you are the fkn best man) Timestamps: intro what's type inference? coding example using zod outro

Why it's here

3 people recommend this

What people say. Recommended for its insights on leveraging TypeScript's type inference to reduce unnecessary boilerplate and refactoring overhead.

u/it-birdsin r/typescript • Recommends

On “Are type interfaces nessecary?”

I also wrote a lot of interfaces in the past and even typed the output of each function. But at some point this is too much unnecessary overhead. I started to rely more on the typescript type inference and this reduced the amount of refactoring needed, if a code change came along. Here a good reference that describes what I aim for. link to this video > Theo has strong opinions and you should not take all he says for the silver bullet, but the things he says are always interesting. Also (because I have seen it in other comments) I do still enforce strong typings in my projects. "any" is not allowed, but a few edge cases where you cannot get rid of it (mapped types). Furthermore, I can only agree…

u/no-lewdingin r/typescript • Recommends

On “Example folder structures for fullstack React projects”

This link to this video was pretty informative for me on the subject. It’s a rant about type inference but there’s a lot of folder organization stuff there. The TLDR is don’t worry about folder layout so much. Just build with the simplest structure that provides value to you (maybe everything in 1 file) and when you need to expand, refactor your code in a way that’s easy to follow and makes logistical sense for the problem you’re solving.

u/Pateeshin r/typescript • Recommends

On “New to typescript”

watch this video: [video TL;DR type-inference is awesome, the TypeScript compiler probably can infer what the types of your variables are, you don't always have to explicitly state the variable type. TypeScript's strength in my opinion is it's bug-catching, but that doesn't mean you necesarily have to litter your code with explicit type declaration or return types on functions. let the compiler do it's thing. my codebase looks a lot like JS, and there are just bits of type-related syntax where it is necessary.