-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Compiler gives unhelpful error messages in the presence of multiple default exports #5084
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
Conversation
Hi @MartyIX, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! The agreement was validated by Microsoft and real humans are currently evaluating your PR. TTYL, MSBOT; |
Issue #95 seems very similar to this one. Maybe another IF statement would fixed it as well. |
1110a26
to
d0bfd00
Compare
|
||
if (symbol.name === "default") { | ||
// @todo(marty) Replace with Diagnostics.<something> | ||
message = { code: 2300, category: ts.DiagnosticCategory.Error, key: "'default' keyword used multiple times." }; |
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.
You need to add a diagnostic with a unique code to diagnosticMessages.json
. Then use the appropriate generated code.
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.
Make the message "A module cannot have multiple default exports."
Can you add the following 3 tests?
export default function f();
export default function f(x: string);
export default function f(...args: any[]) {
}
export default function f() {
}
export default function f() {
}
export default class C {
}
export default class C {
} |
2e168d2
to
32d5825
Compare
export default class C { | ||
} | ||
|
||
// @filename: m2.ts |
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.
Sorry, I didn't want two separate files, I wanted both declarations to occur in the same file.
Also, can you add multipleDefaultExports04?
export default function f() {
}
export default function f() {
}
…iple "default" exports
Hey @MartyIX - unfortunately I gave some bad feedback a little bit earlier regarding multiple default-exported functions. I said that "Duplicate function implementation" was the correct error message to give; however, I think that would be the right message to give only if the function declaration names are not the same. Still, I think this work is great and we can take it in now. Thanks for the fix! |
Compiler gives unhelpful error messages in the presence of multiple default exports
Proposed fix for #3886
The patch is not finished. I would just like to get some feedback from you guys if I'm on the right track or if you would choose another approach.
Thanks!