What's New in TypeScript 2.8 RC

Microsoft is seeking developer feedback for the new TypeScript 2.8 release candidate, featuring new conditional types and more.

TypeScript was deemed a popular programming language in Stack Overflow's big developer survey and the most recent RedMonk language popularity report. It's an open source language backed by Microsoft that provides optional static typing while remaining a strict syntactical superset of JavaScript.

In highlighting the new features of TypeScript 2.8 RC, Microsoft's Daniel Rosenwasser introduced a new construct called conditional types.

"Conditional types help model simple choices made over based on types at runtime, but afford significantly more expressive constructs at design-time," Rosenwasser said. "Conditional types also provide us with a new way to infer types from the types we compare against using the new infer keyword which introduces a new type variable."

Other highlights were described by Rosenwasser thusly:

  • JSX pragmas: TypeScript now lets developers provide a pragma in order to specify the source of a JSX factory within any file.
  • Granular control on mapped type modifiers: "TypeScript 2.8 allows more explicit syntax for adding and removing modifiers in mapped types with the + and - operators." Previously, he said, mapped types could only add such modifiers if they already existed, which resulted in limitations when working with homomorphic mapped types -- copying all modifiers from the original type.
  • JSX.Element is resolved via the JSX Factory: This can shorten lookups for certain JSX types, such as a component. Where previously this lookup examined the global JSX namespace first, now the compiler will first attempt to search the JSX namespace where a JSX factory is located. "For example, if your JSX factory is React.createElement, TypeScript will try to first resolve React.JSX.Element, and then resolve JSX.Element within the current scope."

You can read more details about the above, along with some other new features, breaking changes and more in Rosenwasser's post, published yesterday (March 15).

Future changes for the language can be found in the roadmap, which includes a tweeted proposal maintaining that "TypeScript error messages should always come in haiku form."

[Click on image for larger view.] "TypeScript error messages should always come in haiku form." (source: Twitter).

Other features planned include:

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus


  • VS Code Now Has Apple Silicon Builds for Native Mac Development

    Goodbye Rosetta, hello M1. Visual Studio Code has been updated with new builds that let it run natively on machines with Apple Silicon (M1), the company's own ARM64 chips.

  • Visual Studio 2019 for Mac v8.9 Ships with .NET 6 Preview 1 Support

    During its Ignite 2021 online event for IT pros and developers this week, Microsoft shipped Visual Studio 2019 for Mac v8.9, arriving with out-of-the-box support for .NET 6 Preview 1, which the company also released recently.

  • Analyst: TypeScript Now Firmly in Top 10 Echelon (Ruby, Not So Much)

    RedMonk analyst Stephen O'Grady believes TypeScript has achieved the rare feat of firmly ensconcing itself into the top 10 echelon of his ranking, now questioning how high it might go.

  • Black White Wave IMage

    Neural Regression Using PyTorch: Training

    The goal of a regression problem is to predict a single numeric value, for example, predicting the annual revenue of a new restaurant based on variables such as menu prices, number of tables, location and so on.

Upcoming Events