无法在 bower 包中找到打字稿外部模块
Can not locate typescript external modules in bower package
我用 typescript 源(外部模块)制作了一个 bower 包。在另一个项目中,我使用
安装了我的 bower 包
bower install wrath
并使用 amd require 引用该包。
import Model = require('wrath/Model');
然后tsc编译报错error TS2307: Cannot find external module
。我不知道如何让编译器知道它应该在 bower_components 文件夹中查找该模块。
我有这样的文件夹结构。
app
main.ts
bower_components
wrath
Model.ts
View.ts
...
有人对此有解决方案吗?
我实际上找到了一种解决此问题的方法,方法是在应用程序目录旁边制作一个符号 link 的 bower 包目录。寻找更好的方法。
I can't figure out how to make the compiler know it should lookup that module in bower_components
目前除了硬引用没有其他解决方案:
import Model = require('./bower_components/wrath/Model');
注:非常希望支持node_modules
:https://github.com/Microsoft/TypeScript/issues/247
注意:grunt-ts 可以帮助您进行这些引用:https://github.com/TypeStrong/grunt-ts#transforms
我用 typescript 源(外部模块)制作了一个 bower 包。在另一个项目中,我使用
安装了我的 bower 包bower install wrath
并使用 amd require 引用该包。
import Model = require('wrath/Model');
然后tsc编译报错error TS2307: Cannot find external module
。我不知道如何让编译器知道它应该在 bower_components 文件夹中查找该模块。
我有这样的文件夹结构。
app
main.ts
bower_components
wrath
Model.ts
View.ts
...
有人对此有解决方案吗?
我实际上找到了一种解决此问题的方法,方法是在应用程序目录旁边制作一个符号 link 的 bower 包目录。寻找更好的方法。
I can't figure out how to make the compiler know it should lookup that module in bower_components
目前除了硬引用没有其他解决方案:
import Model = require('./bower_components/wrath/Model');
注:非常希望支持node_modules
:https://github.com/Microsoft/TypeScript/issues/247
注意:grunt-ts 可以帮助您进行这些引用:https://github.com/TypeStrong/grunt-ts#transforms