Backbone.js TypeScript、主干和RequireJS-创建集合时的公共/私有问题
我正在尝试开始使用TypeScript和主干,我所有的类都在单独的文件中,使用RequireJS。我有一个模型和一个集合: EntityModel.ts:Backbone.js TypeScript、主干和RequireJS-创建集合时的公共/私有问题,backbone.js,requirejs,typescript,Backbone.js,Requirejs,Typescript,我正在尝试开始使用TypeScript和主干,我所有的类都在单独的文件中,使用RequireJS。我有一个模型和一个集合: EntityModel.ts: /// <reference path="../modules/backbone.d.ts"/> export class EntityModel extends Backbone.Model{ } // 导出类EntityModel扩展主干.Model{ } EntityCollection.ts /// <refer
/// <reference path="../modules/backbone.d.ts"/>
export class EntityModel extends Backbone.Model{
}
//
导出类EntityModel扩展主干.Model{
}
EntityCollection.ts
/// <reference path="../modules/backbone.d.ts"/>
import em = module("../models/EntityModel");
export class EntityCollection extends Backbone.Collection{
model = em.EntityModel;
}
//
导入em=模块(“../models/EntityModel”);
导出类EntityCollection扩展了主干。集合{
模型=em.EntityModel;
}
我收到一条错误消息:
导出类的公共成员“model”具有或正在使用私有类型“em”
我只想告诉它我的收藏使用哪种型号,但似乎在第一个关口就失败了 找到了答案:
出口你的进口商品
export import em = module("../models/EntityModel");
export class EntityCollection extends Backbone.Collection{
model = em.EntityModel;
}
作为记录,
export-import
解决方案只是暂时的,直到bug被修复。在以后的版本中,export-import
也可能无效-因此此解决方案可能仅在TypeScript的0.8.1.1版本中有效。谢谢Steve-非常感谢!