Daniel Rosenwasser, Microsoft program manager for TypeScript, used an example in which two types, "Circle" and "Square," have a union type, "Shape." In TypeScript 1.8, writing a function to get the area of Shape required a type assertions for each type, whereas TypeScript 2.0 understands how to discriminate based on the "kind" field.
The release candidate also features more literal types. "We wanted to give some more love to types other than just 'string'," Rosenwasser said. "In 2.0, each unique 'boolean,' 'number,' and 'enum' member will have its own type." The new version adds globs, for writing out wild cards for paths when working with tsconfig.json file capability, reducing tedium for developers.
The release candidate is downloadable for use with Visual Studio 2015 and can be accessed via NuGet or NPM, using NPM install -g typescript@rc.
Sign up for CIO Asia eNewsletters.