question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

in.js:3: ERROR - Duplicate let / const / class declaration in the same scope is not allowed.

See original GitHub issue

Hi,

I have an error while compile a js file with ES6 code:

java -jar closure-compiler-v20170409.jar --compilation_level ADVANCED_OPTIMIZATIONS --js_output_file=in.js out.js
in.js:3: ERROR - Duplicate let / const / class declaration in the same scope is not allowed.
class Storage {
      ^^^^^^^

1 error(s), 0 warning(s)

There is conflict name Storage with something as I guess. If I rename, for example, to _Storage then compilation ends successfully.

"use strict";

class Storage {

}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
brad4dcommented, Oct 19, 2018

The original example doesn’t have an import or export statement in it, so closure-compiler doesn’t consider that to be a module. If you get the same error in a file that does contain either an import or export, I suggest you file a new bug with that example.

1reaction
mprobstcommented, Apr 6, 2020

You can put an empty export {}; into a file to mark it as a module.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does var allow duplicate declaration but why does const ...
Both let and const are block-scoped, not function-scoped. This makes them work like variables in most other C-like languages. It turns out this ......
Read more >
JS Tip of the Day: Declarations let, const and class Can't be ...
When declaring variables with let , const , and class , you'll need to be sure not to duplicate declarations of the same...
Read more >
I get this error in the console: (Example) | Treehouse Community
This is apparently a problem Safari has with declaring a let/const variable that shares the same name as a selected id attribute.
Read more >
Functions and Functional Programming
Now let us look at statements in the same scope, not in a nested function. With let and const declaration, accessing a variable...
Read more >
ES6 core, It worth spending a day to learn - Medium
In es5, there are only two variable declarations, var and function. Four new let and const have been added to es6, and the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found