BT

New Early adopter or innovator? InfoQ has been working on some new features for you. Learn more

TypeScript 2.5 Released, Adds Language Level Refactoring

| by David Iffland Follow 3 Followers on Sep 04, 2017. Estimated reading time: 1 minute |

In version 2.5 of TypeScript, Microsoft has focused on developer productivity and broadened the scope of what it can do by offering features typically found in code editors.

Developers accustomed to typed languages such as C# have enjoyed tooling that can easily perform common refactorings. Now, TypeScript has the ability to use its knowledge of the code to perform perform Extract Function and Extract Method refactorings. But TypeScript is a language service, not an editor, so the addition of this feature to the language service means that all editors will be able to hook into the service to provide this refactoring. Daniel Rosenwasser, program manager for TypeScript, says the team is focused on the developer experience, not just the language:

TypeScript as a language is developed with the editing experience in mind, and so our team works on both the compiler/type-checker as well as the language service that powers editors like VS Code in mind. It's not just VS and VS Code. The changes are available to any editor that consumes our language service, and so I think these editing features will be useful to know about as a TypeScript user.

These refactorings will show up in VS Code and Visual Studio soon.

Microsoft also boosted the "quick fix" arsenal by catching accidental usages of JSDoc type declarations and incorrect type referencing. The quick fix language service API was first made available in TypeScript 2.1 and includes corrections such as spelling, missing imports, missing this, and unused declarations. More fixes are already on the roadmap.

This release is light on language features, but one of the only notable ones is called optional catch variables. This ability is useful when you need to catch an error, but you don't care about the actual contents of the error. This feature is actually a part of an ECMAScript proposal. The following code, which does not include a declaration of the caught error, is now valid:

try {
    const result = someMethodThatWillThrowAnException();
}
catch {
    contents = createDefaultContents();
}

As always, the latest version of TypeScript can be installed with npm install -g typescript or on NuGet.

Rate this Article

Adoption Stage
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.

Tell us what you think

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

Email me replies to any of my messages in this thread
Community comments

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

Email me replies to any of my messages in this thread

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

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT