With TypeScript version 2.5, Microsoft’s focus on improving developer productivity goes beyond the usual functionality provided by code editors.

Developers accustomed to typed languages such as C# prefer tools that make it easy to perform common refactorings. TypeScript now leverages its knowledge of language code to perform Extract Function and Extract Method refactorings. But TypeScript is a language service, not an editor, so adding this functionality to a language service means that all editors can refactor by hooking services. TypeScript project manager Daniel Rosenwasser says the team focuses on improving the developer experience, not just the language:

These refactorings will be applied in VS code and Visual Studio.

Microsoft has also improved the toolset’s “quick fixes” by catching unexpected uses of JSDoc type declarations and incorrect type references. TypeScript 2.1 first provides apis for quick fixes to language services, including typos, missing imports, missing this, and unused declarations. More fixes have been planned.

This release does not focus on language features, but the only notable one is the optional catch variable. This feature is useful when developers need to catch errors without having to worry about the actual content of the error. This feature is actually part of the ECMAScript proposal. The following example does not include a declaration to catch an error, so it is now true:

__Mon Sep 11 2017 15:05:53 GMT+0800 (CST)____Mon Sep 11 2017 15:05:53 GMT+0800 (CST)__try {
    const result = someMethodThatWillThrowAnException();
}
catch {
    contents = createDefaultContents();
}
__Mon Sep 11 2017 15:05:53 GMT+0800 (CST)____Mon Sep 11 2017 15:05:53 GMT+0800 (CST)__Copy the code

As before, the latest versions of TypeScript can be installed via NPM install -g typescriptor or NuGet.

TypeScript 2.5 Released, Adds Language Level Refactoring


Thanks to Dongyu for correcting this article.

To contribute or translate InfoQ Chinese, please email [email protected]. You are also welcome to follow us on Sina Weibo (@InfoQ, @Ding Xiaoyun) and wechat (wechat id: InfoQChina).