This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ReadonlyDeep } from 'type-fest'; | |
/** | |
* Deeply freezes an object by recursively freezing all of its properties. | |
* | |
* https://gist.github.com/tkrotoff/e997cd6ff8d6cf6e51e6bb6146407fc3 | |
* https://stackoverflow.com/a/69656011 | |
* | |
* FIXME Should be part of Lodash: https://github.com/Maggi64/moderndash/issues/139 | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Example usage: | |
* | |
* // default depth of 3: (fastest) | |
* type keys = Paths<SomeNestedObject> // returns "property" | "nested.property" | "nested.nested.property" | |
* | |
* // depth of 10: (can be slow) | |
* type keys = Paths<SomeNestedObject, 10> | |
* | |
* // depth of 10 with keys of type string and number: (slowest) |