2016/08/22

[typescript][webpack]typescriptで定義したclassをamdでエクスポート

タイトルが長くなってしまったのだが、typescriptで定義したclassをamdでエクスポートするにはどうすればいいのだろうか?

まず下のようにclassを定義する。

//foo.js
define(['jquery'],function($){
  class Hoge {
    constructor(opts?:any) {
    }
  }
  return Hoge;
});
で、これをrequireすればおk。
var hoge = require('foo');
new hoge;
こうすればできた。

0 コメント:

コメントを投稿