DEV Community

Discussion on: Type | Treat Challenge 4

Collapse
 
dungdung profile image
Houston

Is this an acceptable answer to yesterday's beginner problem?

type House<R extends "treat" | "trick" | "no-show"> = {
  location: string
  result: R
}

type Treat = House<"treat"> & { treat: { candy: string, baked?: string } }
type Trick = House<"trick"> & { trick: string }
type NoShow = House<"no-show">
Enter fullscreen mode Exit fullscreen mode
Collapse
 
orta profile image
Orta

Yep - it's a solid answer too!

Collapse
 
dungdung profile image
Houston

Thanks!