TypeScript 2.8 Officially Released: Hello Conditional Types
Less than two weeks after publishing the TypeScript 2.8 Release Candidate, Microsoft has officially launched it into general availability.
In TypeScript 2.8 the new functionality involving the ternary operator opens up all kinds of possibilities, Microsoft's Daniel Rosenwasser explained:
Conditional types are a new construct in TypeScript that allow us to choose types based on other types. They take the form
A extends B ? C : D
Although that's the simplest example, the new feature can be put to many more complicated use cases, including working with generics.
"While conditional types can be a little intimidating at first, we believe they'll bring a ton of flexibility for moments when you need to push the type system a little further to get accurate types," Rosenwasser said.
The new conditional type functionality stems from a pull request for Microsoft's open source programming language announced by Technical Fellow Anders Hejlsberg on Jan. 20. That PR goes into all of the nitty-gritty details of the new feature, also explained further in Rosenwasser's post.
Speaking of which, Rosenwasser also summarized the following features in TypeScript 2.8:
TypeScript has apparently already been making its users happier, as it was named a popular programming language in Stack Overflow's big developer survey and the most recent RedMonk language popularity report -- though some developers have debated its perceived "bloat."
More information can be found in the list of breaking changes and the language's roadmap, which shows what's coming next, including generic JSX elements.
David Ramel is an editor and writer for Converge360.