Skip to content
This repository has been archived by the owner on Jan 19, 2019. It is now read-only.

Fix: Mark call expression type parameters as used #89

Merged
merged 1 commit into from
Nov 23, 2017
Merged

Fix: Mark call expression type parameters as used #89

merged 1 commit into from
Nov 23, 2017

Conversation

timothykang
Copy link
Contributor

While type parameters on function declarations/expressions are marked as used, ones on call expressions are not, e.g.:

import { Foo } from 'foo'
function bar<T>() {}
bar<Foo>() // fails with no-unused-vars

Copy link
Contributor

@mightyiam mightyiam left a 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>() {}",
Copy link
Contributor

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>() => {}",
Copy link
Contributor

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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Immediately invoked arrow function...

});
annotation.typeParameters.params.forEach(
markTypeAnnotationAsUsed
);
Copy link
Contributor

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.

@timothykang
Copy link
Contributor Author

Updated to incorporate feedback, and added an invalid test case as well.

{
code: [
"import { Foo } from 'foo'",
"const bar = function <T>() {}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function expression!

@JamesHenry JamesHenry merged commit 3284af4 into bradzacher:master Nov 23, 2017
@timothykang timothykang deleted the call-exp-type-param branch April 13, 2018 15:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants