(This article is also published in my public number "dotnet daily Essence article")
Today, because of a little cold, it is not a long speech, a brief introduction and vs. RC release of Typescript 1.5 beta new features-decorated metadata.
At the Build 2015 conference, Microsoft released the typescript 1.5 Beta with Visual Studio RC, which allows you to learn about Typescript's future development progress. Microsoft provides VS2015 RC, VS2013, NPM, and source code installation methods, respectively.
TypeScript 1.5 Beta The biggest change is the introduction of the properties of the decorated metadata (Decorator Metadata), which allows you to add and read metadata at the time of declaration. The purpose of this feature is to provide metadata support for other libraries (such as angular 2 and Aurelia) in the future, allowing these libraries to automatically set features like dependency injection.
The specific wording is as follows:
///<reference path= "node_modules\reflect-metadata\reflect-metadata.d.ts"/>Import "Reflect-metadata"; function Myclassdecorator (value:string) {returnfunction (target:function) {Reflect.definemetadata ("Myclassdecorator",value, target); }} @MyClassDecorator ("My metadata")classMyClass {}var MyClass =NewMyClass (); letvalue:string= Reflect.getmetadata ("Myclassdecorator", Myclass.constructor); Console.log (value);//outputs "my metadata"
More details can be "read the original".
Original address: Http://blogs.msdn.com/b/typescript/archive/2015/04/30/announcing-typescript-1-5-beta.aspx
TypeScript 1.5 beta brings cosmetic metadata support