BT

InfoQ Homepage News TypeScript 3.3 Improves Calling Union Types and Build Times

TypeScript 3.3 Improves Calling Union Types and Build Times

Bookmarks

The TypeScript team continues its bi-monthly release cadence with version 3.3 of TypeScript, improving the behavior for calling union types and the performance of incremental file watching for composite projects. The team also announced the TypeScript roadmap for the next six months.

TypeScript 3.0 added support for composite projects allowing large projects to be separated into smaller projects to improve build times with the --build mode, recompiling only the necessary subset of projects and dependencies to optimize inter-project builds. At the same time, TypeScript also added an intra-project incremental build API which can update files which change or those with dependencies that could impact type checking.

After the 3.0 release, complaints about performance size for using the --watch flag on composite projects increased. Composite projects were not leveraging the intra-project incremental builds, instead of requiring a full build of that project.

The TypeScript 3.3 --build mode --watch flag now leverages incremental file watching to significantly improve build time in --watch mode, reducing build times by an average of 50-75%.

TypeScript supports union types which allow developers to access all properties common to all members of the union. When calling types, it was not previously possible to easily define a union for the return type if every type did not have just one call signature with identical parameters.

With TypeScript 3.3, the parameters of each union member are intersected together to create a new signature. The new behavior only gets applied when up to one type in the union has multiple overloads and up to one type in the union has a generic signature. The TypeScript team identifies this addition to TypeScript 3.3 as a first step for improving this scenario, and may look for further refinements in future releases.

Compared to recent releases, the TypeScript 3.3 release has a relatively modest number of new features, mostly due to the bi-monthly release cadence spanning the winter holiday break, but may also reflect the TypeScript team's six month roadmap, which shows a renewed emphasis on work beyond adding more features to the language:

  • Types on every desk, in every home, for every JS developer
  • Productivity through strong tooling
  • Approachability and UX
  • Community engagement
  • Infrastructure and engineering systems

The TypeScript team remains focused on adding new ECMAScript features and refining TypeScript as a language, but it has reached a level of stability where additional effort can emphasize developer ergonomics in general.

TypeScript adoption has snowballed in the JavaScript ecosystem over the past year including recent announcements that the next versions of Vue.js, Jest, and Storybook are migrating to TypeScript. Many developers and projects are migrating from JavaScript, while others are migrating from Flow.

Ovidiu Bute, software engineering manager at Hootsuite, explains their migration to TypeScript:

We also looked at the communities around these two projects. Flow is a language that, at least a year ago when we ran this analysis, was being driven by Facebook in a very closed manner. Development was never transparent, there was no public roadmap, and very few people outside of Facebook were contributing to the project. TypeScript, in contrast, embraced open-source development since moving to GitHub a few years ago. They keep an up-to-date roadmap, accept outside contributions, and generally keep a very close relationship to the community.

Babel founder and Facebook engineer Sebastian McKenzie explains in response to a user asking about a Flow feature:

I’d honestly recommend switching to TypeScript these days because Flow open source is neglected a lot.

The Flow team has begun to address these concerns with an updated look at recent progress and plans for 2019. In this overview, Facebook software engineer Avik Chaudhuri sheds some light on migrations from Flow to TypeScript:

Recently a bunch of open-source projects originally created at Facebook published plans to be rewritten in TypeScript. At Facebook we strongly value the independence of individual teams in creating their roadmaps, and in doing the best they can for the products they build. The projects that have decided to switch to TypeScript have external contributors whose lives will be much easier with this switch, and we respect these decisions.

With many existing frameworks authored in TypeScript including Angular, Dojo, and Ionic, and other frameworks either planning to switch to TypeScript or at a minimum offering type definitions or CLI tooling for setting up a TypeScript app with that framework, a significant subset of JavaScript developers now leverage TypeScript.

TypeScript is open source software available under the Apache 2 license. Contributions and feedback are encouraged via the TypeScript GitHub project and should follow the TypeScript contribution guidelines and Microsoft open source code of conduct.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.