Typescriptの型定義管理ツールがtsdからtypingsに変わってて、Qiitaとかに載ってた情報より更に変わってたのでメモ。
Typescriptは、簡単にいうと型のあるJavascriptなんですが、既存のJSのライブラリとかはTypescriptで書かれてないので、型情報がないのです。 ですが、メジャーなライブラリは、有志の方が型情報を起こしてストックしてくれており、typingsはそれをコマンドで検索したり取得したりできるツールです。
npmでtypingsをインストールする
$ npm install -g typings
これでインストールが完了。
typingsで検索する
試しにjqueryを検索してみる。
$ typings search jquery Viewing 20 of 107 NAME SOURCE HOMEPAGE DESCRIPTION VERSIONS UPDATED chai-jquery dt https://github.com/chaijs/chai-jquery 1 2016-03-17T12:06:54.000Z jasmine-jquery dt https://github.com/velesin/jasmine-jquery 1 2016-03-17T12:06:54.000Z jquery dt http://jquery.com/ 1 2016-07-04T16:20:08.000Z jquery-ajax-chain dt https://github.com/humana-fragilitas/jQuery-Ajax-Chain/ 1 2016-03-17T12:06:54.000Z jquery-backstretch dt https://github.com/srobbin/jquery-backstretch 1 2016-04-23T07:37:25.000Z jquery-cropbox dt https://github.com/acornejo/jquery-cropbox 1 2016-03-17T12:06:54.000Z jquery-easy-loading dt http://carlosbonetti.github.io/jquery-loading/ 1 2016-03-16T17:18:10.000Z jquery-fullscreen dt https://github.com/kayahr/jquery-fullscreen-plugin 1 2016-03-16T15:55:26.000Z jquery-galleria dt https://github.com/aino/galleria 1 2016-03-17T12:06:54.000Z jquery-handsontable dt http://handsontable.com 1 2016-03-29T17:54:46.000Z jquery-jsonrpcclient dt https://github.com/Textalk/jquery.jsonrpcclient.js 1 2016-03-16T15:55:26.000Z jquery-knob dt http://anthonyterrien.com/knob/ 1 2016-03-17T12:06:54.000Z jquery-mockjax dt https://github.com/jakerella/jquery-mockjax 1 2016-03-16T15:55:26.000Z jquery-mousewheel dt https://github.com/jquery/jquery-mousewheel 1 2016-05-01T12:59:06.000Z jquery-paging global 1 2016-05-08T20:10:23.000Z jquery-sortable dt http://johnny.github.io/jquery-sortable/ 1 2016-03-17T12:06:54.000Z jquery-steps dt http://www.jquery-steps.com/ 1 2016-05-09T15:01:48.000Z jquery-timeentry dt https://github.com/kbwood/timeentry 1 2016-03-16T15:55:26.000Z jquery-truncate-html dt https://github.com/kbwood/timeentry 1 2016-03-05T14:26:59.000Z jquery-urlparam dt https://gist.github.com/stpettersens/e1f4478f299b6f4905c1 1 2016-03-16T15:55:26.000Z ==== * NAME:型情報名 * SOURCE:いくつか * dt:型定義ファイル * global:globalなライブラリ * npm:npmでの依存関係情報 * bower:bowerでの依存関係情報 などなど * HOMEPAGE:ライブラリのありか
こんな感じででてくる。
typingsで型情報をインストールする
SOURCEのタイプをNAMEの前につけて、チルダ(~)をつけます。 "--name"は保存するときの名前、"--save"はdependenciesに、"--save-dev"はdevDependenciesに保存される。
* 型定義 $ typings install dt~jquery --name jquery --save --global * globalライブラリ $ typings install global~jquery --name jquery-paging --save --global
typingsで型情報をアンインストールする
もちろんアンイストールもtypingsでもできる
* 型定義 $ typings remove jquery --name jquery --save
これで削除できる。 まだ黎明期なのかな。結構変わってました。