-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Give a better message for multiple default exported functions of differing names #5198
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
Give a better message for multiple default exported functions of differing names #5198
Conversation
if (isConstructor) { | ||
multipleConstructorImplementation = true; | ||
} | ||
else { | ||
duplicateFunctionDeclaration = true; | ||
duplicateDefaultExports = !!(node.flags & NodeFlags.Default); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point we're not sure that it's a duplicate default export, right? Maybe the name should be different.
(I could be wrong, I've only skimmed areAllFunctionDeclarations...
so far)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, these are all declarations of the same symbol, so if one is a default export, they should all be default exports.
Still, that's a great assertion to check here. I'll add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I realized that we don't need the extra variable, we can just check the implementation.
* | ||
* It is probably more accurate to say that there are duplicate function implementations. | ||
* | ||
* @param declarations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know about our JSDoc style, but in the past I have skipped parameters that had no associated documentation. Is that allowed in JSDoc? Alternatively, instead of deleting this line, it would be nice to have some text here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I'll remove it
This is a follow up to @MartyIX's work on #5084.
With this change, instead of reporting
Duplicate function implementation.
for the following:We will report
A module cannot have multiple default exports.
However, for
we will report the original error message.
We also now correctly report on default-exported function declarations with no names.