Check out all the new features and improvements

Discovering TypeScript 2.7— From pretty to prettier and from clean to cleaner

Eirini-Eleni Papadopoulou
© Shutterstock / By  

TypeScript 2.7 is here and it seems that developers have taken well into account pull requests for error fixing in numerous features while introducing new tools.

For those of you who are not familiar with TypeScript, let me give you a small introduction. TypeScript was first introduced in 2012 as a strict syntactical superset of JavaScript designed for the development of large applications. It is open source, developed and maintained by Microsoft. If you are interested in getting more familiar with TypeScript, check out our tutorial here.

Now, without further ado, let’s dig in all the changes of the latest release.

According to the official release notes, the most significant changes and new additions are the following:

  • Stricter class property checks
  • Definite assignment assertions
  • Easier ECMAScript module interoperability
  • unique symbol types and const-named properties
  • Cleaner output in –watch mode
  • Prettier –pretty output
  • Numeric Separators
  • Fixed Length Tuples
  • in operator narrowing and accurate instanceof
  • Smarter object literal inference

But let’s have a closer look at some of the features.

Stricter class property checks

The new strictness flag named -- strictPropertyInitialization makes sure that each instance property of a class gets set in the constructor body. However, you should pay attention when initializing --strictPropertyInitialization since it will be turned on along with other -- strict mode flags that can impact the whole project.

Easier ECMAScript module interoperability

As part of the endeavor to find the best way to interoperate with existing “legacy” module formats, TypeScript introduces the new -- esModuleInterop flag for callable Common JS modules. Under the new feature, these modules must be imported as default imports, as seen below:

import express from "express";

let app = express();

Cleaner and prettier

As mentioned before, TypeScript developers had a closer look into request and feedback and incorporated the suggested error fixes and improvements to the best of their ability. To give some examples, -- watch mode now clears the screen after requesting a re-compilation while -- pretty flag now uses colors for file names, diagnostic codes and line numbers as well as fine names and positions are now formatted in a manner that common terminals can allow a Ctrl+Click, Cmd+Click, Alt+Click, etc. to move to the appropriate location in the editor.#

SEE ALSO: TypeScript — a trend that keeps on trending

in operator narrowing and accurate instanceof

Two changes are featured in operator narrowing in 2.7. In order to help avoid complex issues when using instanceof to narrow from structurally similar, though unrelated types, the instanceof operator now leverages the inheritance chain instead of relying on structural compatibility while the in operator now acts a type guard to narrow out types that do not explicitly declare properties of a given name.

All in all, the error fixes included in the new release, as suggested by TypeScript users, appear to be right on point while the new tools promise a more organized and neater coding environment. TypeScript’s unique feature of optional static typing allows you to write JavaScript the way you want to! And with the new and improved features, the ride seems to be even smoother, cleaner and prettier!


Eirini-Eleni Papadopoulou
Eirini-Eleni Papadopoulou was the editor for Coming from an academic background in East Asian Studies, she decided that it was time to go back to her high-school hobby that was computer science and she dived into the development world. Other hobbies include esports and League of Legends, although she never managed to escape elo hell (yet), and she is a guest writer/analyst for competitive LoL at TGH.

Inline Feedbacks
View all comments