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
This type is an alias for the `Readonly<T>` TypeScript utility type. It makes all properties of an Object `readonly` or marks an Array or Tuple as immutable `readonly T[]`.
4
+
5
+
## Example
6
+
7
+
When applied to a Object, each property of the Object will be marked as `TReadonly<T>`
8
+
9
+
```typescript
10
+
const T =Type.Object({ // const T = TObject<{
11
+
x: Type.Number(), // x: TNumber,
12
+
y: Type.Number(), // y: TNumber,
13
+
z: Type.Number() // z: TNumber,
14
+
}) // }>
15
+
16
+
const S =Type.ReadonlyType(T) // const S: TObject<{
17
+
// x: TReadonly<TNumber>,
18
+
// y: TReadonly<TNumber>,
19
+
// z: TReadonly<TNumber>
20
+
// }>
21
+
```
22
+
23
+
When applied to an Array or Tuple, the type is marked as `TImmutable<T>`
24
+
25
+
```typescript
26
+
const T =Type.Tuple([ // const T = TImmutable<TTuple<[
27
+
Type.Number(), // TNumber,
28
+
Type.String(), // TString
29
+
]) // ]>>
30
+
31
+
const S =Type.ReadonlyType(T) // const S: TImmutable<TTuple<[
32
+
// TNumber,
33
+
// TString
34
+
// }>>
35
+
36
+
typeS=Type.Static<typeofS> // type S = readonly [number, string]
<p>This type is an alias for the <code>Readonly<T></code> TypeScript utility type. It makes all properties of an Object <code>readonly</code> or marks an Array or Tuple as immutable <code>readonly T[]</code>.</p>
3
+
<h2>Example</h2>
4
+
<p>When applied to a Object, each property of the Object will be marked as <code>TReadonly<T></code></p>
5
+
<pre><codeclass="language-typescript">const T = Type.Object({ // const T = TObject<{
6
+
x: Type.Number(), // x: TNumber,
7
+
y: Type.Number(), // y: TNumber,
8
+
z: Type.Number() // z: TNumber,
9
+
}) // }>
10
+
11
+
const S = Type.ReadonlyType(T) // const S: TObject<{
12
+
// x: TReadonly<TNumber>,
13
+
// y: TReadonly<TNumber>,
14
+
// z: TReadonly<TNumber>
15
+
// }>
16
+
</code></pre>
17
+
<p>When applied to an Array or Tuple, the type is marked as <code>TImmutable<T></code></p>
18
+
<pre><codeclass="language-typescript">const T = Type.Tuple([ // const T = TImmutable<TTuple<[
19
+
Type.Number(), // TNumber,
20
+
Type.String(), // TString
21
+
]) // ]>>
22
+
23
+
const S = Type.ReadonlyType(T) // const S: TImmutable<TTuple<[
24
+
// TNumber,
25
+
// TString
26
+
// }>>
27
+
28
+
type S = Type.Static<typeof S> // type S = readonly [number, string]
0 commit comments