Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

a-tarasyuk
Copy link
Contributor

Fixes #58561

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Jun 16, 2024
@typescript-bot
Copy link
Collaborator

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)) {
Copy link
Member

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?

Copy link
Contributor Author

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?

Copy link
Member

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.

Copy link
Contributor Author

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?

  1. Interface Declaration
  2. Type Alias Declaration
  3. Enum Declaration
  4. Class Declaration

Copy link
Member

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Status: Waiting on reviewers
Development

Successfully merging this pull request may close these issues.

Allow leading underscore for types to bypass noUnusedLocals warning
4 participants