createVariableDeclarator() — react Function Reference
Architecture documentation for the createVariableDeclarator() function in CodegenReactiveFunction.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD 6a903108_0a0b_6e52_019e_0b534b909b09["createVariableDeclarator()"] dc7f10c2_c914_a162_d02b_a10a15c64a5f["CodegenReactiveFunction.ts"] 6a903108_0a0b_6e52_019e_0b534b909b09 -->|defined in| dc7f10c2_c914_a162_d02b_a10a15c64a5f 94638464_4710_0693_528f_4848cf25e876["codegenReactiveScope()"] 94638464_4710_0693_528f_4848cf25e876 -->|calls| 6a903108_0a0b_6e52_019e_0b534b909b09 c65f3ebd_fe8f_602d_b885_bc79e6e81b1d["codegenInstructionNullable()"] c65f3ebd_fe8f_602d_b885_bc79e6e81b1d -->|calls| 6a903108_0a0b_6e52_019e_0b534b909b09 e98029e7_d319_5eee_1233_4a0434b62d22["codegenInstruction()"] e98029e7_d319_5eee_1233_4a0434b62d22 -->|calls| 6a903108_0a0b_6e52_019e_0b534b909b09 style 6a903108_0a0b_6e52_019e_0b534b909b09 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts lines 1550–1573
function createVariableDeclarator(
id: t.LVal,
init?: t.Expression | null,
): t.VariableDeclarator {
const node = t.variableDeclarator(id, init);
/*
* The variable declarator location is not preserved in HIR, however, we can use the
* start location of the id and the end location of the init to recreate the
* exact original variable declarator location.
*
* Or if init is null, we likely have a declaration without an initializer, so we can use the id.loc.end as the end location.
*/
if (id.loc && (init === null || init?.loc)) {
node.loc = {
start: id.loc.start,
end: init?.loc?.end ?? id.loc.end,
filename: id.loc.filename,
identifierName: undefined,
};
}
return node;
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does createVariableDeclarator() do?
createVariableDeclarator() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts.
Where is createVariableDeclarator() defined?
createVariableDeclarator() is defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts at line 1550.
What calls createVariableDeclarator()?
createVariableDeclarator() is called by 3 function(s): codegenInstruction, codegenInstructionNullable, codegenReactiveScope.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free