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 {
333
333
astNode instanceof TaggedTemplateExpr or
334
334
astNode instanceof Templating:: PipeRefExpr or
335
335
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 ( ) )
337
343
)
338
344
or
339
345
DataFlow:: parameterNode ( this , _)
Original file line number Diff line number Diff line change @@ -189,7 +189,12 @@ module TypeResolution {
189
189
)
190
190
}
191
191
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
193
198
exists ( InvokeExpr call , Function target , int i |
194
199
callTarget ( call , target ) and
195
200
value = call .getArgument ( i ) and
@@ -228,6 +233,8 @@ module TypeResolution {
228
233
predicate valueHasType ( Node value , Node type ) {
229
234
value .( BindingPattern ) .getTypeAnnotation ( ) = type
230
235
or
236
+ value .( TypeAssertion ) .getTypeAnnotation ( ) = type
237
+ or
231
238
exists ( VarDecl decl |
232
239
// ValueFlow::step is restricted to variables with at most one assignment. Allow the type annotation
233
240
// 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 48
48
| subtype.ts:7:13:7:15 | req | 'express'.Request |
49
49
| subtype.ts:13:13:13:15 | req | 'express'.Request |
50
50
| 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 1
1
import * as express from 'express' ;
2
2
3
3
function t1 ( e ) {
4
- var req : express . Request = e ; // $ MISSING: hasUnderlyingType='express'.Request
4
+ var req : express . Request = e ; // $ hasUnderlyingType='express'.Request
5
5
}
You can’t perform that action at this time.
0 commit comments