【发布时间】:2018-12-24 20:56:52
【问题描述】:
如果我想将类型分配给稍后将被分配一个 setInterval 的变量,如下所示:
this.autoSaveInterval = setInterval(function(){
if(this.car.id){
this.save();
}
else{
this.create();
}
}.bind(this), 50000);
应该为 this.autosaveInterval 变量分配什么类型?
【问题讨论】:
-
公共 autoSaveInterval :number;
-
你不需要指定类型;
autoSaveInterval将从setInterval调用的返回值推断其类型。在浏览器平台中这是number,但在 node.js 中是 Timer
标签: javascript angular typescript typescript2.0