News

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 at Converge 360.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube