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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug](Typescript): Duplicate declaration error happens when a imported type and function has a same name #16423

Closed
1 task
sapphi-red opened this issue Apr 9, 2024 · 4 comments

Comments

@sapphi-red
Copy link
Sponsor

馃捇

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

https://babeljs.io/repl#?browsers=defaults%2C%20not%20ie%2011%2C%20not%20ie_mob%2011&build=&builtIns=false&corejs=3.21&spec=false&loose=false&code_lz=JYWwDg9gTgLgBAbzgMQhOBfOAzKERwDkAdAPTZqEBQV2ArgHYDGMwEDKaAFAJSIZUgA&debug=false&forceAllTransforms=false&modules=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=false&presets=typescript&prettier=false&targets=&version=7.24.4&externalPlugins=&assumptions=%7B%7D

Configuration file name

No response

Configuration

No response

Current and expected behavior

No error happens.

Environment

System:
OS: Windows 11 10.0.22631
Binaries:
Node: 20.12.0 - C:\Program Files\nodejs\node.EXE
npm: 10.5.0 - C:\Program Files\nodejs\npm.CMD
pnpm: 8.15.6 - C:\Program Files\nodejs\pnpm.CMD
npmPackages:
@babel/core: ^7.24.4 => 7.24.4
@babel/preset-env: ^7.24.4 => 7.24.4
@babel/preset-typescript: ^7.24.1 => 7.24.1

Possible solution

No response

Additional context

The error doesn't happen with esbuild.
TypeScript does not show any errors even with stricter options.

@babel-bot
Copy link
Collaborator

Hey @sapphi-red! 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.

@nicolo-ribaudo
Copy link
Member

I think TS should error in this case, I opened microsoft/TypeScript#58131.

ESBuild also doesn't match the TS behavior, just in the direction opposite from Babel. In this code it should throw about Bar being re-declared, but it doesn't: https://esbuild.github.io/try/#YgAwLjIwLjIAAGUAZW50cnkudHMAaW1wb3J0IHsgRm9vLCBCYXIgfSBmcm9tICcuL2ZvbycKCmZ1bmN0aW9uIEZvbygpIHt9CmZ1bmN0aW9uIEJhcigpIHt9Cgpjb25zb2xlLmxvZyhCYXIpOwAAZm9vLnRzAGV4cG9ydCB0eXBlIEZvbyA9IHt9OwpleHBvcnQgY29uc3QgQmFyID0ge307

@nicolo-ribaudo nicolo-ribaudo closed this as not planned Won't fix, can't repro, duplicate, stale Apr 10, 2024
@sapphi-red
Copy link
Sponsor Author

That makes sense. I'm sorry about the wrong reproduction. Thanks for taking time 馃挌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants