{"id":313,"date":"2015-03-27T15:20:00","date_gmt":"2015-03-27T15:20:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/typescript\/2015\/03\/27\/announcing-typescript-1-5-alpha\/"},"modified":"2024-07-01T13:58:55","modified_gmt":"2024-07-01T21:58:55","slug":"announcing-typescript-1-5-alpha","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/typescript\/announcing-typescript-1-5-alpha\/","title":{"rendered":"Announcing TypeScript 1.5 Alpha"},"content":{"rendered":"<p dir=\"ltr\"><span style=\"font-size: 12px;\">Today we\u2019re announcing TypeScript 1.5 Alpha, the first preview of the TypeScript 1.5 release. \u00a0This release shows off many of the features that will be in the final TypeScript 1.5 release. \u00a0In the alpha release, you\u2019ll be able to use three new capabilities of the TypeScript tools: a richer ES6 experience, decorators, and a new <\/span><a style=\"font-size: 12px;\" href=\"https:\/\/github.com\/Microsoft\/TypeScript-Sublime-Plugin\">Sublime Text plugin<\/a><span style=\"font-size: 12px;\">.<\/span><\/p>\n<p dir=\"ltr\">You can try this alpha out today by installing the new compiler available on <a href=\"https:\/\/www.npmjs.com\/package\/typescript\">npm<\/a>.<\/p>\n<h2>Richer ES6 experience<\/h2>\n<p dir=\"ltr\">In TypeScript 1.5, we\u2019re adding a number of new ES6 features. \u00a0These features work together with the TypeScript type system to give you helpful tooling when working with the new ES6 code patterns.<\/p>\n<h3>Modules<\/h3>\n<p dir=\"ltr\">The module syntax of ES6 is a powerful way of working with modules. \u00a0You can interact with modules by importing whole modules or by working with individual exports directly.<\/p>\n<p dir=\"ltr\"><span style=\"font-family: 'courier new', courier;\"><span style=\"color: #0000ff;\">import<\/span> * <span style=\"color: #0000ff;\">as<\/span> Math <span style=\"color: #0000ff;\">from<\/span> <span style=\"color: #993300;\">&#8220;my\/math&#8221;<\/span>;\n<\/span><span style=\"font-family: 'courier new', courier;\"><span style=\"color: #0000ff;\">import<\/span> { add, subtract } <span style=\"color: #0000ff;\">from<\/span> <span style=\"color: #993300;\">&#8220;my\/math&#8221;<\/span>;<\/span><\/p>\n<p dir=\"ltr\">ES6 also supports a range of functionality in specifying exports. \u00a0You can export declarations, such as classes or functions. \u00a0You can also export a \u2018default\u2019 to import the module directly. \u00a0For example:<\/p>\n<p dir=\"ltr\"><span style=\"color: #339966; font-family: 'courier new', courier;\">\/\/ math.ts<\/span><\/p>\n<p dir=\"ltr\"><span style=\"font-family: 'courier new', courier;\"><span style=\"color: #0000ff;\">export function<\/span> add(x, y) { <span style=\"color: #0000ff;\">return<\/span> x + y }\n<\/span><span style=\"font-family: 'courier new', courier;\"><span style=\"color: #0000ff;\">export function<\/span> subtract(x, y) { <span style=\"color: #0000ff;\">return<\/span> x \u2013 y }\n<\/span><span style=\"font-family: 'courier new', courier;\"><span style=\"color: #0000ff;\">export default<\/span> <span style=\"color: #0000ff;\">function<\/span> multiply(x, y) { <span style=\"color: #0000ff;\">return<\/span> x * y }<\/span><\/p>\n<p dir=\"ltr\"><span style=\"color: #339966; font-family: 'courier new', courier;\">\/\/ myFile.ts<\/span><\/p>\n<p dir=\"ltr\"><span style=\"font-family: 'courier new', courier;\"><span style=\"color: #0000ff;\">import<\/span> {add, subtract} <span style=\"color: #0000ff;\">from<\/span> <span style=\"color: #993300;\">&#8220;math&#8221;<\/span>;\n<\/span><span style=\"font-family: 'courier new', courier;\"><span style=\"color: #0000ff;\">import<\/span> times <span style=\"color: #0000ff;\">from <\/span><span style=\"color: #993300;\">&#8220;math&#8221;<\/span>;\n<\/span><span style=\"font-family: 'courier new', courier;\"><span style=\"color: #0000ff;\">var<\/span> result = times(add(2, 3), subtract(5, 3));<\/span><\/p>\n<p dir=\"ltr\">If you\u2019ve been using TypeScript, you may notice that this is similar to TypeScript external modules. \u00a0This is no accident. \u00a0When we created external modules for TypeScript, we were working on the same problems. \u00a0The ES6 design takes the capabilities even further, showing a powerful, mature design. \u00a0We will continue to support external modules, but we will begin encouraging developers to use the more capable ES6 module syntax.<\/p>\n<h3>Destructuring<\/h3>\n<p dir=\"ltr\">Destructuring is a handy new feature that comes as part of our ES6 support. \u00a0With it, you can pull apart, or destructure, objects and arrays.<\/p>\n<p dir=\"ltr\"><span style=\"font-family: 'courier new', courier;\"><span style=\"color: #0000ff;\">var<\/span> [x, y] = [10, 20];\n<\/span><span style=\"font-family: 'courier new', courier;\">[x, y] = [y, x]; \u00a0<span style=\"color: #339966;\">\/\/ a simple swap<\/span><\/span><\/p>\n<p dir=\"ltr\">You can also use destructuring to handle function parameters:<\/p>\n<p dir=\"ltr\"><span style=\"font-family: 'courier new', courier;\"><span style=\"color: #0000ff;\">var<\/span> myClient = {name: <span style=\"color: #800000;\">&#8220;Bob&#8221;<\/span>, height: 6};\n<\/span><span style=\"font-family: 'courier new', courier;\"><span style=\"color: #0000ff;\">function<\/span> greetClient({name, height: howTall}) {\n<\/span><span style=\"font-family: 'courier new', courier;\">console.log(<span style=\"color: #800000;\">&#8220;Hello,\u00a0&#8220;<\/span> + name + <span style=\"color: #800000;\">&#8220;, who is\u00a0&#8220;<\/span> + howTall +\u00a0<span style=\"color: #800000;\">&#8221; feet tall.&#8221;<\/span>);\n<\/span><span style=\"font-family: 'courier new', courier;\">}\ngreetClient(myClient);\u00a0<\/span><\/p>\n<p dir=\"ltr\">In the above, <span style=\"font-family: 'courier new', courier;\">greetClient<\/span> takes in a single object that has a <span style=\"font-family: 'courier new', courier;\">name<\/span> and <span style=\"font-family: 'courier new', courier;\">height<\/span> property. Using the <span style=\"font-family: 'courier new', courier;\">&#8216;height: howTall&#8217;<\/span>\u00a0syntax, we can rename the <span style=\"font-family: 'courier new', courier;\">height<\/span> property to <span style=\"font-family: 'courier new', courier;\">howTall<\/span> inside of <span style=\"font-family: 'courier new', courier;\">greetClient<\/span>.<\/p>\n<h3>And more<\/h3>\n<p dir=\"ltr\">We\u2019ve also added for-of support for better iteration, let\/const compiling to ES5, unicode support, an ES6 output mode, and better support for computed properties.<\/p>\n<h2>Decorators<\/h2>\n<p dir=\"ltr\">We\u2019ve also worked with the <a href=\"https:\/\/angular.io\/\">Angular<\/a>, <a href=\"http:\/\/emberjs.com\/\">Ember<\/a>, and <a href=\"http:\/\/aurelia.io\/\">Aurelia<\/a>\u00a0(from the makers of Durandal)\u00a0teams on a decorator proposal for ES7, which we\u2019re previewing in TypeScript 1.5 Alpha. \u00a0Decorators allow you to create a clean separation of concerns. \u00a0In this example, we see how the <span style=\"font-family: 'courier new', courier;\">@memoize<\/span> decorator could be used to note that a getter\/setter pair can be memoized:<\/p>\n<p dir=\"ltr\"><span style=\"font-family: 'courier new', courier;\"><span style=\"color: #0000ff;\">class<\/span> Person {\n<\/span><span style=\"font-family: 'courier new', courier;\">@memoize\n<\/span><span style=\"font-family: 'courier new', courier;\"><span style=\"color: #0000ff;\">get<\/span> name() { <span style=\"color: #0000ff;\">return <\/span><span style=\"color: #800000;\">`${this.first} ${this.last}`<\/span> }<\/span><\/p>\n<p dir=\"ltr\"><span style=\"font-family: 'courier new', courier;\"><span style=\"color: #0000ff;\">\u00a0 set<\/span> name(val) {\n<\/span><span style=\"font-family: 'courier new', courier;\"><span style=\"color: #0000ff;\">\u00a0 \u00a0 let<\/span> [first, last] = val.split(<span style=\"color: #800000;\">&#8216; &#8216;<\/span>);\n<\/span><span style=\"font-family: 'courier new', courier;\">this.first = first;\n<\/span><span style=\"font-family: 'courier new', courier;\">this.last = last;\n<\/span><span style=\"font-family: 'courier new', courier;\">}\n<\/span><span style=\"font-family: 'courier new', courier;\">}<\/span><\/p>\n<p dir=\"ltr\">Developers will be able to write new decorators and mix-and-match them to work with the type system.<\/p>\n<h2>Sublime Text plugin<\/h2>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/typescript\/wp-content\/uploads\/sites\/11\/2015\/03\/5428.sublime1.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-4327\" src=\"https:\/\/devblogs.microsoft.com\/typescript\/wp-content\/uploads\/sites\/11\/2015\/03\/5428.sublime1.png\" alt=\"Image 5428 sublime1\" width=\"1224\" height=\"409\" srcset=\"https:\/\/devblogs.microsoft.com\/typescript\/wp-content\/uploads\/sites\/11\/2015\/03\/5428.sublime1.png 1224w, https:\/\/devblogs.microsoft.com\/typescript\/wp-content\/uploads\/sites\/11\/2015\/03\/5428.sublime1-300x100.png 300w, https:\/\/devblogs.microsoft.com\/typescript\/wp-content\/uploads\/sites\/11\/2015\/03\/5428.sublime1-1024x342.png 1024w, https:\/\/devblogs.microsoft.com\/typescript\/wp-content\/uploads\/sites\/11\/2015\/03\/5428.sublime1-768x257.png 768w\" sizes=\"(max-width: 1224px) 100vw, 1224px\" \/><\/a><\/p>\n<p dir=\"ltr\">Along with TypeScript 1.5 Alpha, we\u2019re also releasing a <a href=\"https:\/\/github.com\/Microsoft\/TypeScript-Sublime-Plugin\">preview of the Sublime Text plugin for TypeScript<\/a> to enable more developers to get editor support when authoring TypeScript. \u00a0This plugin works with both Sublime Text 2 and Sublime Text 3 and shows some of what is possible with the TypeScript type system. Sublime Text and the TypeScript plugin are available for OSX, Linux, and Windows.<\/p>\n<p dir=\"ltr\"><a href=\"https:\/\/devblogs.microsoft.com\/00\/00\/01\/56\/67\/4263.sublime2.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/00\/00\/01\/56\/67\/4263.sublime2.png\" alt=\"\" width=\"281\" height=\"143\" border=\"0\" \/><\/a><em>\nTypeScript commands available in Sublime Text<\/em><\/p>\n<p dir=\"ltr\">The Sublime Text plugin allows you to easily navigate, refactor, format, and investigate TypeScript code. \u00a0Those who tried the Sublime plugin that came with the ng-conf demo may also notice that this updated plugin is snappier, especially with larger files.<\/p>\n<p dir=\"ltr\">We\u2019re\u00a0excited to hear your feedback. \u00a0If you\u2019d like to leave a comment, you can fill out an <a href=\"https:\/\/github.com\/Microsoft\/TypeScript-Sublime-Plugin\/issues\">issue on the issue tracker<\/a>. \u00a0Also, feel free to jump in and send us your <a href=\"https:\/\/github.com\/Microsoft\/TypeScript-Sublime-Plugin\/pulls\">pull requests<\/a> to help make the Sublime plugin even better.<\/p>\n<h2>What\u2019s next<\/h2>\n<p dir=\"ltr\">This\u00a0alpha release shows what will be possible in TypeScript 1.5 when it\u2019s released, and we want to hear from you. \u00a0We\u2019re working hard on TypeScript 1.5, and you can help us make it a strong release by trying it out and\u00a0<a href=\"https:\/\/github.com\/microsoft\/typescript\/issues\">sending us any issues<\/a> you find.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today we\u2019re announcing TypeScript 1.5 Alpha, the first preview of the TypeScript 1.5 release. \u00a0This release shows off many of the features that will be in the final TypeScript 1.5 release. \u00a0In the alpha release, you\u2019ll be able to use three new capabilities of the TypeScript tools: a richer ES6 experience, decorators, and a new [&hellip;]<\/p>\n","protected":false},"author":377,"featured_media":1797,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-313","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-typescript"],"acf":[],"blog_post_summary":"<p>Today we\u2019re announcing TypeScript 1.5 Alpha, the first preview of the TypeScript 1.5 release. \u00a0This release shows off many of the features that will be in the final TypeScript 1.5 release. \u00a0In the alpha release, you\u2019ll be able to use three new capabilities of the TypeScript tools: a richer ES6 experience, decorators, and a new [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/posts\/313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/users\/377"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/comments?post=313"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/posts\/313\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/media\/1797"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/media?parent=313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/categories?post=313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/tags?post=313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}