-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: LS: TSServerIssues related to the TSServerIssues related to the TSServerHelp WantedYou can do thisYou can do this
Milestone
Description
π Search Terms
declared but its value is never read
unused variable
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about Common Misconceptions
β― Playground Link
π» Code
function hi() {
let { offsetWidth = 1 } = { offsetWidth: 0 };
offsetWidth = 1;
} π Actual behavior
The problem is that the hint about the unused local variables is not reliably reported in the editor. I can't find a way to reproduce it in the playground. It is an error when noUnusedLocals=true, so it might cause more confusion than if it were just a hint.
It seems to be a race condition where Symbol.isReferenced is populated in another language feature before typecheck. The hint is then not being reported. Semantic highlight is the most reliable way I found to reproduce it. To reproduce this,
- Open VSCode with the color theme set to any theme that supports semantic highlight, like the default dark+.
- Paste the code to a ts file and see the hint not being reported like in the playground (if it is there, edit the file might make it disappear).
- Restart TSServer, and the hint is now reported. But editing the file hides the hint again.
π Expected behavior
It was reliably reported no matter if other features checked the variable.
Additional information about the issue
No response
MartinJohns
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: LS: TSServerIssues related to the TSServerIssues related to the TSServerHelp WantedYou can do thisYou can do this