// Options: --annotations --array-comprehension --async-functions --debug --debug-names --exponentiation --free-variable-checker --generator-comprehension --low-resolution-source-map --input-source-map --member-variables --module-name --referrer --require --script --symbols --types --validate
//annotation class
class Template{
value:string;
constructor(value:string){
this.value = value;
}
}
//annotation class
class Attribute{}
@Template('<div>xxx</div>')
class SomeEl{
@Attribute counter:int=0;
constructor(){}
}
(function main(){
console.log(SomeEl.annotations);
console.log(SomeEl.properties); //prints undefined
})();
如何访问 atscript 中的字段注释?我只能访问类注释,但不能访问类中的字段注释,感谢您的帮助
以上被转码成
$traceurRuntime.options.symbols = true;
var Template = function Template(value) {
"use strict";
this.value = value;
};
($traceurRuntime.createClass)(Template, {}, {});
Object.defineProperty(Template, "parameters", {get: function() {
return [[$traceurRuntime.type.string]];
}});
var Attribute = function Attribute() {
"use strict";
};
($traceurRuntime.createClass)(Attribute, {}, {});
var SomeEl = function SomeEl() {
"use strict";
this.counter = 0;
};
($traceurRuntime.createClass)(SomeEl, {}, {});
Object.defineProperty(SomeEl, "annotations", {get: function() {
return [new Template('<div>xxx</div>')];
}});
(function main() {
console.log(SomeEl.annotations);
console.log(SomeEl.properties);
})();
而且我没有看到考虑@Attribute
归档的注释counter