2012-12-14 62 views
0

我想要開始使用TypeScript和Backbone,並將所有類放在單獨的文件中,使用RequireJS。我有一個模型,一個集合:TypeScript,Backbone和RequireJS - 創建集合時的公共/私人問題

EntityModel.ts:

/// <reference path="../modules/backbone.d.ts"/> 
export class EntityModel extends Backbone.Model{ 
} 

EntityCollection.ts

/// <reference path="../modules/backbone.d.ts"/> 
import em = module("../models/EntityModel"); 
export class EntityCollection extends Backbone.Collection{ 
    model = em.EntityModel; 
} 

我得到一個錯誤信息:

公共成員 '模型' 的出口類有或正在使用私人類型'EM'

我只想告訴它什麼typ用於我的收藏的模型,但似乎在第一個障礙!

回答

0

找到了答案:http://typescript.codeplex.com/discussions/405800

出口的進口!

export import em = module("../models/EntityModel"); 
export class EntityCollection extends Backbone.Collection{ 
    model = em.EntityModel; 
} 
+2

有關記錄,'export import'變通只是暫時的,直到bug修復。 'export import'也可能在以後的版本中失效 - 所以這個解決方法可能只會在TypeScript的0.8.1.1版本中有效。 – Fenton

+0

謝謝史蒂夫 - 非常感謝! – user888734