ES2015 modules "Let/Const redeclaration"

Fixed Issue #7657926

Details

Author
Chris V.
Created
May 23, 2016
Privacy
This issue is public.
Found in
  • Microsoft Edge
Found in build #
14.14342
Reports
Reported by 2 people

Sign in to watch or report this issue.

Steps to reproduce

Using Edge 38.14342.1000.0, If I import a ‘default’ exported class using the same name as in the original class, I get an error "Let/Const redeclaration". Surely this shouldn’t be the case?

es2015-module-test.html:

<!doctype html>
<html>
<head>
    <title>ES2015 module test</title>
    <meta charset="utf-8">
    <script type="module">
        import Rectangle from "./es2015-module-test.js";
        const r = new Rectangle(20, 30);
        alert(r.area());
    </script>
</head>
<body>
</body>
</html>

es2015-module-test.js:

class Rectangle {

    constructor(width, height) {
        this.width = Number(width);
        this.height = Number(height);
    }

    area() {
        return this.width * this.height;
    }

}

export default Rectangle;

If the html <script> is changed to

import R from "./es2015-module-test.js";
const r = new R(20, 30);

then it is ok.

Surely the module should export ‘default’ only, and not leak the internal class name?

Attachments

0 attachments

    Comments and activity

    • Hello,

      Thank you for the feedback on Edge. This does not seem to repro based on my results from running tests on this so far. I do not see the error you reference on the page, or in the console.  

      Can you double check the repro provided to make sure that nothing is missing? 

      All the best,
      The MS Edge Team

    • Microsoft Edge Team

      Changed Assigned To to “Brad E.”

    • There is a public example of the failing web page here: movable-type.co.uk/dev/es2015/es2015-module-test-fail.html.

      The code is here: movable-type.co.uk/dev/es2015/es2015-module-test.js.

      Renaming the import works, as here: movable-type.co.uk/dev/es2015/es2015-module-test-ok.html.

      Screendump: screendump

    • The scope of modules in current Edge seems to be global scope, instead of module local scope.

      minimum repro:

      
      
      // foo.js
      let a = 1;
      
    • Bump?

    • Same problem in:

      <script type="module">
      let foo = 1;
      </script>
      <script type="module">
      let foo = 2;
      </script>

    • No change with 14376 :(

    • Microsoft Edge Team

      Changed Assigned To to “Christian F.”

      Changed Assigned To to “ChakraTriage”

      Changed Assigned To from “ChakraTriage” to “Taylor W.”

      Changed Status to “Confirmed”

    • No change with 14385 :(

      Any plans for the Windows 10 Anniversary Update?

    • Microsoft Edge Team

      Changed Status from “Confirmed” to “Fixed”

    • Good to know this is fixed.

      When will we see it?

      No change following the Windows 10 Anniversary Update 14393 :(

      ...

    • Thanks for the feedback. This has been fixed and pushed to the Chakra repo on GitHub:

      https://github.com/Microsoft/ChakraCore/pull/1292](https://github.[https://github.com/Microsoft/ChakraCore/pull/1292](https://github.com/Microsoft/ChakraCore/pull/1292)

      Looking forward to more feedback from you going forward. Unfortunately we cannot provide an exact estimate as to when this will officially roll out - but it is on the way :)

      All the best,
      The MS Edge Team

    • Thanks for the update. Looking forward to see it in the insider previews.

    You need to sign in to your Microsoft account to add a comment.

    Sign in