WebStorm 中 TypeScript 的外部库与“<reference path=”

External Libraries vs. "<reference path=" for TypeScript in WebStorm

我正在尝试了解如何让 WebStorm 9 识别外部 TypeScript 库。我尝试为外部库添加 "TypeScript Community Stubs"——例如 knockout——这导致名为 knockout-DefinitelyTypes 的应用程序库出现在我的项目树的 "External Libraries" 节点中。展开该节点显示 /Users/Decker/Library/Caches/WebStorm9/extLibs/http_github.com_borisyankov_DefinitelyTyped_raw_master_knockout_knockout.d.ts。我的期望是,这将允许我在自己的打字稿文件中创建如下一行:

var name = ko.observable('Hi');

但是 TypeScript 不会编译并给出错误 "Cannot find name 'ko'"。我可以通过手动下载 TypeScript 定义文件(从 https://github.com/borisyankov/DefinitelyTyped)并将其存储在我的项目中来解决这个问题——在我的例子中是 /scripts/typings/knockout.d.ts——然后引用它在我的 TypeScript 源文件中使用这一行:

/// <reference path="../typings/knockout.d.ts" />

我认为 WebStorm 的外部库可以减轻对标记的需求。事实上,我不确定它为我完成了什么,因为我必须手动下载和引用定义文件。我误会了什么吗? TIA.

Indeed, I'm not sure what it accomplished for me as I had to download and reference the definition file manually. Am I misunderstanding something

webstorm 下载的存根仅针对 JS。 TS需要手动下载参考:intellisense and code complete for DefinitelyTyped (TypeScript type definitions) on WebStorm IDE