JS: Also propagate through promise types

This commit is contained in:
Asger F
2025-04-30 14:15:07 +02:00
parent 500291dd54
commit 167f752301
3 changed files with 26 additions and 1 deletions

View File

@@ -60,7 +60,7 @@ module TypeResolution {
content.isUnknownArrayElement()
)
or
// Ad-hoc support for array types. We don't support generics in general currently, we just special-case arrays.
// Ad-hoc support for array types. We don't support generics in general currently, we just special-case arrays and promises.
content.isUnknownArrayElement() and
(
memberType = host.(ArrayTypeExpr).getElementType()
@@ -77,6 +77,9 @@ module TypeResolution {
memberType = type.getArgument(0)
)
)
or
content.isPromiseValue() and
memberType = unwrapPromiseType(host)
}
/**
@@ -120,6 +123,9 @@ module TypeResolution {
object.(ObjectPattern).getPropertyPatternByName(contents.asPropertyName()).getValuePattern() =
member
or
member.(AwaitExpr).getOperand() = object and
contents = DataFlow::ContentSet::promiseValue()
or
SummaryTypeTracker::basicLoadStep(object.(AST::ValueNode).flow(),
member.(AST::ValueNode).flow(), contents)
}