You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: readme.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -114,7 +114,7 @@ Click the type names for complete docs.
114
114
-[`NonEmptyObject`](source/non-empty-object.d.ts) - Represents an object with at least 1 non-optional key.
115
115
-[`UnknownRecord`](source/unknown-record.d.ts) - Represents an object with `unknown` value. You probably want this instead of `{}`.
116
116
-[`Except`](source/except.d.ts) - Create a type from an object type without certain keys. This is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys).
117
-
-[`Writable`](source/writable.d.ts) - Create a type that strips `readonly` from all or some of an object's keys. The inverse of `Readonly<T>`.
117
+
-[`Writable`](source/writable.d.ts) - Create a type that strips `readonly` from the given type. Inverse of `Readonly<T>`.
118
118
-[`WritableDeep`](source/writable-deep.d.ts) - Create a deeply mutable version of an `object`/`ReadonlyMap`/`ReadonlySet`/`ReadonlyArray` type. The inverse of `ReadonlyDeep<T>`. Use `Writable<T>` if you only need one level deep.
119
119
-[`Merge`](source/merge.d.ts) - Merge two types into a new type. Keys of the second type overrides keys of the first type.
120
120
-[`MergeDeep`](source/merge-deep.d.ts) - Merge two objects or two arrays/tuples recursively into a new type.
: ArrayTypeextendsreadonly[...infer U, infer V] ? [...U,V]
10
+
: ArrayTypeextendsreadonly[infer U, ...infer V] ? [U, ...V]
11
+
: ArrayTypeextendsReadonlyArray<infer U> ? U[]
12
+
: ArrayType;
13
+
14
+
/**
15
+
Create a type that strips `readonly` from the given type. Inverse of `Readonly<T>`.
16
+
17
+
The 2nd argument will be ignored if the input type is not an object.
18
+
19
+
Note: This type can make readonly `Set` and `Map` writable. This behavior is different from `Readonly<T>` (as of TypeScript 5.2.2). See: https://github.com/microsoft/TypeScript/issues/29655
6
20
7
21
This can be used to [store and mutate options within a class](https://github.com/sindresorhus/pageres/blob/4a5d05fca19a5fbd2f53842cbf3eb7b1b63bddd2/source/index.ts#L72), [edit `readonly` objects within tests](https://stackoverflow.com/questions/50703834), [construct a `readonly` object within a function](https://github.com/Microsoft/TypeScript/issues/24509), or to define a single model where the only thing that changes is whether or not some of the keys are writable.
0 commit comments