LoginSignup
2
2

More than 5 years have passed since last update.

【Typescript】DefenitelyTypedはjQuery objectをbootstrapで拡張しない?

Last updated at Posted at 2015-08-24

DefinitelyTypedを使えばTypescriptでもJavascriptの資産を使えることを知った。が……

npm init
bower init
tsd init

して

bower install jquery --save
bower install bootstrap --save

して

tsd install jquery --save
tsd install bootstrap --save

して、tsd.jsonが

{
   "version": "v4",
   "repo": "borisyankov/DefinitelyTyped",
   "ref": "master",
   "path": "typings",
   "bundle": "typings/tsd.d.ts",
   "installed": {
     "jquery/jquery.d.ts": {
       "commit": "c5a2f44bab06cf9f2bcc14530171daac1cebff6c"
     },
     "bootstrap/bootstrap.d.ts": {
       "commit": "c5a2f44bab06cf9f2bcc14530171daac1cebff6c"
     }
   }
 }

もちろんtsd.d.tsは

/// <reference path="jquery/jquery.d.ts" />
/// <reference path="bootstrap/bootstrap.d.ts" />

としてやれば、index.tsとかで

 /// <reference path="../../typings/tsd.d.ts" />
 import $ = require('jquery');

 $('#modal').modal();

とか使えると思ったのに
Uncaught TypeError: $(...).modal is not a function

とか出ちゃう。要するにjQueryに対してbootstrapで追加された機能が追加(inject)されていないということだ。なんでだろー

2
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2