Feeling Like I'm at Hogwarts
I spent some time this week playing with Typescript 2.8’s new features for modeling various complex types. The new syntax that I wanted to play with was the conditional type syntax, 1 T extends U ? X : Y This syntax allows you to express some really crazy type relationships! Some of the most interesting ones have been pre-defined in the Typescript standard lib: Exclude<T, U> – Exclude from T those types that are assignable to U. Extract<T, U> – Extract from T those types that are assignable to U. I wanted to see if I could use these to model the way we’ve been working with return values from Contentful’s Content Delivery API. ...