打字总是抱怨全局模块

typings always complaining about global module

我对打字稿很陌生。无论我尝试安装什么类型,我都会得到:

typings ERR! message Attempted to compile "angular" as an external module, but it looks like a global module.

我只是想做

typings install dt~angular

我做错了什么?

更新: 如果你来这里时知之甚少(就像我在写这个问题时一样)——考虑使用 npm/@types。 More info and discussion.

What am I doing wrong?

全局模块需要用--ambient

编译
typings install angular --ambient --save

您可以在此处查看有关需要使用 ambient 的更多信息:

如错误消息所示,您应该使用 --global 选项:

typings install dt~angular --global --save

请参阅 IntelliJ IDEA / Webstorm or Visual Studio Code

中有关设置支持 TypeScript 的 Node.js 项目的详细分步教程

TypeScript 和围绕它的工具发展得非常快。昨天有效的方法不再有效了。