2016-04-13 21 views
7

Sto utilizzando una libreria con Typescript e ricevo un errore del compilatore.come installo una tipizzazione elencata?

public/components/chatlogs.ts (25,19): errore TS2304: impossibile trovare il nome "Handsontable".

sembra che ci sia un tipizzazioni per esso:

$ 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 

ma poi i cant installare questo?

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

C'è un modo per utilizzare una "sorgente" diversa da 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 

Come si installa una tipizzazione elencata in un'altra homepage?

O forse esistono per tsd ma non per dattilografi?

risposta

12

Credo global ha sostituito ambient come parola chiave, e source~packagename è la sintassi, per esempio:

typings install dt~node --global 

ancora chiaro ciò che il env o dt tipizzazioni repo le distinzioni sono sicuramente dt è il posto predefinito che viene cercato, quindi perché è necessario specificarlo?

+0

correlati https://github.com/typings/typings/issues/517 – Lekhnath

1

ma poi non posso installare che

definizioni di tipo a DefinitelyTyped sono considerati ambient. Quindi, è necessario installare con il flag ambiente:

typings install --ambient handsontable 

Altro su ambiente

When to use ambient while searching for a type definition?

+0

questo è scaduto ora, l'incantesimo è cambiato in 'globale' – dcsan

0

È possibile copiare direttamente un file tipizzazioni da Definitely Typed Typescript e incollarlo nel progetto.

È anche possibile scaricare l'intero progetto github sicuramente digitato dal link sopra, copiare e incollare i file di tipizzazione richiesti in base alle proprie esigenze.

Come @basarat detto

typings install --ambient fileName 

sarebbe un un'altra opzione per scaricare tipizzazioni file.

Per ulteriori informazioni sul file di digitazione, ad esempio come usarli, cosa contengono, vedere Definitely Typed.

saluti

Ajay

0

Il messaggio ERR suggerisce in realtà ciò che si dovrebbe fare (l'aggiunta di interruzioni di riga per 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 

Per ottenere il messaggio di aiuto sulle tipizzazioni, si dovrebbe fare

typings <command> -h 

In questo caso

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 

C'è un modo per utilizzare una "sorgente" diversa da npm?

È possibile configurare il defaultSource e defaultAmbientSource in .typingsrc.

0

provare a utilizzare il seguente comando se v'è una fonte di DT o ENV

tipizzazioni installazione è --global en ~ nodo

+0

qual è la differenza tra en ~ node e dt ~ node - poiché dt è dove la tipizzazione è elencata come esistente? – dcsan

Problemi correlati