TypeScript + Dojo + AMD?

时间:2012-10-19 20:54:43

标签: dojo typescript amd

使用AMD与TypeScript和dojo AMD的任何例子?继续得到“3”而不是对象(tslab == 3):

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

TypeScript如下所示:

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;    
})

1 个答案:

答案 0 :(得分:1)

我定义了我的包裹:

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

并添加了名称空间前缀:

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

现在模块正在加载。