overzealous comment
Signed-off-by: aramissennyeydd <aramis.sennyey@doordash.com>
This commit is contained in:
committed by
Fredrik Adelöw
parent
6cf2ba39d9
commit
99ecdbaf95
@@ -42,18 +42,11 @@ export type DeepReadonly<T> = {
|
||||
|
||||
/**
|
||||
* 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 and related: https://github.com/Maggi64/moderndash/issues/139
|
||||
*
|
||||
* Does not work with Set and Map: https://stackoverflow.com/q/31509175
|
||||
* From https://gist.github.com/tkrotoff/e997cd6ff8d6cf6e51e6bb6146407fc3 +
|
||||
* https://stackoverflow.com/a/69656011
|
||||
*/
|
||||
export function deepFreeze<
|
||||
T,
|
||||
export function deepFreeze<T>(obj: T) {
|
||||
// Can cause: "Type instantiation is excessively deep and possibly infinite."
|
||||
>(obj: T) {
|
||||
// @ts-expect-error
|
||||
Object.values(obj).forEach(
|
||||
value => Object.isFrozen(value) || deepFreeze(value),
|
||||
|
||||
Reference in New Issue
Block a user