Skip to content

Commit 97dc494

Browse files
committed
JS: Always propagate type of variable to all uses
1 parent b39ef15 commit 97dc494

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

javascript/ql/lib/semmle/javascript/internal/TypeResolution.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ module TypeResolution {
129129
predicate valueHasType(Node value, Node type) {
130130
value.(BindingPattern).getTypeAnnotation() = type
131131
or
132+
exists(VarDecl decl |
133+
// ValueFlow::step is restricted to variables with at most one assignment. Allow the type annotation
134+
// of a variable to propagate to its uses, even if the variable has multiple assignments.
135+
type = decl.getTypeAnnotation() and
136+
value = decl.getVariable().(LocalVariable).getAnAccess()
137+
)
138+
or
132139
exists(MemberDeclaration member |
133140
value.(ThisExpr).getBindingContainer() = member.getInit() and
134141
type = getMemberBase(member)

0 commit comments

Comments
 (0)