我正在使用带有Typescript的库,并且遇到编译器错误。
public / components / chatlogs.ts(25,19):错误TS2304:找不到名称'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不同的“来源”?
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而不是打字?
答案 0 :(得分:12)
我相信global
已将ambient
替换为关键字,
并且source~packagename
是语法,例如:
typings install dt~node --global
仍然不清楚env
或dt
类型的回购区别是什么。肯定dt
是搜索的默认位置,为什么需要指定它?
答案 1 :(得分:1)
然后我无法安装
DefinitelyTyped中的类型定义被视为ambient
。所以你需要安装环境标志:
typings install --ambient handsontable
答案 2 :(得分:0)
您可以直接从Definitely Typed Typescript复制一个打字文件并将其粘贴到您的项目中。
您还可以从上面的链接下载整个明确键入的github项目,根据需要复制并粘贴所需的打字文件。
正如@basarat告诉
typings install --ambient fileName
将是下载打字文件的另一种选择。
有关打字文件的更多信息,比如如何使用它们,它们包含的内容请看Definitely Typed。
此致
的Ajay
答案 3 :(得分:0)
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
有没有办法使用与npm不同的“来源”?
您可以在defaultSource
中配置defaultAmbientSource
和.typingsrc
。
答案 4 :(得分:0)
尝试使用以下命令 如果有dt或env的来源
typings install --global en~node