Assignment context
AssignmentContext provides the symbol that is the target of the current assignment.
const AssignmentContext: ComponentContext<AssignmentContext>
Accessor
const myContext = useContext(AssignmentContext);
Context interface
isAssigned | boolean Whether the symbol has had a value assigned to it. Once the symbol has been assigned, subsequent assignments will have no effect. |
target | Declaration context interface The symbol that is the target of the current assignment. |
Remarks
When a variable is declared, the symbol for the variable doesn’t yet know what value it will hold, because that depends on the assignment to the variable in the variable declaration’s initializer. This context provides the symbol that is the target of the current assignment, so that children of an assignment or initializer can provide additional symbol information.
For example, when assigning an object value expression to a variable, the object value expression should use assignment context to provide the member symbols for the object value’s properties.