在 WebStorm 中编辑在 VisualStudio 上创建的 typescript 项目时,会出现以下错误:
Error:(1, 1) TS1148: Cannot compile external modules unless the '--module' flag is provided.
代码很简单:
在文件 Test.ts 中
class helloWorld{
}
export = helloWorld;
预先感谢您的帮助
已编辑
我忘了说我用的是 MAC。
同样在进入帖子后,在我寻求解决方案的过程中,我尝试在 VisualStudio Code for Mac 中编译网页,我在那里遇到了同样的问题,那个,让我意识到问题不是 IDE,而是一些东西共同点,我没弄明白。
在 fedemp answer this sentence trigger someting:
One is using the flag at compilation: tsc --module commonjs or --module amd.
所以我转到 Webstorm 的首选项 -> 语言和框架 -> TypeScript 并在选项 “命令行选项:” 我添加了 --module amd 并完成了!
最佳答案
对于那些使用 VisualStudio 的人,我在 VS2015 上执行了以下操作,错误消失了。
在解决方案资源管理器中右键单击项目 --> 属性-->TypeScript 构建(左侧最后一个选项卡 -- 在代码分析下方),在模块系统部分将无更改为 AMD。
关于javascript - Typescript 和 webstorm,缺少 --module 标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29997716/