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