-
Notifications
You must be signed in to change notification settings - Fork 228
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
Report diagnostics for unused "using" and "import" so that they will be shown properly in ide #5146
Conversation
All changed packages have been documented.
|
You can try these changes here
|
// Don't provide unused diagnostics if customer is using projection in the project because | ||
// the projection statements will only be processed when applying projection. There is no way to determine | ||
// whether "import" or "using" is referenced from them, so we just skip here to avoid providing incorrect suggestions (diagnostics) | ||
// This should be fine for now considering projection is an experiemental feature. |
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.
@timotheeguerin , @chrisradek , I tried to check the project part code and can't find a way to identify the references as commented here. Please let me know if there is some way I missed to count them considering my knowledge in compiler is still limited. thanks.
@@ -576,6 +576,12 @@ const diagnostics = { | |||
default: "The #deprecated directive cannot be used more than once on the same declaration.", | |||
}, | |||
}, | |||
unnecessary: { |
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.
Nit: Should this be named unused
? Does it make sense to have import/using - specific messages?
I prefer unused
over unnecessary
since the latter has a subjective connotation, and at least in TS, unused
is common for linter rules.
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 am fine with "unused", update "unnecessary" to "unused-import" and "unused-using". thanks.
Question that might need input from others: Do we want the unused import/using to show up as a |
They are logged as "trace" because I can't find a better loglevel to log them. I think they are definitely not "error" or "warning". Please feel free to suggest if there is a better way to log them. I am not quite sure I understand the "flags" part correctly, do you mean something like compilerOption? How would it help on the trace? Or do you mean only reporting these diagnostics when some compiler option (i.e. "designTimeBuild") is on? |
Talked offline and we are not able to 100% determine whether an import is used because user may modify the tree in their lib or emitters, so I will
close this PR and the issues are still open to track the 2 actions above. |
When "using" and "import" are not needed, dim them and provide quickfix in IDE.
related issues:
#3373 , #4861