Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
fix(scope-manager): support tagged template string generic type param…
…eters (#2492)
- Loading branch information
Showing
with
166 additions
and 0 deletions.
- +8 −0 packages/eslint-plugin/tests/rules/no-unused-vars.test.ts
- +8 −0 packages/scope-manager/src/referencer/Referencer.ts
- +6 −0 packages/scope-manager/tests/fixtures/type-declaration/type-parameters/tagged-template.ts
- +144 −0 packages/scope-manager/tests/fixtures/type-declaration/type-parameters/tagged-template.ts.shot
@@ -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, | ||
], | ||
}, | ||
], | ||
} | ||
`; |