Skip to content

Commit d32196f

Browse files
committed
Add predefined mapped types and revise Object.freeze
1 parent fe3f88c commit d32196f

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/lib/es5.d.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ interface ObjectConstructor {
180180
* Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
181181
* @param o Object on which to lock the attributes.
182182
*/
183-
freeze<T>(o: T): T;
183+
freeze<T>(o: T): Readonly<T>;
184184

185185
/**
186186
* Prevents the addition of new properties to an object.
@@ -1343,6 +1343,34 @@ interface ArrayLike<T> {
13431343
readonly [n: number]: T;
13441344
}
13451345

1346+
/**
1347+
* Make all properties in T optional
1348+
*/
1349+
type Partial<T> = {
1350+
[P in keyof T]?: T[P];
1351+
};
1352+
1353+
/**
1354+
* Make all properties in T readonly
1355+
*/
1356+
type Readonly<T> = {
1357+
readonly [P in keyof T]: T[P];
1358+
};
1359+
1360+
/**
1361+
* From T pick a set of properties K
1362+
*/
1363+
type Pick<T, K extends keyof T> = {
1364+
[P in K]: T[P];
1365+
}
1366+
1367+
/**
1368+
* Construct a type with a set of properties K of type T
1369+
*/
1370+
type Record<K extends string | number, T> = {
1371+
[P in K]: T;
1372+
}
1373+
13461374
/**
13471375
* Represents a raw buffer of binary data, which is used to store data for the
13481376
* different typed arrays. ArrayBuffers cannot be read from or written to directly,

0 commit comments

Comments
 (0)