DEV Community

Discussion on: Type | Treat Challenge 2

Collapse
 
mattiasbuelens profile image
Mattias Buelens

Also, the proposed solution for AllCandies removes all candies from the union, instead of only keeping the candies.

type AllCandies = Exclude<ResultsFromHalloween, {candy: true}>
// type AllCandies = Toothpaste | Pencil
Enter fullscreen mode Exit fullscreen mode

This should probably use Extract instead of Exclude:

type AllCandies = Extract<ResultsFromHalloween, {candy: true}>
// type AllCandies = SnackBars | Gumballs | Apples | SnickersBar | Cookies
Enter fullscreen mode Exit fullscreen mode