Skip to content
Permalink
Browse files

fix(scope-manager): support tagged template string generic type param…

…eters (#2492)
  • Loading branch information
bradzacher committed Sep 5, 2020
1 parent 9d8b4c4 commit a2686c04293ab9070c1500a0dab7e205bd1fa9d2
@@ -775,6 +775,14 @@ export type F<A extends unknown[]> = (...a: A) => unknown;
import { Foo } from './bar';
export type F<A extends unknown[]> = (...a: Foo<A>) => unknown;
`,
// https://github.com/typescript-eslint/typescript-eslint/issues/2452
`
type StyledPaymentProps = {
isValid: boolean;
};
export const StyledPayment = styled.div<StyledPaymentProps>\`\`;
`,
],

invalid: [
@@ -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 {
@@ -0,0 +1,6 @@
type StyledPaymentProps = {
isValid: boolean;
};
function div<T>(arg: any): void {}

const StyledPayment = div<StyledPaymentProps>``;
@@ -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,
],
},
],
}
`;

0 comments on commit a2686c0

Please sign in to comment.
You can’t perform that action at this time.