2016-10-13 4 views
0

カルマのユニットテスト中に私のコードを翻訳するために、browserifyのプラグインtsifyを使用しています。カルマの "tsify"で "デコレータの実験的サポート"を有効にする

私は私のテストを実行したとき、私はERROのこの種を取得する:ここに私のkarma.config.jsに

を指定しているbrowserify/tsify、中experimentalDecoratorsを有効にするにはどうすればよい

TypeScript error: src/app/emailLogin/emailLogin.component.ts(14,14): Error TS1219: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.

は私のカルマです.config.js:ここ

module.exports = function(config) { 
    config.set({ 
    browsers: ['Chrome'], 
    frameworks: ['jasmine', 'browserify', 'es6-shim'], 
    files: [ 
     'src/**/*.spec.ts' 
    ], 
    preprocessors: { 
     '**/*.ts': ['browserify'] 
    }, 
    browserify: { 
     debug: true, 
     plugin: ['tsify'], 
     transform: ['browserify-shim'] 
    } 
    }); 
}; 

は私の一気ファイルである(私はこれは問題ではありませんだと思う)

var gulp = require('gulp'); 
var Server = require('karma').Server; 

/** 
* Run test once and exit 
*/ 
gulp.task('test', function (done) { 
    new Server({ 
    configFile: __dirname + '/karma.conf.js', 
    singleRun: true 
    }, done).start(); 
}); 

/** 
* Watch for file changes and re-run tests on each change 
*/ 
gulp.task('tdd', function (done) { 
    new Server({ 
    configFile: __dirname + '/karma.conf.js' 
    }, done).start(); 
}); 

gulp.task('default', ['tdd']); 
+1

あなたのTSconfigように見えるんか?私は 'tsify'も使用していて、それは私のためにそのエラーを投げていません –

答えて

1

デコレータに関連する2 compiler optionsがあります

--emitDecoratorMetadata 
--experimentalDecorators 

一般的に、彼らは(tsifyが検索およびtsconfig.jsonをロードします)プロジェクトのtsconfig.jsonファイルで有効になります

{ 
    "compilerOptions": { 
     "emitDecoratorMetadata": true, 
     "experimentalDecorators": true, 
     "target": "es5" 
    }, 
    "files": [] 
} 

場合何らかの理由でtsconfig.jsonファイルを使用していない場合は、カルマのbrowserifyプラグインの設定で有効にすることができます(配列内の配列に注意してください):

browserify: { 
    debug: true, 
    plugin: [['tsify', { 
     emitDecoratorMetadata: true, 
     experimentalDecorators: true 
    }]], 
    transform: ['browserify-shim'] 
} 

そして、彼らはあまりにも、コマンドラインを介して有効にすることができます。

browserify -p [tsify --emitDecoratorMetadata --experimentalDecorators] main.ts > bundle.js 
関連する問題