News

TypeScript 2.1 Is Now Smarter Than Ever

It's like a better version of TypeScript 2.0, only this incremental update adds "smarter" inference and a bevy of other improvements.

New this week is a version of TypeScript 2.1 that follows the version 2.0 release of nearly a month ago, only this one is naturally better. It's better in that it adds "smarter" inference for better tooling and a handful of small but important improvements to try out.

"TypeScript 2.1 now makes it easier to model scenarios where you might incrementally initialize variables," writes Microsoft Program Manager Daniel Rosenwasser, in a blog. "Since a lot of code is written like this in JavaScript, this makes it even easier to migrate existing codebases to TypeScript."

Rosenwasser holds up the any type as an example in his post: TypeScript will assign an implicit any type to a variable if one isn't assigned to it. That's all well and good with earlier versions, but he said that "[w]ith TypeScript 2.0 we built out a foundation of using control flow analysis to track the flow of types throughout your program. Because that analysis examines the assignments of every variable, we've leveraged that same foundation in TypeScript 2.1 to more deeply examine the type of any variable that seems like it's destined for a better type." So, TypeScript no longer assigns any to a variable, but smartly infers the variable's type based on what you assign to it.

TypeScript 2.1 also has support for async/await. If this capability looks familiar, Rosenwasser notes that it has existed in earlier versions of TypeScript that were used to target ES6 and ES 2015. "TypeScript 2.1 brings the capability to ES3 and ES5 runtimes, meaning you'll be free to take advantage of it no matter what environment you're using," he writes.

On a side note, on the GitHub page for TypeScript there's also a nifty roadmap of features coming in subsequent releases. The notes shows that support for project references, addition of variadic types and partial types, and support for type-checking of computed properties for constants and symbols are expected in the next update.

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

  • Visual Studio Code Dev Team Cleans Up

    The Visual Studio Code development team focused on some housekeeping in the October update, closing more than 4,000 issues on GitHub, where the cross-platform, open-source editor lives.

  • ML.NET Model Builder Update Boosts Image Classification

    Microsoft announced an update to the Model Builder component of its ML.NET machine learning framework, boosting image classification and adding "try your model" functionality for predictions with sample input.

  • How to Do Naive Bayes with Numeric Data Using C#

    Dr. James McCaffrey of Microsoft Research uses a full code sample and screenshots to demonstrate how to create a naive Bayes classification system when the predictor values are numeric, using the C# language without any special code libraries.

  • Vortex

    Open Source 'Infrastructure-as-Code' SDK Adds .NET Core Support for Working with Azure

    Pulumi, known for its "Infrastructure-as-Code" cloud development tooling, has added support for .NET Core, letting .NET-centric developers use C#, F# and VB.NET to create, deploy, and manage Azure infrastructure.

  • .NET Framework Not Forgotten: Repair Tool Updated

    Even though Microsoft's development focus has shifted to the open-source, cross-platform .NET Core initiative -- with the aging, traditional, Windows-only .NET Framework relegated primarily to fixes and maintenance such as quality and reliability improvements -- the latter is still getting some other attention, as exemplified in a repair tool update.

.NET Insight

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.

Upcoming Events