What’s new in TypeScript 3.1

TypeScript 3.1 adds properties on function declarations, and moves away from the namespaces construct

Become An Insider

Sign up now and get FREE access to hundreds of Insider articles, guides, reviews, interviews, blogs, and other premium content. Learn more.

TypeScript 3.1, Microsoft’s typed superset of JavaScript, is now generally available for production deployments, featuring programming enhancements including mappable tuple and array types.

Where to download TypeScript

You can download the production version of TypeScript through NuGet or via NPM. To get TypeScript via NPM, use the following command: npm install -g typescript.

Current version: The new features in TypeScript 3.1

TypeScript 3.1 adds properties on function declarations. Thus, for any function or const declaration that is initialized with a function, the type-checker analyzes the containing scope to track added properties. This change is intended to make TypeScript smarter about patterns.

With JavaScript, functions are objects, with developers able to tack properties on them. TypeScript’s traditional approach to this has been through the namespaces construct. But this construct has not aged well. ECMAScript modules have become the preferred mode for organizing new code in TypeScript and JavaScript, but namespaces are TypeScript-specific. Also, namespaces do not merge with var, let, or const declarations, which can make code conversions difficult. These issues can make it tougher to migrate to TypeScript.

To continue reading this article register now