optionalProp()
optionalProp<
T
>(obj
?): <K
>(prop
) =>undefined
|T
[K
]
Gets the optional value of prop
in obj
. Array index support.
Type Parameters
• T extends object
The type of the input object.
Parameters
obj?
T
The object to get the value from.
Returns
Function
Type Parameters
• K extends string
| number
| symbol
Parameters
prop
K
Returns
undefined
| T
[K
]
Remarks
pure function
Remarks
pure function
Example
optionalProperty(personStore)('address');
// personStore?.address
optionalProperty(userStore.profile)(0);
// userStore?.profile?.at(0)