cannot redeclare block scoped variable (typescript)

后端 未结 8 1188
醉话见心
醉话见心 2020-12-08 18:02

I\'m building a node app, and inside each file in .js used to doing this to require in various packages.

let co = require(\"co\");

But gett

8条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 18:37

    I was receiving this similar error when compiling my Node.JS Typescript application:

    node_modules/@types/node/index.d.ts:83:15 - error TS2451: Cannot redeclare block-scoped variable 'custom'.

    The fix was to remove this:

    "files": [
      "./node_modules/@types/node/index.d.ts"
    ]
    

    and to replace it with this:

    "compilerOptions": {
      "types": ["node"]
    }
    

提交回复
热议问题