File tree Expand file tree Collapse file tree 4 files changed +17
-3
lines changed
test/library-tests/UnderlyingTypes Expand file tree Collapse file tree 4 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -333,7 +333,13 @@ module SourceNode {
333333 astNode instanceof TaggedTemplateExpr or
334334 astNode instanceof Templating:: PipeRefExpr or
335335 astNode instanceof Templating:: TemplateVarRefExpr or
336- astNode instanceof StringLiteral
336+ astNode instanceof StringLiteral or
337+ astNode instanceof TypeAssertion
338+ )
339+ or
340+ exists ( VariableDeclarator decl |
341+ exists ( decl .getTypeAnnotation ( ) ) and
342+ this = DataFlow:: valueNode ( decl .getBindingPattern ( ) )
337343 )
338344 or
339345 DataFlow:: parameterNode ( this , _)
Original file line number Diff line number Diff line change @@ -189,7 +189,12 @@ module TypeResolution {
189189 )
190190 }
191191
192- private predicate contextualType ( Node value , Node type ) {
192+ predicate contextualType ( Node value , Node type ) {
193+ exists ( LocalVariable v |
194+ type = v .getADeclaration ( ) .getTypeAnnotation ( ) and
195+ value = v .getAnAssignedExpr ( )
196+ )
197+ or
193198 exists ( InvokeExpr call , Function target , int i |
194199 callTarget ( call , target ) and
195200 value = call .getArgument ( i ) and
@@ -228,6 +233,8 @@ module TypeResolution {
228233 predicate valueHasType ( Node value , Node type ) {
229234 value .( BindingPattern ) .getTypeAnnotation ( ) = type
230235 or
236+ value .( TypeAssertion ) .getTypeAnnotation ( ) = type
237+ or
231238 exists ( VarDecl decl |
232239 // ValueFlow::step is restricted to variables with at most one assignment. Allow the type annotation
233240 // of a variable to propagate to its uses, even if the variable has multiple assignments.
Original file line number Diff line number Diff line change 4848| subtype.ts:7:13:7:15 | req | 'express'.Request |
4949| subtype.ts:13:13:13:15 | req | 'express'.Request |
5050| subtype.ts:19:13:19:15 | req | 'express'.Request |
51+ | varAssignment.ts:4:9:4:11 | req | 'express'.Request |
Original file line number Diff line number Diff line change 11import * as express from 'express' ;
22
33function t1 ( e ) {
4- var req : express . Request = e ; // $ MISSING: hasUnderlyingType='express'.Request
4+ var req : express . Request = e ; // $ hasUnderlyingType='express'.Request
55}
You can’t perform that action at this time.
0 commit comments