JS: Add test and fix for contextType

This commit is contained in:
Asger Feldthaus
2020-10-28 16:23:36 +00:00
parent 7ee3846142
commit f99db23e7b
4 changed files with 25 additions and 4 deletions

View File

@@ -650,9 +650,12 @@ private DataFlow::Node getAContextInput(DataFlow::CallNode createContext) {
* ```
*/
pragma[nomagic]
private DataFlow::CallNode getAContextOutput(DataFlow::CallNode createContext) {
result = react().getAMemberCall("useContext") and
getAContextRef(createContext).flowsTo(result.getArgument(0))
private DataFlow::SourceNode getAContextOutput(DataFlow::CallNode createContext) {
exists(DataFlow::CallNode call |
call = react().getAMemberCall("useContext") and
getAContextRef(createContext).flowsTo(call.getArgument(0)) and
result = call
)
or
exists(DataFlow::ClassNode cls |
getAContextRef(createContext).flowsTo(cls.getAPropertyWrite("contextType").getRhs()) and