Skip to content

Commit 0474d63

Browse files
committed
Add an overload to Object.freeze that preserves literal types
1 parent eb037f5 commit 0474d63

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/lib/es5.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,12 @@ interface ObjectConstructor {
204204
*/
205205
freeze<T extends Function>(f: T): T;
206206

207+
/**
208+
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
209+
* @param o Object on which to lock the attributes.
210+
*/
211+
freeze<T extends {[idx: string]: U | null | undefined | object}, U extends string | number | symbol>(o: T): Readonly<T>;
212+
207213
/**
208214
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
209215
* @param o Object on which to lock the attributes.

0 commit comments

Comments
 (0)