本周的重大新闻是AtScript和TypeScript的合并。
以下示例摘自AtScript文档...
@Component()
class MyApp {
server:Server;
@Bind('name') name:string;
@Event('foo') fooFn:Function;
@Inject()
constructor(@parent server:Server) {}
greet():string {}
}
编译后的JavaScript代码如下...
function MyApp() {}
MyApp.properties = {
'server': { is: Server },
'name': { is:string,
annotate: [new Bind('name']},
'fooFn': { is:Function,
annotate:[new Event('foo')]}
}
MyApp.annotate = [
new Component(),
new Inject()
];
MyApp.parameters = [
{is:Server, annotate:[parent]}
];
MyApp.prototype.greet = function() {}
MyApp.prototype.greet.returns = string;
AtScript原本计划作为TypeScript的一层(即超集的超集) - 但现在这两个项目已经合并。
注释只能放置在函数上。
放置在类上的注释等同于放置在类的构造函数上。
放置在字段上的注释将被移动到构造函数中。
所有注释都被翻译为函数的属性。