Announcing TypeScript 1.3

Luke Hoban [MS]

We’re happy to announce the availability of TypeScript 1.3. TypeScript 1.3 includes two new features in the language and a new language service for Visual Studio 2015 that is built on the .NET Compiler Platform (“Roslyn”), Visual Studio’s new language service that provides rich Intellisense. Roslyn makes it much easier to provide a premier editing experience for TypeScript in Visual Studio on par with the other first-class languages in Visual Studio.

TypeScript 1.3 is available as part of Visual Studio 2015 Preview. You can also install it for Visual Studio 2013 via the power tool install, NPM, and as source.

New Language Features 

We’ve added two new language features in TypeScript 1.3: the “protected” access modifier and tuple types.

The “protected” access modifier is a highly requested feature that allows users the ability to use build even richer objected-oriented patterns in TypeScript. In this example, you can see how the protected keyword allows subclasses to gain visibility into the parent class without exposing this API to other parts of the code.

class List<T> {
    private contents: T[];
    constructor() {
        this.contents = [];
    }
    protected setElement(index: number, item: T) {
        this.contents[index] = item;
    }

}

class Stack<T> extends List<T> {
    currentIndex: number;

    constructor() {
        super();
        this.currentIndex = 0;
    }

    public push(item: T) {
        this.setElement(this.currentIndex, item);
        this.currentIndex++;
    }
}

var stack = new Stack<number>();
stack.setElement(0, 1); // error ‘setElement’ is protected and only visible to subclasses 

Tuple types allow TypeScript to begin typing the new patterns we will see in the upcoming ECMAScript 6 standard, where new features like array destructuring allow developers to work with arrays in richer ways. Tuple types have the advantage that now you can accurately describe the type of an array of mixed types, as in this example:

var tuple: [number, string] = [1, “bob”];
var secondElement = tuple[1];  // secondElement now has type ‘string’ 

 

New Visual Studio Features 

With TypeScript 1.3, we’ve built a new Visual Studio 2015 language service on Roslyn, the compiler platform that’s a part of the open source .NET Foundation. Roslyn allows us to enable a number of new features for editing TypeScript code.

 

Faster and more accurate find all references

We have made fundamental changes to how compute and report references. Computing references is now significantly faster on the first attempt. Find All References now also reports locations where a contextual type is present, and reports indexed access to properties.

 

Enhanced completion list

TypeScript now supports the same trigger commit characters as C#, so “enter” or “tab”  both commit your selection from the completion list. TypeScript also has completion list filtering based on camel casing.

  

Enhanced outlining

With the “Roslyn” language service everything is now collapsible –  including functions, object literals, classes, and control flow blocks.

Enhanced Colorization

Classes, Interfaces, modules, enums are now colored according to their kind.  Keywords are also now colorized correctly according to their context.

 

Peek 

Editor peek is now available, enabling you to quickly see declarations at a glance complete with colorization.

Enhanced rename

TypeScript now supports inline rename with even more accuracy than before. Rename finds all instances the name even if it does not have an explicit type annotation –  including strings used in property access.

  

TODO comments support

 

TODO comments are now populated in the tasks list.

 

 

Better support for functional programming style

We have made several changes to ensure that our tools work well with different JavaScript coding patterns. Specifically, we’ve improved support for the functional programming style by improving how the editor works with nested functions. Now “Navigate To” shows you nested functions, and the navigation bar shows where you are based on your enclosing function scopes.

 

Looking Ahead

We’re pleased to enable more coding patterns and improve the Visual Studio experience of working with TypeScript. We look forward to continuing to enhance the language and tools for working with large-scale JavaScript projects. To find out more about what we’ll be working on next, check out our roadmap. We encourage you to try out this release and give us your feedback.

0 comments

Discussion is closed.

Feedback usabilla icon