此代码可以正常工作:
import modal = require('./modal');//modal path
class index{
constructor(){
var_modal = new modal();
}
}
export = index
如果我将require路径更改为"../../widgets/personInfo/viewmodel"
,则在重建解决方案后,Visual Studio会给出错误:
无法解析外部模块“../../widgets/personInfo/viewmodel”,Build:Module不能别名为非模块类型,无效的'new'表达式
答案 0 :(得分:0)
发现了问题。文件夹名称以大写字母开头,而require路径全部为小写。
有效代码:
import modal = require('../../Widgets/PersonInfo/viewmodel')