how do i install a listed typings?
Asked Answered
J

5

7

I'm using a library with Typescript, and getting a compiler error.

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

it seems there is a typings for it:

$ 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

but then i cant install that?

$ 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) ✗ 

Is there some way to use a different "source" than 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

[email protected] /usr/local/lib/node_modules/typings

How do I install a typings that is listed with a different homepage?

Or maybe they exist for tsd but not typings?

Jaeger answered 13/4, 2016 at 0:31 Comment(0)
J
13

I believe global has replaced ambient as a keyword, and source~packagename is the syntax, for example:

typings install dt~node --global

still unclear what the env or dt typings repo distinctions are. surely dt is the default place that is searched, so why is there a need to specify it?

Jaeger answered 19/6, 2016 at 21:39 Comment(0)
O
1

but then i cant install that

Type definitions in DefinitelyTyped are considered ambient. So you need to install with the ambient flag:

typings install --ambient handsontable

More on ambient

When to use ambient while searching for a type definition?

Optional answered 13/4, 2016 at 0:34 Comment(1)
this is out of date now, the incantation has changed to globalJaeger
B
0

You can directly copy a typings file from Definitely Typed Typescript and paste it in your project.

You can also download the whole definitely typed github project from above link, copy and paste the required typings files according to your need.

As @basarat told

typings install --ambient fileName 

would be an another option to download typings file.

For more info on typings file, like how to use them, what they contain look at Definitely Typed.

Regards

Ajay

Bismarck answered 13/4, 2016 at 4:9 Comment(0)
B
0

The ERR message actually suggest what you should do (adding line breaks for 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

To get the help message on typings, you should do

typings <command> -h

In this case

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?

You can configure the defaultSource and defaultAmbientSource in .typingsrc.

Beauteous answered 13/4, 2016 at 5:44 Comment(0)
N
0

try using the following command if there is a source for dt or env

typings install --global en~node

Nissa answered 15/6, 2016 at 21:34 Comment(1)
whats the difference between en~node and dt~node - since dt is where the typing is listed as existing?Jaeger

© 2022 - 2024 — McMap. All rights reserved.