-
Notifications
You must be signed in to change notification settings - Fork 14
Better error message for mistaken import #40
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
reviewing |
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.
a few minor stylistic changes, but other than that looks good to me!
@@ -2297,7 +2308,17 @@ namespace ts { | |||
} | |||
} | |||
else { | |||
error(name, Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); | |||
if (moduleSymbol.exports && moduleSymbol.exports.has("default" as __String)) { |
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.
Judging by other code in the checker, I think this could be more idiomatic.
- can you try
.has(InternalSymbolName.Default)
instead of a hard-coded string? Then it's more consistent with the surrounding code and we don't need a cast.
@@ -1,4 +1,4 @@ | |||
tests/cases/compiler/service.ts(1,8): error TS1192: Module '"tests/cases/compiler/db"' has no default export. | |||
tests/cases/compiler/service.ts(1,8): error TS6222: Module '"tests/cases/compiler/db"' has no default export. Did you mean to use 'import {db} from "tests/cases/compiler/db"' instead? |
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 think it's more idiomatic to see a space around the identifier in the curlies: import { db } from ...
.
Basing this on the formatting for destructuring assignment in the TS codebase, as well as how prettier formats imports, to the best of my knowledge.
Signed-off-by: Mukesh Prasad <[email protected]>
@mheiber addressed your review comments. |
Issue number of the reported bug or feature request: microsoft#13601
it's live! microsoft#33706 |
Issue number of the reported bug or feature request: microsoft#13601