-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Way to tell TS that a JavaScript variable really is used somewhere #24790
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
Comments
@Fedoranimus A public method should never be marked as unused because unused testing isn't that smart. Similarly, something in global scope should never be marked as unused. We only mark things unused if they have a limited scope (or are |
@Andy-MS What about AngularJS? There are cases when you have a variable in the controller, which is used indirectly in the view: <!-- my-thing.component.html -->
<div>{{ $ctrl.property }}</div> // my-thing.component.ts
class MyThing {
public property = 42; // marked as unused, but is really used in the view
} |
@parzh Are you sure there isn't some other tool marking that as unused? TypeScript should never mark anything public as unused. |
@Andy-MS Oh, I actually didn't test it. Sorry for the confusion 😔 |
As far as I can tell, there's no case where unused detection has a false positive (other than something erroneously marked |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
From microsoft/vscode#51405
Feature request
For JavaScript, add a way to mark that a variable that appears unused is used somewhere. For example it may be used within a template that TS cannot analyze
Not sure if
@ts-ignore
should suppress unused too. It currently has no effect:The text was updated successfully, but these errors were encountered: