TypeScript and the path to version 2.0

Original author: Jonathan Turner
  • Transfer
var t: [number, string] = [1, "hello"];
t = [];                 // Error
t = [1];                // Error
t = [2, "test"];        // Ok
t = ["test", 2];        // Error
t = [2, "test", true];  // Ok

When we released TypeScript 1.0 earlier this year, we focused on creating a language that helps developers really scale their JavaScript projects. It was pretty fun to watch what people did with him, including 170,000 lines of code at Mozilla Shumway , Walmart stationery and our wealth of experience with Microsoft Azure , in which we jumped over a million lines of code.

Our goal at TypeScript is to continue to support projects of this magnitude and make it the best language for scaling JavaScript. With version 1.1, we released a fast and lightweight compiler that can produce results four times faster than the previous one. The new compiler is also more flexible with regard to adding new functionality than we will certainly take when moving to version 2.0.

Today we want to talk about our plans for the second version. We invite you to join our TypeScript page on GitHub and help us make TypeScript even better.

The growth of the JavaScript typing community


The JavaScript typing community continues to grow, we are happy to see this and be part of it. DefinitelyTyped today contains more than 700 .d.ts typed descriptions for a wide range of libraries and frameworks and is close to breaking the 600-contributor bar.

We are also seeing new projects growing out of the work done by the JavaScript typing community. The first of these, the Flow language from Facebook, announced earlier this year. It is based on modules as the fundamental building block for applications and adds a rich typed interface and compatibility with .d.ts to them. The second project, called AtScript, was recently announced by the Angular team at Google. It is based on type annotations similar to TypeScript, and adds metadata annotations and validation at runtime.

The TypeScript team works with both commands (Flow and AtScript) to ensure that resources already created by the JavaScript typing community can be used in these tools. All projects can learn a lot from each other, we look to the future to work together to create the best tools for the JavaScript community. In the long run, we also strive to ensure that the best features of these tools are also included in ECMAScript, the standard behind JavaScript.

Road map


TypeScript 1.3


Our next release will be TypeScript 1.3, it will include a new rewritten language service that will make the development process in code editors faster and smoother. It will also be the first release in which we will begin standardizing the compiler API so that tools can rely on it completely. As part of this release, we will also show previews of the new version of integration in Visual Studio, which will subsequently become part of it.

From a language point of view, we are adding two new features: protected and type tuples (tuple). The secure access modifier has been one of the most frequently requested features for quite some time, we are pleased to add additional object-oriented templates to TypeScript. With type tuples, we begin to expand the type system in order to synchronize with practices that will be based on the features of the upcoming ECMAScript 6. More specifically, this will allow the type-safe use of array destructuring, considered as tuples.

You may be asking, “Where is TypeScript 1.2?” We expected to use it as a release to stabilize the previous version, but version 1.1. It turned out to be stable enough for developers to switch to it. This allowed us to proceed to complete work on the language service and add new features earlier than we originally planned.

TypeScript 1.4


In release 1.4, we want to focus on the further development of the language. The first new features are already available in the master verification on GitHub. These include type joins and the use of typeof in if blocks to specify types. Both features are shown in the example below:

function createCustomer(name: { firstName: string; lastName: string } | string) {
    if (typeof name === "string") {
        // Because of the typeof check in the if, we know name has type string
        return { fullName: name };
    }
    else {
        // Since it's not a string, we know name has 
        // type { firstName: string; lastName: string }
        return { fullName: name.firstName + " " + name.lastName };
    }
} 
// Both customers have type { fullName: string }
var customer = createCustomer("John Smith"); 
var customer2 = createCustomer({ firstName: "Samuel", lastName: "Jones" });

Both features together allow you to use more natural patterns when working with JavaScript code. Type associations, allowing more precise description of types with multiple variants, also help alleviate some of the pain points of earlier TypeScript versions that arose when working with mixed arrays.

From TypeScript 1.5 to TypeScript 2.0


Looking to the future with release 2.0, we are focusing on two goals, in addition to our primary goal of providing the best tools for JavaScript development. The first is to dock with ES6. Synchronization with ES6 will allow TypeScript to become a superset of the next version of JavaScript, opening up the opportunity to work on new templates and code-building practices, including destructuring, string templates, promises, iterators, etc. in addition to the features that TypeScript already supports, for example, classes and lambda -functions. Second, we also work with the Flow and Angular teams to make sure TypeScript is the best language for working with a wide range of libraries, including declarative frameworks like the upcoming Angular 2.0 release.

Looking to the future


There is a lot of work ahead, but we are already well on our way. You can try some of the features mentioned above by taking the latest source code from our TypeScript repository on GitHub . We adopted the GitHub style for laying out specifications along with the use of pull requests. This will allow you to keep track of new features as they are developed, and we will also be happy to hear your feedback.

useful links



Also popular now: