File tree Expand file tree Collapse file tree 5 files changed +13
-12
lines changed
test/library-tests/UnderlyingTypes Expand file tree Collapse file tree 5 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -229,10 +229,7 @@ module DataFlow {
229229 predicate hasUnderlyingType ( string globalName ) {
230230 Stages:: TypeTracking:: ref ( ) and
231231 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
236233 UnderlyingTypes:: nodeHasUnderlyingType ( type , globalName )
237234 )
238235 }
@@ -246,12 +243,7 @@ module DataFlow {
246243 Stages:: TypeTracking:: ref ( ) and
247244 moduleName != "global" and
248245 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
255247 UnderlyingTypes:: nodeHasUnderlyingType ( type , moduleName , typeName )
256248 )
257249 }
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 @@ -233,6 +233,8 @@ module TypeResolution {
233233 predicate valueHasType ( Node value , Node type ) {
234234 value .( BindingPattern ) .getTypeAnnotation ( ) = type
235235 or
236+ value .( TypeAssertion ) .getTypeAnnotation ( ) = type
237+ or
236238 exists ( VarDecl decl |
237239 // ValueFlow::step is restricted to variables with at most one assignment. Allow the type annotation
238240 // 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