Skip to content

Commit a4362e7

Browse files
timothykangJamesHenry
authored andcommitted
Fix: Mark qualified name type annotations as used (typescript-eslint#88)
1 parent c6ccf36 commit a4362e7

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Diff for: packages/eslint-plugin-typescript/lib/rules/no-unused-vars.js

+11
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,26 @@ module.exports = {
6969
const annotation = node.typeAnnotation || node;
7070

7171
switch (annotation.type) {
72+
case "Identifier": {
73+
markVariableAsUsed(context, annotation.name);
74+
break;
75+
}
7276
case "TSArrayType": {
7377
markTypeAnnotationAsUsed(annotation.elementType);
7478
break;
7579
}
80+
case "TSQualifiedName": {
81+
markTypeAnnotationAsUsed(annotation.left);
82+
markTypeAnnotationAsUsed(annotation.right);
83+
break;
84+
}
7685
case "TSTypeReference": {
7786
if (annotation.typeName.type === "TSArrayType") {
7887
markTypeAnnotationAsUsed(
7988
annotation.typeName.elementType
8089
);
90+
} else if (annotation.typeName.type === "TSQualifiedName") {
91+
markTypeAnnotationAsUsed(annotation.typeName);
8192
} else {
8293
markVariableAsUsed(context, annotation.typeName.name);
8394
if (

Diff for: packages/eslint-plugin-typescript/tests/lib/rules/no-unused-vars.js

+16
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,22 @@ ruleTester.run("no-unused-vars", ruleNoUnusedVars, {
434434
"}"
435435
].join("\n"),
436436
parser
437+
},
438+
{
439+
code: [
440+
"import Foo from 'foo'",
441+
"const bar: Foo.Bar = null",
442+
"console.log(bar)"
443+
].join("\n"),
444+
parser
445+
},
446+
{
447+
code: [
448+
"import Foo from 'foo'",
449+
"const baz: Foo.Bar.Baz = null",
450+
"console.log(baz)"
451+
].join("\n"),
452+
parser
437453
}
438454
],
439455

0 commit comments

Comments
 (0)