Skip to content
0:00 / 0:00

#typescript#react#conditionaltypes

How Did I Not Know This TypeScript Trick Earlier??!

Josh tried coding

174K subscribers • 1 video on Hallway

YouTube
  • Recommended by 2 people: 2 in engineering communities.
  • Presented by Josh

Intermediate. Assumes working knowledge.

234K views3 years ago2 recommendations

Programming languagesWeb developmentTypeScriptReact

Josh explains how to conditionally include types in TypeScript, which is especially useful for defining dynamic React component props.

This TypeScript trick to conditionally include types is so useful, especially for React props. I've asked myself how this is done many times before, and it's just really cool to learn something so simple yet useful. -- links Discord: discord.gg/4vCRMyzgA5 My GitHub: github.com/joschan21

Why it's here

2 people recommend this

What people say. Recommended for developers who need to change a component's type based on the value of a specific property.

u/oxy1sin r/typescript • Recommends

On “Newbie TS Question”

check out this vid it might be what you want, if you need the type to change based on a property: link to this video

u/cardyetin r/typescript • Recommends

On “How do I make sure that data is of type URL or Code only if action is of value URL or Code?”

This guy (my new fave) on YouTube has done a video on this recently link to this video