JS: Add SatisfiesExpr

This commit is contained in:
Asger F
2025-06-04 22:12:36 +02:00
parent 79101fd121
commit 57fad7e6c9
4 changed files with 6 additions and 2 deletions

View File

@@ -334,7 +334,8 @@ module SourceNode {
astNode instanceof Templating::PipeRefExpr or
astNode instanceof Templating::TemplateVarRefExpr or
astNode instanceof StringLiteral or
astNode instanceof TypeAssertion
astNode instanceof TypeAssertion or
astNode instanceof SatisfiesExpr
)
or
exists(VariableDeclarator decl |

View File

@@ -235,6 +235,8 @@ module TypeResolution {
or
value.(TypeAssertion).getTypeAnnotation() = type
or
value.(SatisfiesExpr).getTypeAnnotation() = type
or
exists(VarDecl decl |
// ValueFlow::step is restricted to variables with at most one assignment. Allow the type annotation
// of a variable to propagate to its uses, even if the variable has multiple assignments.

View File

@@ -50,4 +50,5 @@
| subtype.ts:19:13:19:15 | req | 'express'.Request |
| typeCast.ts:4:16:4:35 | e as express.Request | 'express'.Request |
| typeCast.ts:5:16:5:33 | <express.Request>e | 'express'.Request |
| typeCast.ts:6:16:6:42 | e satis ... Request | 'express'.Request |
| varAssignment.ts:4:9:4:11 | req | 'express'.Request |

View File

@@ -3,5 +3,5 @@ import * as express from 'express';
function t1(e) {
var req1 = e as express.Request; // $ hasUnderlyingType='express'.Request
var req2 = <express.Request>e; // $ hasUnderlyingType='express'.Request
var req3 = e satisfies express.Request;
var req3 = e satisfies express.Request; // $ hasUnderlyingType='express'.Request
}