assertDataProp()function
assertDataProp(data: T, key: unknown, caller: AnyCaller = assertDataProp): asserts key is DataKey<T>
| Param | Type | |
|---|---|---|
data | T | The data object to check against. required |
key | unknown | The value to check as a key. required |
caller | AnyCaller | The function to attribute a thrown error to (defaults to assertDataProp). Defaults to assertDataProp |
| Return | |
|---|---|
asserts key is DataKey<T> |
| Throws | |
|---|---|
RequiredError | If key is not an own key of data. |
Assert that an unknown value is the key for an own prop of a data object.
Examples
assertDataProp(data, key); // throws unless `key` exists in `data`