-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
feat(58561): Allow leading underscore for types to bypass noUnusedLocals warning #58884
base: main
Are you sure you want to change the base?
Conversation
The TypeScript team hasn't accepted the linked issue #58561. If you can get it accepted, this PR will have a better chance of being reviewed. |
@@ -43194,6 +43195,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { | |||
} | |||
|
|||
function isValidUnusedLocalDeclaration(declaration: Declaration): boolean { | |||
if (isTypeAliasDeclaration(declaration)) { |
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.
At some level, I wonder if we should just be checking isIdentifierThatStartsWithUnderscore
for all declarations, rather than special casing a few kinds. What declarations are we actually missing here?
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 this is open to discussion. The fix shouldn't require significant work... What do you think, @RyanCavanaugh?
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 guess it's sort of nonsensical to do this for enum members and properties and so on; after all, their names are important.
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.
@jakebailey What are your thoughts on the following list? Should we add or exclude any additional declarations?
- Interface Declaration
- Type Alias Declaration
- Enum Declaration
- Class Declaration
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 would say any declaration that can be a child of a Block
or SourceFile
or Module
, etc, if that makes sense. So basically not enum members or properties. Not sure we have a list of that variety, though...
Fixes #58561