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

Shadowed import bindings require cross-file knowledge even with isolatedModules #58131

Closed
nicolo-ribaudo opened this issue Apr 9, 2024 · 4 comments

Comments

@nicolo-ribaudo
Copy link

nicolo-ribaudo commented Apr 9, 2024

πŸ”Ž Search Terms

isolatedModules import duplicate

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

https://www.typescriptlang.org/dev/bug-workbench/?ts=5.4.4#code/PTAEAEGcAsHsHcCiBbAlgFwFAggQwDby4CekAyugE6oDG6oVArgKbZjiqSz67rMAmAWVj9G+ZpAaUWbCADdmlAEa9UyYaPFliAO3S4AHlJlt2AM1TiduZMwBcoM7FgA6dJEzMDAB1iV66MTezKAAYs6gALygAN4AvgDcnj5+9DSwOpD0AEK4lFGxiZimEBZWNvagqDr8Xm4ear7+sWHOADSguflxjpSwyKAA5C7ATrCDxWaMOnSoGa2wABQAlIWYUzPoczqdeStrmEA

πŸ’» Code

/// @filename: index.ts
import { Foo, Bar } from './foo'

function Foo() {}
function Bar() {}
/// @filename: foo.ts
export type Foo = {};
export const Bar = {};

πŸ™ Actual behavior

TS complains about the redeclaration of Bar but not about the redeclaration of Foo

πŸ™‚ Expected behavior

Given that inside index.ts Foo and Bar are used exactly the same way, they both should be an error (or both allowed, but it's less desirable).

Additional information about the issue

This was originally reported to Babel at babel/babel#16423, but we cannot match the TS semantics because they require cross-file knowledge (and isolatedModules is supposed to prevent that).

@andrewbranch andrewbranch added Working as Intended The behavior described is the intended behavior; this is not a bug and removed Working as Intended The behavior described is the intended behavior; this is not a bug labels Apr 10, 2024
@nicolo-ribaudo
Copy link
Author

Oh thanks πŸ™ƒ

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

Thanks πŸ™

@fatcerberus
Copy link

Also, tip: isolatedModules is redundant if you're already using verbatimModuleSyntax - the latter implies the former

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

No branches or pull requests

4 participants