无法在凉亭包中找到打字稿外部模块

时间:2015-02-12 15:09:59

标签: requirejs typescript amd

我用打字稿源(外部模块)制作了一个凉亭包。在另一个项目中,我使用

安装了我的凉亭包
bower install wrath

并将该包与amd一起提及。

import Model = require('wrath/Model');

然后tsc编译器发出错误error TS2307: Cannot find external module。我无法弄清楚如何让编译器知道它应该在bower_components文件夹中查找该模块。

我有这样的文件夹结构。

app
    main.ts
bower_components
    wrath
        Model.ts
        View.ts
        ...

有没有人有解决方案?

我实际上找到了一种方法来解决这个问题,方法是将bower包目录的符号链接与app目录放在一起。寻找更好的方式。

1 个答案:

答案 0 :(得分:2)

  

我无法弄清楚如何让编译器知道它应该在bower_components中查找该模块

目前除硬参考之外没有其他解决方案:

import Model  = require('./bower_components/wrath/Model');

注意:非常希望支持node_moduleshttps://github.com/Microsoft/TypeScript/issues/247

注意:grunt-ts可以帮助您制作这些引用:https://github.com/TypeStrong/grunt-ts#transforms

相关问题