Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn
Profile photo of Wanda Muriy
Nataliya Muriy
Marketing Content Creator - you name it, she'll write it!
Contributions by Brian Fernandes

If you have kept true to JavaScript (JS), using TypeScript (TS) doesn’t represent abandoning a good old friend. It’s simply moving on to its typed superset – basically, getting JS with optional static types, which gets you the best of both worlds (the JS flexibility and strengthened TS security).  If you have already enjoyed TypeScript’s capabilities, such as early bug detection, easier code navigation and completion, as well as error fixes, then you will love what TS 2.5, the latest stable version, has in store for you.

New Features in TypeScript 2.5

Optional Catch Clause Variable

So what’s new?  As outlined on the TS site, one feature is the optional catch clause variable, a new ECMAScript feature. This is great if you don’t particularly care for the error thrown – there’s no longer any need to declare an unused variable.

Do you happen to be using TypeScript to develop Angular applications? Even if you aren’t, with Angular IDE, TypeScript development is a cinch, with great features like:
  • Advanced content assist & fast validation.
  • Superior syntax highlighting & call/type hierarchies.
  • Refactoring, formatting, quick fixes & linting with TSLint.
  • Powerful debugger.
  • Configuration managed in tsconfig.json to retain compatibility with the command line, and other tools.

New Quick Fixes

There are some new quick fixes available too – if you’re used to declaring JSDoc-style types, the quick fix will suggest the appropriate TS equivalent.

qf-in-angular-ide

There’s also a new quick which fix will correct incorrect references to the type of a property:

qf_type_ref

The attention to these aspects, this sort of mistake that you might make while coding, is impressive – kudos to the TS team!

On the refactoring front, thanks to TypeScript 2.5, in 2017 CI 10, you’ll be able to extract methods and functions from blocks of code, making it much easier to modularize and reuse your code – a staple Eclipse JDT feature which will soon be available to TypeScript developers.

Advanced Capabilities

Type Checking in JavaScript

If you have a hybrid project which contains both JS and TS source, and you are using TypeScript for type-checking in JavaScript, using JSDoc type assertions will result in more accurate validation.

The syntax is: var x = /** @type {SomeType} */ (AnyParenthesizedExpression);
An example: var bar = /** @type {string} */ (foo);

Better handling of Multiple Resolutions

TypeScript 2.5 will also alleviate the headaches caused by multiple resolutions of the same file – but only if you’re using the Node module resolution strategy. With this version of TS, you will no longer encounter trouble if two packages happen to have identical class declarations but with structurally incompatible private members. How is that achieved? Thanks to the compiler checking for file origin and redirecting to the top-most package in case the file comes from “a package with a package.json containing the same name and version fields as a previously encountered package”, as explained in this blog. Since .d.ts files from duplicate packages will not be loaded, both the memory and the compiler’s runtime footprint will be reduced.

A New Flag

Another added feature of TS 2.5, is the --preserveSymlinks flag, which functions in a similar fashion to the –preserve-symlinks flag in Node.js. As explained here, when using it, “references to modules and packages are all resolved relative to the location of the symbolic link file, rather than relative to the path that the symbolic link resolves to”.

What’s Next

Even though TS 2.5 includes quite a few improvements, as always, work continues – there are already some plans as to what the following version will bring. Our favorite features in TS 2.6, are strict function types and some cool quick fixes. Refer to the Roadmap for further details.

As far as version 2.5 is concerned, you will be able to use it with Angular IDE, Webclipse and MyEclipse, later this week, when we release 2017 CI 9.

Related Posts

Angular 5 Features Front-end developers, rejoice - after a short delay, the Angular 5 release is scheduled for October 23rd!Update (November 1st): It's finally here! After ten release candidates, Angular version 5.0.0, "pentagonal-donut", has been released.Update (October 31st): Well, we're still waiting for Angular version 5, and we're now at 5.0.0 RC 9 - but, I'm s...
Using Swagger to Connect a Backend to an Angular F... IntroductionLet’s say you have an advanced backend system, for which you wish to develop a modern Angular frontend, or, perhaps it’s not your backend, but something public like Facebook, and you want to develop a site using some of its exposed APIs. Of course, you want to do this with minimal effort ... how do you pull this off? Enter Swagger!This ...
TypeScript 2.4 — Even More Reasons to Love i... Perhaps you are already enjoying all the amazing features TypeScript (TS) adds to JavaScript: you might already be in love with its interfaces, abstract classes, and algebraic data types, among many others. TS 2.4 brings more good news. This version of TS comes loaded with improvements, ranging from dynamic import expressions to weak type detection...
Slack Is Using TypeScript, and You Should Too! Building a desktop application with multiple threads is a challenge not everyone is up to. No problem for TypeScript, though! All the pieces must fit in perfectly to make sure an application doesn’t crash due to even a tiny mistake. For this reason, folks at Slack (and many others) have put their faith in it. How is this made possible? Felix Rieseb...

Posted on Oct 30th 2017