我如何安装列出的类型?

how do i install a listed typings?

我正在使用带有 Typescript 的库,遇到编译器错误。

public/components/chatlogs.ts(25,19): error TS2304: Cannot find name 'Handsontable'.

它似乎有一个类型:

$ typings search handsontable
Viewing 2 of 2

NAME                SOURCE HOMEPAGE                  DESCRIPTION UPDATED                 
handsontable        dt     https://handsontable.com/             2016-04-12T15:30:16.000Z
jquery-handsontable dt     http://handsontable.com               2016-03-29T17:54:46.000Z

但是我无法安装它?

$ typings install handsontable
typings ERR! message Unable to find "handsontable" for "npm" in the registry. Did you want to install ambient typings with the ambient flag? If you can contribute these typings, please help us: https://github.com/typings/registry
typings ERR! caused by https://api.typings.org/entries/npm/handsontable/versions/latest responded with 404, expected it to equal 200

typings ERR! cwd /Users/dc/dev/rikai/boteditor
typings ERR! system Darwin 15.3.0
typings ERR! command "/usr/local/bin/iojs" "/usr/local/bin/typings" "install" "handsontable"
typings ERR! node -v v5.1.1
typings ERR! typings -v 0.7.12

typings ERR! If you need help, you may report this error at:
typings ERR!   <https://github.com/typings/typings/issues>
➜  boteditor git:(master) ✗ 

有什么方法可以使用不同于 npm 的 "source" 吗?

typings help install

Usage: typings <command>

Commands:
    bundle, i, in, info, init, install, la, list, ll, ls, open, r, remove, rm,
    search, uninstall, view

typings <command> -h   Get help for <command>
typings <command> -V   Enable verbose logging

typings --version      Print the CLI version

typings@0.7.12 /usr/local/lib/node_modules/typings

如何安装在不同主页上列出的类型?

或者它们可能存在于 tsd 而不是 typings?

but then i cant install that

DefinitelyTyped 中的类型定义被视为 ambient。所以你需要安装环境标志:

typings install --ambient handsontable

有关环境的更多信息

您可以直接从 Definitely Typed Typescript 复制类型文件并将其粘贴到您的项目中。

您也可以从上面link下载完整的明确类型github项目,根据需要复制并粘贴所需的类型文件。

正如@basarat所说

typings install --ambient fileName 

将是下载打字文件的另一种选择。

有关打字文件的更多信息,例如如何使用它们、它们包含的内容,请查看 Definitely Typed

此致

阿杰

ERR 消息实际上建议您应该做什么(为 SO 添加换行符):

$ typings install handsontable
typings ERR! message Unable to find "handsontable" for "npm" in the registry.
Did you want to install ambient typings with the ambient flag?
If you can contribute these typings, please help us: https://github.com/typings/registry

要获取有关打字的帮助消息,您应该这样做

typings <command> -h

在这种情况下

typings install -h

typings install (with no arguments, in package directory)
typings install [<name>=]<location>

  <name>      Module name of the installed definition
  <location>  The location to read from (described below)

Valid Locations:
  [<source>!]<pkg>[@<version>][#<tag>]
  file:<path>
  github:<org>/<repo>[/<path>][#<commitish>]
  bitbucket:<org>/<repo>[/<path>][#<commitish>]
  npm:<pkg>[/<path>]
  bower:<pkg>[/<path>]
  http(s)://<host>/<path>

  <source>    The registry mirror (E.g. "npm", "bower", "env", "global", "dt", ...)
  <path>      Path to a `.d.ts` file or `typings.json`
  <host>      A domain name (with optional port)
  <version>   A semver range (E.g. ">=4.0")
  <tag>       The specific tag of a registry entry
  <commitish> A git commit, tag or branch

Options:
  [--save|-S]       Persist to "dependencies"
  [--save-dev|-D]   Persist to "devDependencies"
  [--save-peer|-P]  Persist to "peerDependencies"
  [--ambient|-A]    Install and persist as an ambient definition
    [-SA]           Persist to "ambientDependencies"
    [-DA]           Persist to "ambientDevDependencies"
  [--production]    Install only production dependencies (omits dev dependencies)

Aliases: i, in

Is there some way to use a different "source" than npm?

您可以在 .typingsrc 中配置 defaultSourcedefaultAmbientSource

尝试使用以下命令 如果有 dt 或 env

的来源

键入安装 --global en~node

我相信 global 已取代 ambient 作为关键字, source~packagename 是语法,例如:

typings install dt~node --global

仍然不清楚 envdt typings repo 的区别是什么。 dt肯定是默认搜索的地方,为什么要指定呢?