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

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

  • What's New for Python, Java in Visual Studio Code

    Microsoft announced March 2024 updates to its Python and Java extensions for Visual Studio Code, the open source-based, cross-platform code editor that has repeatedly been named the No. 1 tool in major development surveys.

Subscribe on YouTube