-
Notifications
You must be signed in to change notification settings - Fork 63
Fix: Mark call expression type parameters as used #89
Conversation
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.
How about a test case with a normal (non-arrow) function expression?
@@ -186,6 +186,28 @@ ruleTester.run("no-unused-vars", ruleNoUnusedVars, { | |||
}, | |||
{ | |||
code: [ | |||
"import { Foo } from 'foo'", | |||
"function bar<T>() {}", |
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.
Function declaration...
{ | ||
code: [ | ||
"import { Foo } from 'foo'", | ||
"const bar = <T>() => {}", |
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.
Arrow function by reference.
parser | ||
}, | ||
{ | ||
code: ["import { Foo } from 'foo'", "<Foo>(<T>() => {})()"].join( |
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.
Immediately invoked arrow function...
lib/rules/no-unused-vars.js
Outdated
}); | ||
annotation.typeParameters.params.forEach( | ||
markTypeAnnotationAsUsed | ||
); |
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.
👍 in general. 👎 for being unrelated.
Updated to incorporate feedback, and added an invalid test case as well. |
{ | ||
code: [ | ||
"import { Foo } from 'foo'", | ||
"const bar = function <T>() {}", |
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.
Function expression!
While type parameters on function declarations/expressions are marked as used, ones on call expressions are not, e.g.: