了解 Webstorm 上的 Typescript 定义文件 [英] Understanding Typescript definition files on Webstorm

查看:38
本文介绍了了解 Webstorm 上的 Typescript 定义文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天开始在 Webstorm 中使用 Typescript,并且我对正在发生的事情有了真正的了解.想象一个使用 tsdtypings/ 上加载定义类型的项目.对于背景,angular 定义了一个别名为 ngangular 模块,然后还有其他 d.ts 文件附加更多模块转换成 angular(技术上是 ng).

I started using Typescript with Webstorm today and I am getting real crazy understanding what's going on. Imagine a project using tsd loading definition types on typings/. For background, angular defines an angular module aliased to ng and then there is other d.ts files appending more modules into angular (and technically ng).

例如,当我需要 router 时,我得到:

When I require for example the router I get:

事实上,如果你去angular-route.d.ts(来自DefinitelyTyped)你可以看到同样的:

In fact, if you go to angular-route.d.ts (from DefinitelyTyped) you can see the same:

d.ts 文件在技术上是正确的,因为 tsc 编译它们给它那些定义文件.

The d.ts files are technically correct because tsc compiles them giving it those definition files.

另一方面,Webstorm 允许您加载库(来自绝对类型的打字稿存根).如果我去那里下载 angular 的(与我在 typings/ 上的 100% 相同),我会得到:

On the other hand, Webstorm allows you to load libraries (typescript stubs from DefinitelyTyped). If I go there and I download the angular ones (which are 100% the same as the one I have on typings/) I get:

同样的错误,但至少我没有在解决方案资源管理器中看到红色摆动.尽管如此,它在编写 ng.route.<ctrl+space> 时并没有给我任何智能感知,当我写完它时它只是变成蓝色(事实上,我可以 cmd+click and go到定义).

Same error but at least I don't get the red wiggle in the solution explorer. Still, it doesn't give me any intellisense when writing ng.route.<ctrl+space>, it just turn blue when I finish writing it (in fact, I can cmd+click and go to the definition).

谁在这里失败了?打字稿插件?奇怪的是它使用 typings/ 失败并且以某种方式使用 Webstorm 的库菜单(使用相同的文件).

Who's failing here? The typescript plugin? It is weird that it fails using typings/ and somehow work with Webstorm's libraries menu (using the same file).

推荐答案

谁在这里失败了?打字稿插件?

Who's failing here? The typescript plugin?

是的.目前您需要使用 Webstorm beta 频道来获得对 TypeScript 1.4 联合类型的支持.

Yes. You need to use the Webstorm beta channel to get support for TypeScript 1.4 union Types at the moment.

这篇关于了解 Webstorm 上的 Typescript 定义文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆