Skip to content

Instantly share code, notes, and snippets.

@shiwork
Created February 7, 2014 07:53
Show Gist options
  • Save shiwork/8858763 to your computer and use it in GitHub Desktop.
Save shiwork/8858763 to your computer and use it in GitHub Desktop.
module Hoge {
export class Sample {
constructor() {
}
methodA():void {
alert('methodA');
}
methodB():void {
alert('methodB');
}
}
}
var sample = new Hoge.Sample();
sample.methodA();
sample.methodB();
@shiwork
Copy link
Author

shiwork commented Feb 7, 2014

環境
node v0.11.11
typescript 0.9.5
grunt 0.4.2
grunt-cli 0.1.13
grunt-typescript 0.2.7
grunt-contrib-concat 0.3.0
grunt-contrib-uglify 0.3.2

@shiwork
Copy link
Author

shiwork commented Feb 7, 2014

それだとコケないねー

@vvakame
Copy link

vvakame commented Feb 7, 2014

$ git clone https://gist.github.com/8858763.git
$ cd 8858763
$ npm install uglify-js
$ tsc sample.ts
$ ./node_modules/.bin/uglifyjs sample.js -o sample.min.js
$ cat sample.min.js
var Hoge;(function(Hoge){var Sample=function(){function Sample(){}Sample.prototype.methodA=function(){alert("methodA")};Sample.prototype.methodB=function(){alert("methodB")};return Sample}();Hoge.Sample=Sample})(Hoge||(Hoge={}));var sample=new Hoge.Sample;sample.methodA();sample.methodB();

となって再現しませんでした…。
Gruntfile.js も見てみたい気がします。

@shiwork
Copy link
Author

shiwork commented Feb 7, 2014

一旦全部削除してnpmのパッケージをすべてlocalインストールに切り替えたら期待取りに動作しました・・・

@shiwork
Copy link
Author

shiwork commented Feb 7, 2014

@vvakame 多分なんですが、globalでインストールされている物がだいぶ前にインストールしたnode_moduleの方を向いていて、期待しているものを参照してなかったのではないかと思います。
一旦関連するものをすべて削除した上で、nvmからnodeをインストール、rcファイルのpathをすべて精査した後にpackage.jsonでnpmで利用するmoduleを定義した上で、npm installでlocalインストールを実行したところ正しく動作しました。

過去のプロジェクトの呪いだと思って心清らかに乗り切ります・・・(当時関わったpjでたまたま使う必要があっただけで放置してた)

色々有り難うございます。npmのパッケージ管理とnvmの管理方法に詳しく慣れたので得るものも大きかった><

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment