Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`Duplicate declaration` error with Babel 7, typescript preset and namespace #10038

Open
ikenik opened this issue May 29, 2019 · 1 comment

Comments

Projects
None yet
3 participants
@ikenik
Copy link

commented May 29, 2019

Bug Report

Current Behavior

Transpilation of the code fails with the following error.

TypeError: D:\Git\babel-duplicate-declaration-example\example.ts: Duplicate declaration "foo"
   6 |     }
   7 |     export namespace ns2 {
>  8 |         export class foo {
     |                      ^
   9 |             F1: string;
  10 |         }
  11 |     }
    at File.buildCodeFrameError (D:\Git\babel-duplicate-declaration-example\node_modules\@babel\core\lib\transformation\file\file.js:261:12)
    at Scope.checkBlockScopedCollisions (D:\Git\babel-duplicate-declaration-example\node_modules\@babel\traverse\lib\scope\index.js:344:22)
    at Scope.registerBinding (D:\Git\babel-duplicate-declaration-example\node_modules\@babel\traverse\lib\scope\index.js:501:16)
    at Scope.registerDeclaration (D:\Git\babel-duplicate-declaration-example\node_modules\@babel\traverse\lib\scope\index.js:444:12)
    at Object.BlockScoped (D:\Git\babel-duplicate-declaration-example\node_modules\@babel\traverse\lib\scope\index.js:187:28)
    at Object.newFn (D:\Git\babel-duplicate-declaration-example\node_modules\@babel\traverse\lib\visitors.js:230:17)
    at NodePath._call (D:\Git\babel-duplicate-declaration-example\node_modules\@babel\traverse\lib\path\context.js:53:20)
    at NodePath.call (D:\Git\babel-duplicate-declaration-example\node_modules\@babel\traverse\lib\path\context.js:36:14)
    at NodePath.visit (D:\Git\babel-duplicate-declaration-example\node_modules\@babel\traverse\lib\path\context.js:88:12)
    at TraversalContext.visitQueue (D:\Git\babel-duplicate-declaration-example\node_modules\@babel\traverse\lib\context.js:118:16)

Input Code

https://github.com/ikenik/babel-duplicate-declaration-example

// typescript
module src {
    export namespace ns1 {
        export class foo {
            F1: string;
        }
    }
    export namespace ns2 {
        export class foo {
            F1: string;
        }
    }
}

Expected behavior/code
A clear and concise description of what you expected to happen (or code).

Babel Configuration (.babelrc, package.json, cli command)

{
    presets: ["@babel/preset-typescript"]
}
{
  "dependencies": {
    "@babel/core": "^7.4.5"
  },
  "devDependencies": {
    "@babel/preset-typescript": "^7.3.3"
  }
}
npm install
npm start

Environment

  • Babel version(s): v7.4.5
  • Node/npm version: Tested and confirmed in Node 8/9/10 with npm 5.6.0
  • OS: Windows 10
  • Monorepo: no
  • How you are using Babel: cli

Additional context/Screenshots

#8559, #8525 may be related.

@babel-bot

This comment has been minimized.

Copy link
Collaborator

commented May 29, 2019

Hey @ikenik! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community
that typically always has someone willing to help. You can sign-up here
for an invite.

@ikenik ikenik changed the title `Duplicate declaration` error with Babel 7, typescropt preset and namespace `Duplicate declaration` error with Babel 7, typescript preset and namespace May 29, 2019

@nicolo-ribaudo nicolo-ribaudo referenced a pull request that will close this issue May 29, 2019

Open

Implement TypeScript namespace support #9785

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.