News

TypeScript 2.1 Is Done, But There's More

Following the RC release of 2.1 nearly a month ago, the final version adds a few more tweaks to smooth the coding experience.

Following the TypeScript 2.1 release candidate that hit the Web nearly a month ago, the finalized version adds a few more tweaks to smooth the coding experience.

"This release comes with features that we think will drastically reduce the friction of starting new projects, make the type-checker much more powerful, and give you the tools to write much more expressive code," writes Microsoft Program Manager Daniel Rosenwasser, in a blog post. His post covers lots of ground: async functions, support for object rest & spread, lookup types, mapped types, more utility types, and easier package imports.

Async functions were a part of the 2.1 RC, but in this release it's been tested and stable when targeting ES3/ES5.

Rosenwasser notes that object rest & spread are part of the ES2017 proposal "that makes it much easier to partially copy, merge, and pick apart objects." Object spreads use the spread operator to streamline copying of properties from object to object, while object rests can be extracted into distinct variables.

TypeScript 2.1 also has support for lookup types and mapped types. "Mapped types are produced by taking a union of literal types, and computing a set of properties for a new object type," he writes. He also notes that with the addtion of mapped types, partial type operators aren't absolutely necessary. Even so, support for partial is incorporated into 2.1, as are several others: readonly, record and pick. Rosenwasser points to a Github lib.d.ts file that provides usage examples.

To reduce editing friction, version 2.1 automatically makes assumptions about packages that are installed, bypassing the need to declare them. "We decided that TypeScript needs to be more trusting, and in TypeScript 2.1, so long as you have a package installed, you can use it," he said. Rosenwasser does caution that because of its more trusting nature, there's the assumption that installed package "has the type any, meaning you can do anything with it."

Rosenwasser's blog at the end also links to additional features, including support for custom elements and importing helper functions.

On a related note: Be sure to read Visual Studio Magazine columnist Peter Vogel's recent TypeScript 2.0 coverage on data typing and class discriminants.

About the Author

Michael Domingo is a long-time software publishing veteran, having started up and managed several developer publications for the Clipper compiler, Microsoft Access, and Visual Basic. He's also managed IT pubs for 1105 Media, including Microsoft Certified Professional Magazine and Virtualization Review before landing his current gig as Visual Studio Magazine Editor in Chief. Besides his publishing life, he's a professional photographer, whose work can be found by Googling domingophoto.

comments powered by Disqus

Featured

  • Hands On: New VS Code Insiders Build Creates Web Page from Image in Seconds

    New Vision support with GitHub Copilot in the latest Visual Studio Code Insiders build takes a user-supplied mockup image and creates a web page from it in seconds, handling all the HTML and CSS.

  • Naive Bayes Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the naive Bayes regression technique, where the goal is to predict a single numeric value. Compared to other machine learning regression techniques, naive Bayes regression is usually less accurate, but is simple, easy to implement and customize, works on both large and small datasets, is highly interpretable, and doesn't require tuning any hyperparameters.

  • VS Code Copilot Previews New GPT-4o AI Code Completion Model

    The 4o upgrade includes additional training on more than 275,000 high-quality public repositories in over 30 popular programming languages, said Microsoft-owned GitHub, which created the original "AI pair programmer" years ago.

  • Microsoft's Rust Embrace Continues with Azure SDK Beta

    "Rust's strong type system and ownership model help prevent common programming errors such as null pointer dereferencing and buffer overflows, leading to more secure and stable code."

  • Xcode IDE from Microsoft Archrival Apple Gets Copilot AI

    Just after expanding the reach of its Copilot AI coding assistant to the open-source Eclipse IDE, Microsoft showcased how it's going even further, providing details about a preview version for the Xcode IDE from archrival Apple.

Subscribe on YouTube

Upcoming Training Events