tryResolveType() — react Function Reference
Architecture documentation for the tryResolveType() function in InferTypes.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD 3586dd2f_f748_328e_8e11_2899a16d4f45["tryResolveType()"] e91596b5_bd35_ace7_a141_7dbab722b96d["Unifier"] 3586dd2f_f748_328e_8e11_2899a16d4f45 -->|defined in| e91596b5_bd35_ace7_a141_7dbab722b96d 6938eece_f870_22b1_d136_01eb0a26f7b9["bindVariableTo()"] 6938eece_f870_22b1_d136_01eb0a26f7b9 -->|calls| 3586dd2f_f748_328e_8e11_2899a16d4f45 f0603215_bdb0_88a0_8649_8c18b423f04f["get()"] 3586dd2f_f748_328e_8e11_2899a16d4f45 -->|calls| f0603215_bdb0_88a0_8649_8c18b423f04f 073c81a5_c389_d108_5b8f_4d6dc6eece83["push()"] 3586dd2f_f748_328e_8e11_2899a16d4f45 -->|calls| 073c81a5_c389_d108_5b8f_4d6dc6eece83 d7fde76c_4fd9_feb3_299b_798689f05bc6["assertExhaustive()"] 3586dd2f_f748_328e_8e11_2899a16d4f45 -->|calls| d7fde76c_4fd9_feb3_299b_798689f05bc6 style 3586dd2f_f748_328e_8e11_2899a16d4f45 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/TypeInference/InferTypes.ts lines 700–792
tryResolveType(v: TypeVar, type: Type): Type | null {
switch (type.kind) {
case 'Phi': {
/**
* Resolve the type of the phi by recursively removing `v` as an operand.
* For example we can end up with types like this:
*
* v = Phi [
* T1
* T2
* Phi [
* T3
* Phi [
* T4
* v <-- cycle!
* ]
* ]
* ]
*
* By recursively removing `v`, we end up with:
*
* v = Phi [
* T1
* T2
* Phi [
* T3
* Phi [
* T4
* ]
* ]
* ]
*
* Which avoids the cycle
*/
const operands = [];
for (const operand of type.operands) {
if (operand.kind === 'Type' && operand.id === v.id) {
continue;
}
const resolved = this.tryResolveType(v, operand);
if (resolved === null) {
return null;
}
operands.push(resolved);
}
return {kind: 'Phi', operands};
}
case 'Type': {
const substitution = this.get(type);
if (substitution !== type) {
const resolved = this.tryResolveType(v, substitution);
if (resolved !== null) {
this.substitutions.set(type.id, resolved);
}
return resolved;
}
return type;
}
case 'Property': {
const objectType = this.tryResolveType(v, this.get(type.objectType));
if (objectType === null) {
return null;
}
return {
kind: 'Property',
objectName: type.objectName,
objectType,
propertyName: type.propertyName,
};
}
case 'Function': {
const returnType = this.tryResolveType(v, this.get(type.return));
if (returnType === null) {
return null;
}
return {
kind: 'Function',
return: returnType,
shapeId: type.shapeId,
isConstructor: type.isConstructor,
};
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does tryResolveType() do?
tryResolveType() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/TypeInference/InferTypes.ts.
Where is tryResolveType() defined?
tryResolveType() is defined in compiler/packages/babel-plugin-react-compiler/src/TypeInference/InferTypes.ts at line 700.
What does tryResolveType() call?
tryResolveType() calls 3 function(s): assertExhaustive, get, push.
What calls tryResolveType()?
tryResolveType() is called by 1 function(s): bindVariableTo.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free