diff --git a/packages/eslint-plugin/tests/rules/no-unused-vars.test.ts b/packages/eslint-plugin/tests/rules/no-unused-vars.test.ts
index 5165ecda28b..aa795ed5d76 100644
--- a/packages/eslint-plugin/tests/rules/no-unused-vars.test.ts
+++ b/packages/eslint-plugin/tests/rules/no-unused-vars.test.ts
@@ -775,6 +775,14 @@ export type F = (...a: A) => unknown;
import { Foo } from './bar';
export type F = (...a: Foo) => unknown;
`,
+ // https://github.com/typescript-eslint/typescript-eslint/issues/2452
+ `
+type StyledPaymentProps = {
+ isValid: boolean;
+};
+
+export const StyledPayment = styled.div\`\`;
+ `,
],
invalid: [
diff --git a/packages/scope-manager/src/referencer/Referencer.ts b/packages/scope-manager/src/referencer/Referencer.ts
index 1b71d7d0c50..c0c49ef9728 100644
--- a/packages/scope-manager/src/referencer/Referencer.ts
+++ b/packages/scope-manager/src/referencer/Referencer.ts
@@ -565,6 +565,14 @@ class Referencer extends Visitor {
this.close(node);
}
+ protected TaggedTemplateExpression(
+ node: TSESTree.TaggedTemplateExpression,
+ ): void {
+ this.visit(node.tag);
+ this.visit(node.quasi);
+ this.visitType(node.typeParameters);
+ }
+
protected TSAbstractClassProperty(
node: TSESTree.TSAbstractClassProperty,
): void {
diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/tagged-template.ts b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/tagged-template.ts
new file mode 100644
index 00000000000..a3c92996728
--- /dev/null
+++ b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/tagged-template.ts
@@ -0,0 +1,6 @@
+type StyledPaymentProps = {
+ isValid: boolean;
+};
+function div(arg: any): void {}
+
+const StyledPayment = div``;
diff --git a/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/tagged-template.ts.shot b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/tagged-template.ts.shot
new file mode 100644
index 00000000000..20b355c1df3
--- /dev/null
+++ b/packages/scope-manager/tests/fixtures/type-declaration/type-parameters/tagged-template.ts.shot
@@ -0,0 +1,144 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`type-declaration type-parameters tagged-template 1`] = `
+ScopeManager {
+ variables: Array [
+ Variable$1 {
+ defs: Array [
+ TypeDefinition$1 {
+ name: Identifier<"StyledPaymentProps">,
+ node: TSTypeAliasDeclaration$1,
+ },
+ ],
+ name: "StyledPaymentProps",
+ references: Array [
+ Reference$3 {
+ identifier: Identifier<"StyledPaymentProps">,
+ isRead: true,
+ isTypeReference: true,
+ isValueReference: false,
+ isWrite: false,
+ resolved: Variable$1,
+ },
+ ],
+ isValueVariable: false,
+ isTypeVariable: true,
+ },
+ Variable$2 {
+ defs: Array [
+ FunctionNameDefinition$2 {
+ name: Identifier<"div">,
+ node: FunctionDeclaration$2,
+ },
+ ],
+ name: "div",
+ references: Array [
+ Reference$2 {
+ identifier: Identifier<"div">,
+ isRead: true,
+ isTypeReference: false,
+ isValueReference: true,
+ isWrite: false,
+ resolved: Variable$2,
+ },
+ ],
+ isValueVariable: true,
+ isTypeVariable: false,
+ },
+ Variable$3 {
+ defs: Array [],
+ name: "arguments",
+ references: Array [],
+ isValueVariable: true,
+ isTypeVariable: true,
+ },
+ Variable$4 {
+ defs: Array [
+ ParameterDefinition$3 {
+ name: Identifier<"arg">,
+ node: FunctionDeclaration$2,
+ },
+ ],
+ name: "arg",
+ references: Array [],
+ isValueVariable: true,
+ isTypeVariable: false,
+ },
+ Variable$5 {
+ defs: Array [
+ TypeDefinition$4 {
+ name: Identifier<"T">,
+ node: TSTypeParameter$3,
+ },
+ ],
+ name: "T",
+ references: Array [],
+ isValueVariable: false,
+ isTypeVariable: true,
+ },
+ Variable$6 {
+ defs: Array [
+ VariableDefinition$5 {
+ name: Identifier<"StyledPayment">,
+ node: VariableDeclarator$4,
+ },
+ ],
+ name: "StyledPayment",
+ references: Array [
+ Reference$1 {
+ identifier: Identifier<"StyledPayment">,
+ init: true,
+ isRead: false,
+ isTypeReference: false,
+ isValueReference: true,
+ isWrite: true,
+ resolved: Variable$6,
+ writeExpr: TaggedTemplateExpression$5,
+ },
+ ],
+ isValueVariable: true,
+ isTypeVariable: false,
+ },
+ ],
+ scopes: Array [
+ GlobalScope$1 {
+ block: Program$6,
+ isStrict: false,
+ references: Array [
+ Reference$1,
+ Reference$2,
+ Reference$3,
+ ],
+ set: Map {
+ "StyledPaymentProps" => Variable$1,
+ "div" => Variable$2,
+ "StyledPayment" => Variable$6,
+ },
+ type: "global",
+ upper: null,
+ variables: Array [
+ Variable$1,
+ Variable$2,
+ Variable$6,
+ ],
+ },
+ FunctionScope$2 {
+ block: FunctionDeclaration$2,
+ isStrict: false,
+ references: Array [],
+ set: Map {
+ "arguments" => Variable$3,
+ "arg" => Variable$4,
+ "T" => Variable$5,
+ },
+ type: "function",
+ upper: GlobalScope$1,
+ variables: Array [
+ Variable$3,
+ Variable$4,
+ Variable$5,
+ ],
+ },
+ ],
+}
+`;