Today, we are thrilled to announce the release of TypeScript 1.7 along with the availability of Visual Studio 2015 Update 1. This release enables async/await by default for ECMAScript 6 (ES6) targets. It also adds support for polymorphic ‘this’ typing, proposed ECMAScript 2016 exponentiation syntax, and ES6 module targeting. For a complete change list, check out our roadmap on GitHub.
As always, you can get your hands on TypeScript 1.7 for Visual Studio 2015 Update 1, Visual Studio 2013, on npm, or straight from the source.
Async/Await for ES6 targets
With the 1.7 release, TypeScript now supports Async functions for targets that have ES6 generator support enabled (e.g. node.js v4 and above). Functions can now be prefixed with the async keyword designating it as an asynchronous function. The await keyword can then be used to stop execution until an async function’s promise is fulfilled. Following is a simple example:
“use strict”;
// printDelayed is a ‘Promise<void>’
async function printDelayed(elements: string[]) {
for (const element of elements) {
await delay(200);
console.log(element);
}
}
async function delay(milliseconds: number) {
return new Promise<void>(resolve => {
setTimeout(resolve, milliseconds);
});
}
printDelayed([“Hello”, “beautiful”, “asynchronous”, “world”]).then(() => {
console.log();
console.log(“Printed every element!”);
});
We are working on bringing async/await support in TypeScript for other targets, including a breadth of browsers, which might not have ES6 generators support. For more information on current implementation of async/await and how to use it, see our previous blog post.
Polymorphic this Typing
After much community discussion and feedback, TypeScript 1.7 adds a new polymorphic this type. A this type can be used in classes and interfaces to represent some type that is a subtype of the containing type (rather than the containing type itself). This feature makes patterns such as hierarchical fluent APIs much easier to express.
interface Model {
setupBase(): this;
}
interface AdvancedModel extends Model {
setupAdvanced(): this;
}
declare function createModel(): AdvancedModel;
newModel = newModel.setupBase().setupAdvanced(); // fluent style works
For a deep dive on this typing, checkout the TypeScript Wiki.
As a part of supporting the feature, TypeScript 1.7 has made changes in inferring the type from this. In a class, the type of the value this will be inferred to the this type, and subsequent assignments from values of the original type can fail. As a workaround, you could add a type annotation for this. A code sample with recommended work around, along with a list of other potentially breaking changes is available at GitHub.
ES6 Module Emitting
TypeScript 1.7 adds es6 to the list of options available for the –module flag and allows you to specify the module output when targeting ES6. This provides more flexibility to target exactly the features you want in specific runtimes. For example, it is now a breeze to target Node.js v4 and beyond, which doesn’t support ES6 modules (but does support several other ES6 features).
//tsconfig.json targeting node.js v4 and beyond
{
“compilerOptions”: {
“module”: “commonjs”,
“target”: “es6”
}
}
ES7 Exponentiation
Finally, a little syntactic sugar! The ECMAScript committee recently moved the Exponentiation Operator proposal to stage 3. So we decided it was ready for TypeScript to adopt, and added support for it in TypeScript 1.7.
let cubed = 2 ** 3; // same as: 2 * 2 * 2
num **= 2; // same as: num = num * num;
Say goodbye to Math.pow()!
What’s Next?
We are excited to announce all the new improvements we’ve made in this release, and as always, we would love to hear your feedback. Everything we do is easily viewable on our Github. If you’re interested in weighing in on the future of TypeScript, we encourage you to check out our existing issues, throw us a pull request, or just come hang out with the team on gitter.

Thanks for that!
Cool! Can't wait to play with this!
Keep up the great work!
Your ES7 Exponentiation example seems a little wrong, instead of `2 * 2 * 3` shouldn't it be `2 * 2 * 2`?
thanks @Griffork, should be fixed now.
Congratulations. Love the quicker iteration that is happening.
I've been seeing that there are some breaking changes to the decorators specification. Can you comment on how that will be addressed in TypeScript and what the timeframe for that might be?
@RobEisenberg, Decorators are a proposed future ES feature, and available as an experimental feature; TypeScript is committed to trail the JS committee (TC39) for the final semantics, which might entail some breaks.
We spent the day today with @YehudaKatz, mostly talking about the decorator proposal he is championing in TC39. We still need the proposal to advance in the committee, and to understand the breaking changes needed to align with the final proposal. We need to then come up with a plan for handling any breaks. The breaks should be limited to the TypeScript compiler emit logic, and how decorator library authors handle them, and we will try to synchronize these changes to mitigate the impact for decorator users.
please improve the documentation
What about an example showing decorators for the ES3 Target ? This is really huge …
@ Ladislav Burkovsky, we are working on a new website with updated documentation. you can find the most up-to-date documentation at: github.com/…/TypeScript-Handbook; please give it a look and feel free log issues for missing or out dated content.
The link to "Async functions" is broken.
Great to see this release. I like async/await feature combined with flexible module targeting (ES6+commonjs) which allows to use this cool feature in nodejs projects.
Polymorphic this typing example could probably contain line:
newModel = createModel().setupBase().setupAdvanced(); // fluent style works
The idea behind the exponentiation operator is less typing. I wonder whether that really flies. When this operator is needed, likely other math functions are needed as well. For example the square root, i.e. Math.sqrt. Or are we supposed to write (x**2+y**2)**0.5? Even then, I don't expect the operator will be used throughout the whole codebase. I think adding the operator does not outweight the downside of a larger cognitive load, misinterpretation, and larger interpreter needed.
How is C#->WebAssembly compilation going?
You say "say goodbye to Math.pow". Has it been deprecated or removed already? The floating-point machine code exponentiation instruction may be faster on some architectures… Will the JIT collapse those multiplication into a call to those?
Glad to see the progress! Would it be possible to have a little more details on "ES6 Module Emitting"? I've read and re-read but it's not too clear to me what this feature offers / what problem it solves. I'd really like to understand and see an example that fleshes this out.
@John Reilly Take a look at the modules page on the handbook at github.com/…/Modules.md . There's a ton of examples in here.
In general, none of the main JavaScript engine support ES6 modules directly yet, so this feature is only usable if you have other tools in your toolchain that understand the ES6 module syntax (such as WebPac/Babel – http://www.2ality.com/…/webpack-es6.html, or SystemJS – github.com/…/es6-modules-overview.md ).
What's the recommended way to get TS1.7 running on a Windows build server? For versions prior to 1.7 we just installed the latest version of TypeScript for Visual Studio 2015 on the build machine. That seems to work fine even though VS is not itself installed.
At least currently the download for TypeScript for Visual Studio 2015, as linked from the typescriptlang.org page, contains TS 1.6.
http://www.microsoft.com/…/details.aspx
Will this change? Are there other downloads?
Thanks @onyxmaster, the link should be fixed now.
@Janus Troelsen, Math.pow is still around. the operator is just syntactic sugar for calling Math.pow. The exponentiation operator is part of the upcoming JS standard (ES2016), and you can see the proposal details at: github.com/…/exponentiation-operator
@Ronald ZarÄ«ts, we are working on a nugget package for TS1.7, this would be the easiest way to get it wired into your build system. If you still want to install the tools on your build machine, i would recommend installing the latest package from http://www.microsoft.com/…/details.aspx.
Awesome, I've been waiting for the polymorphic this. Good job
Sorry, but broken link:
As always, you can get your hands on TypeScript 1.7 for Visual Studio 2015 Update 1,
"Visual Studio 2015 Update 1" leads to "blogs.msdn.com/…/Visual%20Studio%202015%20Update%201"
Thanks @Ky7m, the link should be fixed now.
Anyone else having issues with publishing to Azure Web Roles? It looks like the list of items dynamically added to the build have a path formatted in a way not expected by the CopyWebRoleFiles step in Microsoft.WindowsAzure.targets. Here are some examples of the error logs we are seeing when we build:
Creating directory "M:solutionssolutionProject.AzureobjTestProject.WebM:solutionssolutionProject.WebScriptsCustomBindingHandlers".
10>C:Program Files (x86)MSBuildMicrosoftVisualStudiov14.0Windows Azure Tools2.8Microsoft.WindowsAzure.targets(2787,5): error MSB3021: Unable to copy file "M:solutionssolutionProject.WebScriptsCustomBindingHandlersAutoCompleteHandler.js" to "M:solutionssolutionProject.AzureobjTestProject.WebM:solutionssolutionProject.WebScriptsCustomBindingHandlersAutoCompleteHandler.js". The given path's format is not supported.
Components like polymer are missing.
After digging a bit more it appears that the compiled JS files are being copied twice. Once with the correct path and after that it is copied again with an incorrect path. It seems as if the compiled files are somehow being added twice.
Correct: "M:solutionsSolutionProject.AzureobjTestProject.WebScriptsCustomBindingHandlersAutoCompleteHandler.js"
Wrong: "M:solutionsSolutionProject.AzureobjTestProject.WebM:solutionssolutionProject.WebScriptsCustomBindingHandlersAutoCompleteHandler.js"
Keep up the great work!
I can't wait for 1.8 and path substitutions 🙂
@Mohamed There is a ";" at the end of your handbook link that breaks it. This one should work: github.com/…/TypeScript-Handbook
3 cheers for better docs on the way!
What happened to the sometimes-used syntax of 2 ^ 2 ??
^ continues to be the binary XOR operator.
@Rusco: Yes, we have made some changes to allow the use of decorators when targeting ES3 with a few restrictions:
– An ES3 method decorator will not receive a property descriptor when applied at runtime.
– The return value of an ES3 method decorator will be ignored when applied at runtime.
This means that method decorators in ES3 have the same semantics as decorators on property declarations in prior versions of the compiler.
Please keep in mind that decorators are an experimental feature based on an evolving proposal for ES2016, and as such are subject to change.
Please improve the TypeScript Playground so that it would be possible to play with async/await there.
Hi,
I mostly understand the spec. The spec parts which contains only links to github could be improved.
Looking for 1.8 especially github.com/…/5090
Regards,
Ladislav
@RobLS Can you share a 'diagnostic' build log, so we can try to figure out what's happening?
You can email me at paul(dot)van(dot)brenk(at)Microsoft(dot)com
Thanks!
Can we use in TypeScript 1.7 async / await for XHR calls? If so, how?
Thanks!
Where's the es5 support? On the browser side, having only es6 support doesn't do us much good.
@es5 async/await, we are working on it 🙂 Please see our previous blog post on this topic at blogs.msdn.com/…/what-about-async-await.aspx for more information.
Can't wait for Async/Await on ES5 targets!
@Andrei Rînea, you can find a sample for using async/await at: github.com/…/async
I really don't get it why a two-letter operator had to be chosen (like **) instead of a single letter one (like ^). Why do they have to follow C-like languages in syntax?
@George Birbilis, as mentioned earlier by @Ryan Cavanaugh, ^ is already in use for XOR operator in JS.
This polymorphic "this" implementation still doesn't work for functional-style code.
Check this out: http://bit.ly/1mdetIb
When will it be available in visual studio online hosted build controllers?
We have even problems with TypeScript 1.6 there: social.msdn.microsoft.com/…/hosted-build-controller-in-vs-online-doesnt-support-typescript-16
@Fyodor Soykin, Specifying the type of this argument in function declarations is planned for TypeScript 2.0. Issue github.com/…/3694 is tracking this work
I wonder why all the download links from the http://www.typescriptlang.org/ page are broken. I don't want to install Visual Studio 2015 Update 1 to get the newest TypeScript as Update 1 is broken for us beyond usability (it was already reported to Microsoft, unfortunately, they can't deal with it).
@Tadeusz, the links point to the Download Center landing pages for the TypeScript Plugin for VS2013 (http://www.microsoft.com/…/details.aspx) and VS 2015 (http://www.microsoft.com/…/details.aspx). Expand the "Details" section in the page to get more information.
TypeScript 1.7.* plugin for Visual Studio 2015 requires Update 1. there are dependency on new features included in Update 1 and is not available without it.
Can you point us to the issues that are blocking you from adopting VS 2015 Update 1?
I find it very annoying is that the syntax looks like scala rather than C# !!
Aren't you afraid of the easy error someone can made by accidentaly writing two * and then searching for who knows how long for such error? And how many times does one even use the Math.pow function?
Kind of a general question, but: what would be the best place to get some help/interaction on getting TypeScript to work with React with the Visual Studio 2015 IDE?
@Seth I don’t seem to find a way to share TypeScript 1.7 files between different web applications in VS2015 using AMD modules. Although while coding VS2015 seems to handle the require(“……”) instruction for my common/shared component just fine, when I start the app, require throws an error (can’t locate the generated JavaScript code).
Here’s the more detailed post I made about this on SO, but you guys might want to look into this: http://stackoverflow.com/questions/35506086/using-typescript-files-in-different-web-apps-with-require-amd
If this is not the right place, please advise where I can discuss this with a MS team member (or anyone more knowledgeable than me on this matter). Thanks!