2016-08-02 17 views
0

typescriptコンパイルでエラーが発生しましたが、tsconfig.jsonセットアップのさまざまな組み合わせを試しましたが、webpack-env 。ここで webpackでのコンパイル時にTypeScriptエラーが発生しました

(gec) ➜ optim ./node_modules/.bin/webpack --config webpack.config.js 
ts-loader: Using [email protected] and /home/bischoff_s/Code/optim/tsconfig.json 
Hash: 0e608742cc4dff532c9a 
Version: webpack 1.13.1 
Time: 3182ms 
          Asset  Size  Chunks    Chunk Names 
    main-0e608742cc4dff532c9a.ts 5.09 MB 0, 1, 2, 3 [emitted] main 
polyfills-0e608742cc4dff532c9a.ts 25 bytes  1, 2, 3 [emitted] polyfills 
     app-0e608742cc4dff532c9a.ts 25 bytes  2, 1, 3 [emitted] app 
    vendor-0e608742cc4dff532c9a.ts 3.63 kB  3, 1, 2 [emitted] vendor 
    + 329 hidden modules 

ERROR in /home/guy/Code/optim/typings/globals/webpack-env/index.d.ts 
(176,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'require' must be of type 'NodeRequire', but here has type 'RequireFunction'. 

ERROR in /home/guyCode/optim/typings/globals/webpack-env/index.d.ts 
(225,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'module' must be of type 'NodeModule', but here has type 'Module'. 

は私のtsconfig.json

{ 
    "compilerOptions": { 
     "target": "es5", 
     "module": "commonjs", 
     "emitDecoratorMetadata": true, 
     "experimentalDecorators": true, 
     "sourceMap": true, 
     "noEmitHelpers": true 
    } 

}のWebPACK-envおよびノー​​ドのための

答えて

1

あなたインストールタイピングである - これら二つのモジュールモジュールを必要とするため、両方の環境宣言を持っています。 Tscは、require/moduleを別の型(webpack-env/index.d.tsの行176と225)で再宣言できないと訴えています。あなたは実際にwebpack-envタイピングを使用していますか? webpack-env/index.d.tsを削除してみてください。

+0

私はそれを削除し、エラー(4,1)を受け取りました:エラーTS6053:ファイル '/webpack-env/index.d.ts'が見つかりません。 webpack-envとは何ですか?私のwebpack configsまたはnode package.jsonのどこにも参照されていません – bischoffingston

+1

あなたの入力/ index.d.tsの参照ディレクティブを見てください - それは(今)欠けているwebpack-envの型を参照します。あなたの入力からも消えていることを確認してください.jsonファイル。そうでなければ、タイピングインストールがそれを再導入します。 – kayjtea

+0

それは、ありがとう! – bischoffingston

関連する問題