-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Unused identifiers compiler code #9200
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
Changes from 1 commit
617b819
a8bc8b4
01966ba
1e5ca92
890d178
69dbeea
c78d0e2
107b369
481baa3
cd1ce0f
a38149d
0571c19
e17ed58
2b7f3a7
5a34352
93b7490
7aba626
ed5052d
f5cdc9c
8c3c7b1
dfad7cc
c325625
6a711bc
d62a43f
043a625
8f9d4ae
f15448a
c82453f
bcd6fc4
49385f4
5993015
f464f92
3b5f8d2
ed282d7
e502ba0
0e2e43d
d6c2bcd
f93c6c8
4521058
5eb7153
1401506
5361e5f
7fc4616
9753d09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14214,9 +14214,7 @@ namespace ts { | |
|
|
||
| function checkUnusedLocals(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction): void { | ||
| checkUnusedIdentifiers(node); | ||
| if (node.kind !== SyntaxKind.Constructor) { | ||
| checkUnusedParameters(node); | ||
| } | ||
| checkUnusedParameters(node); | ||
| } | ||
|
|
||
| function checkUnusedIdentifiers(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction): void { | ||
|
|
@@ -14236,7 +14234,13 @@ namespace ts { | |
| for (const key in node.locals) { | ||
| if (hasProperty(node.locals, key) && !node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { | ||
| if (node.locals[key].valueDeclaration.kind === SyntaxKind.Parameter && node.parent.kind !== SyntaxKind.InterfaceDeclaration) { | ||
| error(node.locals[key].valueDeclaration, Diagnostics.Parameter_0_has_never_been_used, key); | ||
| if (node.locals[key].valueDeclaration.modifiers) { | ||
| if (!checkModifiersForPublicAccess(node.locals[key].valueDeclaration.modifiers)) { | ||
| error(node.locals[key].valueDeclaration, Diagnostics.Parameter_0_has_never_been_used, key); | ||
| } | ||
| } else { | ||
| error(node.locals[key].valueDeclaration, Diagnostics.Parameter_0_has_never_been_used, key); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -14289,6 +14293,15 @@ namespace ts { | |
| return false; | ||
| } | ||
|
|
||
| function checkModifiersForPublicAccess(modifiers: ModifiersArray): boolean { | ||
| for (let i = 0; i < modifiers.length; i++) { | ||
| if (modifiers[i].kind === SyntaxKind.PublicKeyword) { | ||
| return true; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. capture |
||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move the node.parent.kind check outside the loop. |
||
| } | ||
| return false; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| function checkBlock(node: Block) { | ||
| // Grammar checking for SyntaxKind.Block | ||
| if (node.kind === SyntaxKind.Block) { | ||
|
|
||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| tests/cases/compiler/unusedMultipleParameter1InContructor.ts(3,17): message TS6133: Parameter 'person' has never been used. | ||
| tests/cases/compiler/unusedMultipleParameter1InContructor.ts(4,13): message TS6132: Variable 'unused' has never been used. | ||
|
|
||
|
|
||
| ==== tests/cases/compiler/unusedMultipleParameter1InContructor.ts (2 errors) ==== | ||
|
|
||
| class Dummy { | ||
| constructor(person: string, person2: string) { | ||
| ~~~~~~~~~~~~~~ | ||
| !!! message TS6133: Parameter 'person' has never been used. | ||
| var unused = 20; | ||
| ~~~~~~ | ||
| !!! message TS6132: Variable 'unused' has never been used. | ||
| person2 = "Dummy value"; | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
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.
check that node is not an interface member first.