Tri*_*Gao 19 javascript typescript atscript angular
在官方的TypeScript 博客中发布了一张非常有趣的图片.

我想知道@(at sign)符号是做什么的(因为据我所知)它不能用在JavaScript标识符中.
Fen*_*ton 14
本周的重大新闻是AtScript和TypeScript的融合.
以下来自AtScript文档的示例...
@Component()
class MyApp {
server:Server;
@Bind('name') name:string;
@Event('foo') fooFn:Function;
@Inject()
constructor(@parent server:Server) {}
greet():string {}
}
Run Code Online (Sandbox Code Playgroud)
编译成以下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;
Run Code Online (Sandbox Code Playgroud)
计划将AtScript作为TypeScript之上的一个层(即超集的超集) - 但现在这两个项目是一个.
注释只能放在函数上.
放在类上的注释是放在类的构造函数上的注释.
放置在字段上的注释将移动到构造函数.
所有注释都转换为函数的属性.
| 归档时间: |
|
| 查看次数: |
5424 次 |
| 最近记录: |