[Bug]: Error when I specify "declare class" and "function" with the same name
See original GitHub issue💻
- Would you like to work on a fix?
How are you using Babel?
Input code
declare class A {}
function A () {}
Configuration file name
.babelrc
Configuration
{
"presets": ["@babel/preset-typescript"]
}
Current and expected behavior
I expect this construction to be compiled correctly because tsc
can do it. However, currently Babel throws an error:
Duplicate declaration "A"
1 | declare class A {}
2 |
> 3 | function A () {}
|
Environment
- Babel version(s): 7.15.5
- Node: 16
- npm: 7
- OS: Windows 10
- Monorepo: no
Possible solution
No response
Additional context
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (11 by maintainers)
Top Results From Across the Web
Class method and variable with same name, compile error in ...
This way you have members with the same name, but with different addresses. Though isVal variable is hidden by isVal function in the...
Read more >Erroneous error "Method with same name already defined in ...
What steps will reproduce the problem? 1. Create a class 2. Declare two methods returning a reference (i.e. "function &<methodName>()") with a distinct...
Read more >Declared property first conflicts when function parameters of ...
Basically Anytime you Define a class field/property and then later on a function that uses a parameter with the same name the UBT...
Read more >unable to define local function because it has the same name ...
Is there only a way to overcome this problem ? I though that in matlab function where forced to be set in files...
Read more >Bug Patterns - Error Prone
The called constructor accepts a parameter with the same name and type as one of its caller's parameters, but its caller doesn't pass...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Good question. You can build the AST and manually assign
declare
to itI can look into this