DEV Community

Discussion on: Using TypeScript to guard against specific React prop combinations

Collapse
 
dorshinar profile image
Dor Shinar

It's a nice approach but I find that it does not scale very well. If prefer something like:

type Shape = "Square" | "Circle";
type Props = { 
  name: string; 
  shape?: Shape; 
}
Collapse
 
svitekpavel profile image
Pavel Svitek • Edited

Of course, this is usual usage. But let's imagine a situation where you would like to restrict combination of parameters to a function which doesn't represent the same "type".

Collapse
 
msholtyfd profile image
Michael Sholty

Yep, this article was purely a thought exercise ✌🏻