{"id":1672,"date":"2015-04-30T11:00:00","date_gmt":"2015-04-30T11:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/typescript\/2015\/04\/30\/announcing-typescript-1-5-beta\/"},"modified":"2019-02-20T10:46:15","modified_gmt":"2019-02-20T17:46:15","slug":"announcing-typescript-1-5-beta","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/typescript\/announcing-typescript-1-5-beta\/","title":{"rendered":"Announcing TypeScript 1.5 Beta"},"content":{"rendered":"<p dir=\"ltr\">We have continued work on the TypeScript 1.5 release, and today we are one step closer. &nbsp;You can now try out the TypeScript 1.5 beta as a download for <a href=\"https:\/\/visualstudiogallery.msdn.microsoft.com\/3e5ba71c-abea-4d00-b81b-a62de3ad3d53\">VS 2015 RC<\/a>, <a href=\"https:\/\/visualstudiogallery.msdn.microsoft.com\/107f89a0-a542-4264-b0a9-eb91037cf7af\">VS 2013<\/a>, <a href=\"https:\/\/www.npmjs.com\/package\/typescript\">npm<\/a>, or as <a href=\"https:\/\/github.com\/Microsoft\/TypeScript\">source<\/a>.The beta represents further progress to the final 1.5 release, with many bugfixes, support for a new metadata API that works with decorators, and updates to bring lib.d.ts up-to-date.<\/p>\n<h2>Decorator Metadata<\/h2>\n<p>TypeScript 1.5 beta introduces the new metadata API for working with decorators, allowing you to add and read metadata on declarations. &nbsp;You can see how this works in the example below.<\/p>\n<p>First, you need to install the polyfill for the new metadata API. &nbsp;We&#8217;ve made this available on NPM:<\/p>\n<p><span style=\"font-family: 'courier new', courier\">&gt; npm install reflect-metadata<\/span><\/p>\n<p>Next, you can use this metadata as in the example below:<\/p>\n<p><span style=\"font-family: 'courier new', courier\"><span style=\"color: #008000\">\/\/\/&lt;reference path=&#8221;node_modulesreflect-metadatareflect-metadata.d.ts&#8221;\/&gt;<\/span><\/p>\n<p><\/span><span style=\"font-family: 'courier new', courier\"><span style=\"color: #0000ff\">import<\/span> <span style=\"color: #800000\">&#8220;reflect-metadata&#8221;<\/span>;<\/p>\n<p><\/span><span style=\"font-family: 'courier new', courier\"><span style=\"color: #0000ff\">function<\/span> MyClassDecorator(value: <span style=\"color: #0000ff\">string<\/span>) {<br><\/span><span style=\"font-family: 'courier new', courier\"><span style=\"color: #0000ff\">&nbsp; return<\/span> <span style=\"color: #0000ff\">function<\/span> (target: Function) {<br><\/span><span style=\"font-family: 'courier new', courier\">&nbsp; &nbsp; &nbsp; Reflect.defineMetadata(<span style=\"color: #800000\">&#8220;MyClassDecorator&#8221;<\/span>, value, target);<br><\/span><span style=\"font-family: 'courier new', courier\">&nbsp; }<br><\/span><span style=\"font-family: 'courier new', courier\">}<\/span><\/p>\n<p dir=\"ltr\"><span style=\"font-family: 'courier new', courier\">@MyClassDecorator(<span style=\"color: #800000\">&#8220;my metadata&#8221;<\/span>)<\/span><br><span style=\"font-family: 'courier new', courier\"><span style=\"color: #0000ff\">class<\/span> MyClass { }<\/span><\/p>\n<p><span style=\"font-family: 'courier new', courier\"><span style=\"color: #0000ff\">var<\/span> myClass = <span style=\"color: #0000ff\">new<\/span> MyClass();<\/span><br><span style=\"font-family: 'courier new', courier\"><span style=\"color: #0000ff\">let<\/span> value: <span style=\"color: #0000ff\">string<\/span> = Reflect.getMetadata(<span style=\"color: #800000\">&#8220;MyClassDecorator&#8221;<\/span>, myClass.constructor);<\/span><br><span style=\"font-family: 'courier new', courier\">console.log(value); <span style=\"color: #008000\">\/\/ outputs &#8220;my metadata&#8221;<\/span><\/span><\/p>\n<p>You can compile this example using:<\/p>\n<p><span style=\"font-family: 'courier new', courier\">&gt;&nbsp;tsc myFile.ts &#8211;module commonjs &#8211;target ES5<\/span><\/p>\n<p>We&#8217;ve also added a new commandline option that will allow you to look at the types being passed into your decorators. &nbsp;<\/p>\n<p><span style=\"font-family: 'courier new', courier\">&gt;&nbsp;tsc myFile.ts &#8211;module commonjs &#8211;target ES5 &nbsp;&#8211;emitDecoratorMetadata<\/span><\/p>\n<p>This is a being developed to help support the metadata needs of rich libraries, like the upcoming <a href=\"http:\/\/angular.io\">Angular 2<\/a>&nbsp;and <a href=\"http:\/\/aurelia.io\">Aurelia<\/a> releases, which can use the metadata to automatically set up features like dependency injection.<\/p>\n<h2>Looking Ahead<\/h2>\n<p>Your feedback is important to us. &nbsp;As we close in on completing the 1.5 release, your feedback will be crucial to helping us make sure the new features are at the highest quality they can be. &nbsp;We&#8217;d love to <a href=\"https:\/\/github.com\/microsoft\/typescript\/issues\">hear from you<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We have continued work on the TypeScript 1.5 release, and today we are one step closer. &nbsp;You can now try out the TypeScript 1.5 beta as a download for VS 2015 RC, VS 2013, npm, or as source.The beta represents further progress to the final 1.5 release, with many bugfixes, support for a new metadata [&hellip;]<\/p>\n","protected":false},"author":375,"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-1672","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-typescript"],"acf":[],"blog_post_summary":"<p>We have continued work on the TypeScript 1.5 release, and today we are one step closer. &nbsp;You can now try out the TypeScript 1.5 beta as a download for VS 2015 RC, VS 2013, npm, or as source.The beta represents further progress to the final 1.5 release, with many bugfixes, support for a new metadata [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/posts\/1672","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\/375"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/comments?post=1672"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/posts\/1672\/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=1672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/categories?post=1672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/tags?post=1672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}