cannot redeclare block scoped variable (typescript)

The solution for me was to convert my code from using CommonJS (require, module.exports, etc) to ES Modules (import, export, etc.)

The TypeScript documentation also appears to recommend ES Module syntax: TypeScript Modules

Of course there’s a lot more to it than this, but as a start:

  1. Replace instances of require with import, e.g. Replace: const https = require('https'); With: import https from 'https';
  2. Replace the default module.exports with export default, e.g. Replace: module.exports = myVar ... With: export default myVar ...
  3. Replace other module.exports with export, e.g. Replace: module.exports.myVar = or: module.export = { myVar ... } With: export myVar ...

More here: From CommonJS to ES Modules: How to modernize your Node.js app

Leave a Comment

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş