You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
Interestingly it's only shown as unused when the TS server is restarted. When reloading the window or restarting VS Code it's not shown as unused. When editing the file it's shown as unused as well.
π Search Terms
declared but its value is never read
unused variable
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?noUnusedLocals=true#code/GYVwdgxgLglg9mABACxgCgJSIN4CgCQANgKZQ6JzDADOpA6jACZTKIC8iAjIgL7vmUa9JiwBciAAy8A3LgKDaUBs1YdOsvriA
π» Code
π 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,π Expected behavior
It was reliably reported no matter if other features checked the variable.
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: