簡體   English   中英

使用Webpack編譯時出現TypeScript錯誤

[英]TypeScript error on compilation with webpack

我在打字稿編譯時遇到錯誤,我不知道它來自哪里-我嘗試了tsconfig.json設置的許多不同組合,但是我總是從webpack-env中得到相同的兩個錯誤。

(gec) ➜  optim ./node_modules/.bin/webpack --config webpack.config.js
ts-loader: Using typescript@1.8.10 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和node的類型-這兩個模塊都具有requiremodule的環境聲明。 Tsc抱怨不能用不同的類型(webpack-env / index.d.ts的第176和225行)重新聲明require / module。 您是否真的在使用webpack-env類型? 嘗試刪除webpack-env / index.d.ts並查看。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM