我正在使用来自https://github.com/borisyankov/DefinitelyTyped/的主干.d.ts 。
打字稿版本 0.9.1
问题:我无法正确定义 Backbone.Collection:
代码:
/// <reference path='./backbone/backbone.d.ts'/>
import Backbone = require("backbone");
class User extends Backbone.Model {
getName() : string {
return "User Name";
}
}
class Users extends Backbone.Collection {
model = User;
}
var users = new Users();
var firstUser = users.create({});
console.log(firstUser.getName());
试图编译:tsc ./users.ts -m amd
我得到了错误:
error TS2094: The property 'getName' does not exist on value of type 'Backbone.Model'.
如何解决这个问题呢?