* A key may name an own property of the node or one it does not have yet, never * one it inherits: the walk would leave the defaults through it. * @param node The node the key is read from, undefined when it does not exist yet * @param key * @param path The path to report
(node: any, key: string, path: string)
| 28 | * @param path The path to report |
| 29 | */ |
| 30 | function assertOwnOrNew(node: any, key: string, path: string) { |
| 31 | // `in` throws on a primitive, such as the string a path `color.length` reads |
| 32 | // `length` from; Object() wraps it. |
| 33 | if (UNSAFE_KEYS.includes(key) || (node && !_hasOwn(node, key) && key in Object(node))) { |
| 34 | throw new Error(`Invalid defaults scope: ${path}`); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Checks every key of a path before anything is created, so that a rejected |