dcsan dcsan - 1 year ago 632
TypeScript Question

cannot redeclare block scoped variable (typescript)

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 getting

enter image description here

etc. So using typescript it seems there can only be one such declaration/require across the whole project?
I'm confused about this as I thought
was scoped to the current file.

I just had a project that was working but after a refactor am now getting these errors all over the place.

Can someone explain?

Answer Source

let is used to declare local variables that exist in block scopes instead of function scopes.

The latest preferred way of importing an external module is the ES6 syntax anyways, which contains no explicit assignment:

import * as co from "./co"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download