tsdでcordova.d.tsをインストールする

Ken published on
3 min, 514 words

Categories: Programming

gulpでcordova.d.tsをインストールしようと思ったんだけど、エラーが出た。
仕方ないのでtsdコマンドで直接試してみるか…とやってもだめ。

エラーはこんな感じ。

# gulp tsd
[23:23:34] Using gulpfile ~/Project/gulpfile.js
[23:23:34] Starting 'tsd'...
[23:23:34] [gulp-tsd] execute command: reinstall
[23:23:34] [gulp-tsd] config: ./tsd.json
[23:23:34] [gulp-tsd] latest: true
[23:23:34] [gulp-tsd] running...
-> warning path reference not in index: plugins/BatteryStatus.d.ts
-> warning path reference not in index: plugins/Camera.d.ts
-> warning path reference not in index: plugins/Contacts.d.ts
-> warning path reference not in index: plugins/Device.d.ts
-> warning path reference not in index: plugins/DeviceMotion.d.ts
-> warning path reference not in index: plugins/DeviceOrientation.d.ts
-> warning path reference not in index: plugins/Dialogs.d.ts
-> warning path reference not in index: plugins/FileSystem.d.ts
-> warning path reference not in index: plugins/FileTransfer.d.ts
-> warning path reference not in index: plugins/Globalization.d.ts
-> warning path reference not in index: plugins/InAppBrowser.d.ts
-> warning path reference not in index: plugins/Media.d.ts
-> warning path reference not in index: plugins/MediaCapture.d.ts
-> warning path reference not in index: plugins/NetworkInformation.d.ts
-> warning path reference not in index: plugins/Push.d.ts
-> warning path reference not in index: plugins/Splashscreen.d.ts
-> warning path reference not in index: plugins/Vibration.d.ts
-> warning path reference not in index: plugins/WebSQL.d.ts
[23:23:34] [gulp-tsd] finish
[23:23:34] Finished 'tsd' after 512 ms

解決してない人発見

▶cordova - TSD/DefinitelyTyped Install directory instead of specific file - Stack Overflow
http://stackoverflow.com/questions/25429327/tsd-definitelytyped-install-directory-instead-of-specific-file

そうそう、この現象なんだよ〜。
この人は解決できていないっぽい。
粘って調べること数時間…いや、2日くらい調べてるんじゃないか?

解決!

▶Installing definitions on a deeper level · Issue #100 · DefinitelyTyped/tsd
https://github.com/DefinitelyTyped/tsd/issues/100

また有力そうな情報発見!!
上記の記事を読みながらいろいろと試したところ、解決。

npm install tsd@next -g
tsd query cordova -r --action install --save --overwrite

肝は@next。これで次のバージョンを指定しているらしい。
@nextでインストールされるバージョンはtsd@0.6.0-beta.1でベータ版。
試しに@nextを付けずに試したら、2行目のコマンドでエラー発生。
普通にインストールするとtsd@0.5.7というバージョン。

gulp tsdは相変わらずエラー出るが、tsdコマンドでインストールできたので前進。

一応、tsd.jsonを置いておく。 [gist id="f0be668ae0ef67d9573a"] https://gist.github.com/teaplanet/f0be668ae0ef67d9573a