2012-10-19 74 views
1

任何使用AMD与TypeScript和dojo AMD的例子?不断收到 “3”,而不是一个对象(tslab == 3):TypeScript + Dojo + AMD?

require(["TypeScriptLab"], function (tslab) 
    { 
     new tslab.Tests().run(); 
    }); 

打字稿看起来像这样:

export class TypeScriptLab { 
    test() { 
    } 
} 

生成的JS看起来像这样:

define(["require", "exports"], function(require, exports) { 
    var TypeScriptLab = (function() { 
     function TypeScriptLab() { } 
     TypeScriptLab.prototype.test = function() { 
     }; 
     return TypeScriptLab; 
    })(); 
    exports.TypeScriptLab = TypeScriptLab;  
}) 
+0

忽略提及我正在使用dojo 1.8.0 –

回答

1

我定义了我的包裹:

<script> 
    dojoConfig = { 
     async: true, 
     packages: [ 
      { name: "TSLab", location: "/IPS" } 
     ] 
    }; 
</script> 

并添加了一个命名空间前缀:

require(["TSLab/typeScriptLab"], function (tslab) 
    { 
     new tslab.Tests().run(); 
    }); 

现在加载该模块。