File tree 5 files changed +13
-12
lines changed
test/library-tests/UnderlyingTypes
5 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -229,10 +229,7 @@ module DataFlow {
229
229
predicate hasUnderlyingType ( string globalName ) {
230
230
Stages:: TypeTracking:: ref ( ) and
231
231
exists ( NameResolution:: Node type |
232
- TypeResolution:: valueHasType ( this .getNameResolutionNode ( ) , type )
233
- or
234
- TypeResolution:: contextualType ( this .getNameResolutionNode ( ) , type )
235
- |
232
+ TypeResolution:: valueHasType ( this .getNameResolutionNode ( ) , type ) and
236
233
UnderlyingTypes:: nodeHasUnderlyingType ( type , globalName )
237
234
)
238
235
}
@@ -246,12 +243,7 @@ module DataFlow {
246
243
Stages:: TypeTracking:: ref ( ) and
247
244
moduleName != "global" and
248
245
exists ( NameResolution:: Node type |
249
- TypeResolution:: valueHasType ( this .getNameResolutionNode ( ) , type )
250
- or
251
- // Also check contextual type as this helps when tracking facts between SourceNode only.
252
- // For example, for `var x: T = getFoo()` we need `getFoo()` to have the type T.
253
- TypeResolution:: contextualType ( this .getNameResolutionNode ( ) , type )
254
- |
246
+ TypeResolution:: valueHasType ( this .getNameResolutionNode ( ) , type ) and
255
247
UnderlyingTypes:: nodeHasUnderlyingType ( type , moduleName , typeName )
256
248
)
257
249
}
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 @@ -233,6 +233,8 @@ module TypeResolution {
233
233
predicate valueHasType ( Node value , Node type ) {
234
234
value .( BindingPattern ) .getTypeAnnotation ( ) = type
235
235
or
236
+ value .( TypeAssertion ) .getTypeAnnotation ( ) = type
237
+ or
236
238
exists ( VarDecl decl |
237
239
// ValueFlow::step is restricted to variables with at most one assignment. Allow the type annotation
238
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