ts-fortress 6.2.2 → 6.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/README.md +1 -1
  2. package/dist/array/array-at-least-length.d.mts +2 -2
  3. package/dist/array/array-at-least-length.d.mts.map +1 -1
  4. package/dist/array/array-at-least-length.mjs.map +1 -1
  5. package/dist/array/array-of-length.d.mts +2 -2
  6. package/dist/array/array-of-length.d.mts.map +1 -1
  7. package/dist/array/array-of-length.mjs.map +1 -1
  8. package/dist/array/array.d.mts +2 -2
  9. package/dist/array/array.d.mts.map +1 -1
  10. package/dist/array/array.mjs.map +1 -1
  11. package/dist/array/non-empty-array.d.mts +2 -2
  12. package/dist/array/non-empty-array.d.mts.map +1 -1
  13. package/dist/array/non-empty-array.mjs.map +1 -1
  14. package/dist/array/tuple.d.mts +5 -5
  15. package/dist/array/tuple.d.mts.map +1 -1
  16. package/dist/array/tuple.mjs.map +1 -1
  17. package/dist/brand/brand.d.mts +1 -1
  18. package/dist/brand/brand.d.mts.map +1 -1
  19. package/dist/compose/intersection.d.mts +4 -4
  20. package/dist/compose/intersection.d.mts.map +1 -1
  21. package/dist/compose/intersection.mjs.map +1 -1
  22. package/dist/compose/merge-records.d.mts +3 -3
  23. package/dist/compose/merge-records.d.mts.map +1 -1
  24. package/dist/compose/merge-records.mjs.map +1 -1
  25. package/dist/compose/union.d.mts +2 -2
  26. package/dist/compose/union.d.mts.map +1 -1
  27. package/dist/compose/union.mjs.map +1 -1
  28. package/dist/enum/enum.d.mts +2 -2
  29. package/dist/enum/enum.d.mts.map +1 -1
  30. package/dist/enum/enum.mjs.map +1 -1
  31. package/dist/globals.d.mts +0 -2
  32. package/dist/other-types/map.d.mts +2 -2
  33. package/dist/other-types/map.d.mts.map +1 -1
  34. package/dist/other-types/map.mjs.map +1 -1
  35. package/dist/other-types/recursion.d.mts +2 -2
  36. package/dist/other-types/recursion.d.mts.map +1 -1
  37. package/dist/other-types/recursion.mjs +5 -7
  38. package/dist/other-types/recursion.mjs.map +1 -1
  39. package/dist/other-types/set.d.mts +2 -2
  40. package/dist/other-types/set.d.mts.map +1 -1
  41. package/dist/other-types/set.mjs.map +1 -1
  42. package/dist/predefined/brand/string/email.d.mts +2 -2
  43. package/dist/predefined/brand/string/email.d.mts.map +1 -1
  44. package/dist/predefined/brand/string/email.mjs.map +1 -1
  45. package/dist/predefined/brand/string/json-string.d.mts +2 -2
  46. package/dist/predefined/brand/string/json-string.d.mts.map +1 -1
  47. package/dist/predefined/brand/string/json-string.mjs.map +1 -1
  48. package/dist/predefined/brand/string/uuid.d.mts +2 -2
  49. package/dist/predefined/brand/string/uuid.d.mts.map +1 -1
  50. package/dist/predefined/brand/string/uuid.mjs.map +1 -1
  51. package/dist/primitives/bigint.d.mts +10 -10
  52. package/dist/primitives/bigint.d.mts.map +1 -1
  53. package/dist/primitives/bigint.mjs.map +1 -1
  54. package/dist/primitives/number.d.mts +10 -10
  55. package/dist/primitives/number.d.mts.map +1 -1
  56. package/dist/primitives/number.mjs.map +1 -1
  57. package/dist/primitives/string.d.mts +20 -20
  58. package/dist/primitives/string.d.mts.map +1 -1
  59. package/dist/primitives/string.mjs.map +1 -1
  60. package/dist/record/key-value-record.d.mts +2 -2
  61. package/dist/record/key-value-record.d.mts.map +1 -1
  62. package/dist/record/key-value-record.mjs.map +1 -1
  63. package/dist/record/keyof.d.mts +2 -2
  64. package/dist/record/keyof.d.mts.map +1 -1
  65. package/dist/record/keyof.mjs.map +1 -1
  66. package/dist/record/omit.d.mts +2 -2
  67. package/dist/record/omit.d.mts.map +1 -1
  68. package/dist/record/omit.mjs.map +1 -1
  69. package/dist/record/partial.d.mts +8 -8
  70. package/dist/record/partial.d.mts.map +1 -1
  71. package/dist/record/partial.mjs.map +1 -1
  72. package/dist/record/pick.d.mts +2 -2
  73. package/dist/record/pick.d.mts.map +1 -1
  74. package/dist/record/pick.mjs.map +1 -1
  75. package/dist/record/record.d.mts +4 -4
  76. package/dist/record/record.d.mts.map +1 -1
  77. package/dist/record/record.mjs.map +1 -1
  78. package/dist/record/required.d.mts +8 -8
  79. package/dist/record/required.d.mts.map +1 -1
  80. package/dist/record/required.mjs.map +1 -1
  81. package/dist/record/valueof.d.mts +2 -2
  82. package/dist/record/valueof.d.mts.map +1 -1
  83. package/dist/record/valueof.mjs.map +1 -1
  84. package/dist/type.d.mts +4 -4
  85. package/dist/type.d.mts.map +1 -1
  86. package/package.json +26 -19
  87. package/src/array/array-at-least-length.mts +6 -4
  88. package/src/array/array-of-length.mts +6 -4
  89. package/src/array/array.mts +6 -4
  90. package/src/array/non-empty-array.mts +6 -4
  91. package/src/array/tuple.mts +8 -6
  92. package/src/brand/brand.mts +1 -1
  93. package/src/compose/intersection.mts +76 -59
  94. package/src/compose/merge-records.mts +74 -59
  95. package/src/compose/union-literal-array.test.mts +1 -1
  96. package/src/compose/union-nested-record.test.mts +10 -8
  97. package/src/compose/union-records.test.mts +10 -8
  98. package/src/compose/union.mts +18 -8
  99. package/src/enum/enum.mts +6 -4
  100. package/src/globals.d.mts +0 -2
  101. package/src/other-types/map.mts +5 -3
  102. package/src/other-types/recursion.mts +10 -10
  103. package/src/other-types/recursion.test.mts +1 -1
  104. package/src/other-types/set.mts +5 -3
  105. package/src/predefined/brand/string/email.mts +5 -3
  106. package/src/predefined/brand/string/json-string.mts +5 -3
  107. package/src/predefined/brand/string/uuid.mts +10 -8
  108. package/src/primitives/bigint.mts +24 -30
  109. package/src/primitives/number.mts +24 -30
  110. package/src/primitives/string.mts +53 -58
  111. package/src/record/key-value-record.mts +5 -3
  112. package/src/record/keyof.mts +17 -9
  113. package/src/record/omit.mts +19 -14
  114. package/src/record/partial.mts +25 -18
  115. package/src/record/pick.mts +19 -14
  116. package/src/record/record.mts +28 -24
  117. package/src/record/required.mts +27 -26
  118. package/src/record/valueof.mts +9 -7
  119. package/src/type.mts +9 -15
@@ -15,11 +15,13 @@ export const omit = <
15
15
  >(
16
16
  recordType: RecordType<R, ExcessValidation>,
17
17
  keysToOmit: KeysToOmit,
18
- options?: PartialReadonly<{
19
- typeName: string;
20
- excessPropertyValidation: ExcessValidation;
21
- excessPropertyFill: Extract<ExcessPropertyBehavior, 'allow' | 'strip'>;
22
- }>,
18
+ options?: Partial<
19
+ Readonly<{
20
+ typeName: string;
21
+ excessPropertyValidation: ExcessValidation;
22
+ excessPropertyFill: Extract<ExcessPropertyBehavior, 'allow' | 'strip'>;
23
+ }>
24
+ >,
23
25
  ): OmittedType<R, KeysToOmit, ExcessValidation> =>
24
26
  record(Obj.omit(recordType.shape, keysToOmit), {
25
27
  typeName:
@@ -38,27 +40,30 @@ export type OmittedType<
38
40
  > = RecordType<Omit<R, ArrayElement<KeysToOmit>>, ExcessValidation>;
39
41
 
40
42
  expectType<
41
- Omit<{ a: Type<0>; b: Type<1>; c: Type<2> }, 'a' | 'b'>,
42
- {
43
+ Omit<Readonly<{ a: Type<0>; b: Type<1>; c: Type<2> }>, 'a' | 'b'>,
44
+ Readonly<{
43
45
  c: Type<2>;
44
- }
46
+ }>
45
47
  >('=');
46
48
 
47
49
  expectType<
48
- RecordType<Omit<{ a: Type<0>; b: Type<1>; c: Type<2> }, 'a' | 'b'>>,
50
+ RecordType<Omit<Readonly<{ a: Type<0>; b: Type<1>; c: Type<2> }>, 'a' | 'b'>>,
49
51
  Type<Readonly<{ c: 2 }>> &
50
52
  Readonly<{
51
- shape: { c: Type<2> };
53
+ shape: Readonly<{ c: Type<2> }>;
52
54
  excessPropertyValidation: 'strip';
53
55
  excessPropertyFill: 'allow' | 'strip';
54
56
  }>
55
57
  >('=');
56
58
 
57
59
  expectType<
58
- OmittedType<{ a: Type<0>; b: Type<1>; c: Type<2> }, ['a', 'b']>,
60
+ OmittedType<
61
+ Readonly<{ a: Type<0>; b: Type<1>; c: Type<2> }>,
62
+ readonly ['a', 'b']
63
+ >,
59
64
  Type<Readonly<{ c: 2 }>> &
60
65
  Readonly<{
61
- shape: { c: Type<2> };
66
+ shape: Readonly<{ c: Type<2> }>;
62
67
  excessPropertyValidation: 'strip';
63
68
  excessPropertyFill: 'allow' | 'strip';
64
69
  }>
@@ -66,9 +71,9 @@ expectType<
66
71
 
67
72
  expectType<
68
73
  OmittedType<
69
- { a: Type<0>; b: Type<1>; c: Type<2> },
74
+ Readonly<{ a: Type<0>; b: Type<1>; c: Type<2> }>,
70
75
  // @ts-expect-error key "d" doesn't exist
71
- ['a', 'd']
76
+ readonly ['a', 'd']
72
77
  >,
73
78
  0
74
79
  >('!=');
@@ -18,12 +18,14 @@ export const partial = <
18
18
  const ExcessValidation extends ExcessPropertyBehavior = 'strip',
19
19
  >(
20
20
  recordType: RecordType<R, ExcessValidation>,
21
- options?: PartialReadonly<{
22
- keysToBeOptional: KeysToBeOptional;
23
- typeName: string;
24
- excessPropertyValidation: ExcessValidation;
25
- excessPropertyFill: Extract<ExcessPropertyBehavior, 'allow' | 'strip'>;
26
- }>,
21
+ options?: Partial<
22
+ Readonly<{
23
+ keysToBeOptional: KeysToBeOptional;
24
+ typeName: string;
25
+ excessPropertyValidation: ExcessValidation;
26
+ excessPropertyFill: Extract<ExcessPropertyBehavior, 'allow' | 'strip'>;
27
+ }>
28
+ >,
27
29
  ): PartialType<R, KeysToBeOptional, ExcessValidation> => {
28
30
  const typeNameFilled: string =
29
31
  options?.typeName ??
@@ -63,16 +65,15 @@ type PartialTypeShape<
63
65
  ? FullyOptionalType<R>
64
66
  : PartiallyOptionalType<R, ArrayElement<KeysToBeOptional>>;
65
67
 
66
- type FullyOptionalType<R extends ReadonlyRecord<string, Type<unknown>>> = {
67
- readonly [P in keyof R]: OptionalPropertyType<R[P]>;
68
- };
68
+ type FullyOptionalType<R extends ReadonlyRecord<string, Type<unknown>>> =
69
+ Readonly<{ [P in keyof R]: OptionalPropertyType<R[P]> }>;
69
70
 
70
71
  type PartiallyOptionalType<
71
72
  R extends ReadonlyRecord<string, Type<unknown>>,
72
73
  K extends keyof R,
73
- > = {
74
- readonly [P in keyof R]: P extends K ? OptionalPropertyType<R[P]> : R[P];
75
- };
74
+ > = Readonly<{
75
+ [P in keyof R]: P extends K ? OptionalPropertyType<R[P]> : R[P];
76
+ }>;
76
77
 
77
78
  export type PartialType<
78
79
  R extends ReadonlyRecord<string, Type<unknown>>,
@@ -81,7 +82,10 @@ export type PartialType<
81
82
  > = RecordType<PartialTypeShape<R, KeysToBeOptional>, ExcessValidation>;
82
83
 
83
84
  expectType<
84
- PartialTypeShape<{ a: Type<0>; b: Type<1>; c: Type<2> }, ['a']>,
85
+ PartialTypeShape<
86
+ Readonly<{ a: Type<0>; b: Type<1>; c: Type<2> }>,
87
+ readonly ['a']
88
+ >,
85
89
  Readonly<{
86
90
  a: OptionalPropertyType<Type<0>>;
87
91
  b: Type<1>;
@@ -142,7 +146,7 @@ expectType<
142
146
  >('=');
143
147
 
144
148
  expectType<
145
- PartialType<{ a: Type<0>; b: Type<1>; c: Type<2> }, ['a']>,
149
+ PartialType<Readonly<{ a: Type<0>; b: Type<1>; c: Type<2> }>, readonly ['a']>,
146
150
  Type<
147
151
  Readonly<{
148
152
  a?: 0;
@@ -162,7 +166,10 @@ expectType<
162
166
  >('=');
163
167
 
164
168
  expectType<
165
- PartialType<{ a: Type<0>; b: Type<1>; c: Type<2> }, ['a', 'b']>,
169
+ PartialType<
170
+ Readonly<{ a: Type<0>; b: Type<1>; c: Type<2> }>,
171
+ readonly ['a', 'b']
172
+ >,
166
173
  Type<
167
174
  Readonly<{
168
175
  a?: 0;
@@ -182,7 +189,7 @@ expectType<
182
189
  >('=');
183
190
 
184
191
  expectType<
185
- PartialType<{ a: Type<0>; b: Type<1>; c: Type<2> }, undefined>,
192
+ PartialType<Readonly<{ a: Type<0>; b: Type<1>; c: Type<2> }>, undefined>,
186
193
  Type<
187
194
  Readonly<{
188
195
  a?: 0;
@@ -203,9 +210,9 @@ expectType<
203
210
 
204
211
  expectType<
205
212
  PartialType<
206
- { a: Type<0>; b: Type<1>; c: Type<2> },
213
+ Readonly<{ a: Type<0>; b: Type<1>; c: Type<2> }>,
207
214
  // @ts-expect-error key "d" doesn't exist
208
- ['a', 'd']
215
+ readonly ['a', 'd']
209
216
  >,
210
217
  0
211
218
  >('!=');
@@ -15,11 +15,13 @@ export const pick = <
15
15
  >(
16
16
  recordType: RecordType<R, ExcessValidation>,
17
17
  keysToPick: KeysToPick,
18
- options?: PartialReadonly<{
19
- typeName: string;
20
- excessPropertyValidation: ExcessValidation;
21
- excessPropertyFill: Extract<ExcessPropertyBehavior, 'allow' | 'strip'>;
22
- }>,
18
+ options?: Partial<
19
+ Readonly<{
20
+ typeName: string;
21
+ excessPropertyValidation: ExcessValidation;
22
+ excessPropertyFill: Extract<ExcessPropertyBehavior, 'allow' | 'strip'>;
23
+ }>
24
+ >,
23
25
  ): PickedType<R, KeysToPick, ExcessValidation> =>
24
26
  record(Obj.pick(recordType.shape, keysToPick), {
25
27
  typeName:
@@ -38,28 +40,31 @@ export type PickedType<
38
40
  > = RecordType<Pick<R, ArrayElement<KeysToPick>>, ExcessValidation>;
39
41
 
40
42
  expectType<
41
- Pick<{ a: Type<0>; b: Type<1>; c: Type<2> }, 'a' | 'b'>,
42
- {
43
+ Pick<Readonly<{ a: Type<0>; b: Type<1>; c: Type<2> }>, 'a' | 'b'>,
44
+ Readonly<{
43
45
  a: Type<0>;
44
46
  b: Type<1>;
45
- }
47
+ }>
46
48
  >('=');
47
49
 
48
50
  expectType<
49
- RecordType<Pick<{ a: Type<0>; b: Type<1>; c: Type<2> }, 'a' | 'b'>>,
51
+ RecordType<Pick<Readonly<{ a: Type<0>; b: Type<1>; c: Type<2> }>, 'a' | 'b'>>,
50
52
  Type<Readonly<{ a: 0; b: 1 }>> &
51
53
  Readonly<{
52
- shape: { a: Type<0>; b: Type<1> };
54
+ shape: Readonly<{ a: Type<0>; b: Type<1> }>;
53
55
  excessPropertyValidation: 'strip';
54
56
  excessPropertyFill: 'allow' | 'strip';
55
57
  }>
56
58
  >('=');
57
59
 
58
60
  expectType<
59
- PickedType<{ a: Type<0>; b: Type<1>; c: Type<2> }, ['a', 'b']>,
61
+ PickedType<
62
+ Readonly<{ a: Type<0>; b: Type<1>; c: Type<2> }>,
63
+ readonly ['a', 'b']
64
+ >,
60
65
  Type<Readonly<{ a: 0; b: 1 }>> &
61
66
  Readonly<{
62
- shape: { a: Type<0>; b: Type<1> };
67
+ shape: Readonly<{ a: Type<0>; b: Type<1> }>;
63
68
  excessPropertyValidation: 'strip';
64
69
  excessPropertyFill: 'allow' | 'strip';
65
70
  }>
@@ -67,9 +72,9 @@ expectType<
67
72
 
68
73
  expectType<
69
74
  PickedType<
70
- { a: Type<0>; b: Type<1>; c: Type<2> },
75
+ Readonly<{ a: Type<0>; b: Type<1>; c: Type<2> }>,
71
76
  // @ts-expect-error key "d" doesn't exist
72
- ['a', 'd']
77
+ readonly ['a', 'd']
73
78
  >,
74
79
  0
75
80
  >('!=');
@@ -20,26 +20,28 @@ export const record = <
20
20
  const ExcessValidation extends ExcessPropertyBehavior = 'strip',
21
21
  >(
22
22
  shape: R,
23
- options?: PartialReadonly<{
24
- typeName: string;
25
-
26
- /**
27
- * Behavior when validating objects with excess properties.
28
- * - 'allow': Accept excess properties
29
- * - 'strip': Remove excess properties from the result (default)
30
- * - 'error': Reject objects with excess properties
31
- * @default 'strip'
32
- */
33
- excessPropertyValidation: ExcessValidation;
34
-
35
- /**
36
- * Behavior when filling objects with excess properties.
37
- * - 'allow': Keep excess properties in the result
38
- * - 'strip': Remove excess properties from the result (default)
39
- * @default 'strip'
40
- */
41
- excessPropertyFill: ExcessPropertyFillBehavior;
42
- }>,
23
+ options?: Partial<
24
+ Readonly<{
25
+ typeName: string;
26
+
27
+ /**
28
+ * Behavior when validating objects with excess properties.
29
+ * - 'allow': Accept excess properties
30
+ * - 'strip': Remove excess properties from the result (default)
31
+ * - 'error': Reject objects with excess properties
32
+ * @default 'strip'
33
+ */
34
+ excessPropertyValidation: ExcessValidation;
35
+
36
+ /**
37
+ * Behavior when filling objects with excess properties.
38
+ * - 'allow': Keep excess properties in the result
39
+ * - 'strip': Remove excess properties from the result (default)
40
+ * @default 'strip'
41
+ */
42
+ excessPropertyFill: ExcessPropertyFillBehavior;
43
+ }>
44
+ >,
43
45
  ): RecordType<R, ExcessValidation> => {
44
46
  type T = ExcessValidation extends 'allow'
45
47
  ? TsFortressInternal.RecordTypeValue<R> | UnknownRecord
@@ -224,9 +226,11 @@ export const strictRecord = <
224
226
  const R extends ReadonlyRecord<string, Type<unknown>>,
225
227
  >(
226
228
  source: R,
227
- options?: PartialReadonly<{
228
- typeName: string;
229
- excessPropertyFill: Extract<ExcessPropertyBehavior, 'allow' | 'strip'>;
230
- }>,
229
+ options?: Partial<
230
+ Readonly<{
231
+ typeName: string;
232
+ excessPropertyFill: Extract<ExcessPropertyBehavior, 'allow' | 'strip'>;
233
+ }>
234
+ >,
231
235
  ): RecordType<R, 'error'> =>
232
236
  record(source, { ...options, excessPropertyValidation: 'error' });
@@ -22,12 +22,14 @@ export const required = <
22
22
  const ExcessValidation extends ExcessPropertyBehavior = 'strip',
23
23
  >(
24
24
  recordType: RecordType<R, ExcessValidation>,
25
- options?: PartialReadonly<{
26
- keysToBeRequired: KeysToBeRequired;
27
- typeName: string;
28
- excessPropertyValidation: ExcessValidation;
29
- excessPropertyFill: Extract<ExcessPropertyBehavior, 'allow' | 'strip'>;
30
- }>,
25
+ options?: Partial<
26
+ Readonly<{
27
+ keysToBeRequired: KeysToBeRequired;
28
+ typeName: string;
29
+ excessPropertyValidation: ExcessValidation;
30
+ excessPropertyFill: Extract<ExcessPropertyBehavior, 'allow' | 'strip'>;
31
+ }>
32
+ >,
31
33
  ): RequiredType<R, KeysToBeRequired, ExcessValidation> => {
32
34
  const typeNameFilled: string =
33
35
  options?.typeName ??
@@ -78,16 +80,15 @@ type RequiredTypeShape<
78
80
  ? FullyRequiredType<R>
79
81
  : PartiallyRequiredType<R, ArrayElement<KeysToBeRequired>>;
80
82
 
81
- type FullyRequiredType<R extends ReadonlyRecord<string, Type<unknown>>> = {
82
- readonly [P in keyof R]: RequiredPropertyType<R[P]>;
83
- };
83
+ type FullyRequiredType<R extends ReadonlyRecord<string, Type<unknown>>> =
84
+ Readonly<{ [P in keyof R]: RequiredPropertyType<R[P]> }>;
84
85
 
85
86
  type PartiallyRequiredType<
86
87
  R extends ReadonlyRecord<string, Type<unknown>>,
87
88
  K extends keyof R,
88
- > = {
89
- readonly [P in keyof R]: P extends K ? RequiredPropertyType<R[P]> : R[P];
90
- };
89
+ > = Readonly<{
90
+ [P in keyof R]: P extends K ? RequiredPropertyType<R[P]> : R[P];
91
+ }>;
91
92
 
92
93
  export type RequiredType<
93
94
  R extends ReadonlyRecord<string, Type<unknown>>,
@@ -97,12 +98,12 @@ export type RequiredType<
97
98
 
98
99
  expectType<
99
100
  RequiredTypeShape<
100
- {
101
+ Readonly<{
101
102
  a: OptionalPropertyType<Type<0>>;
102
103
  b: Type<1>;
103
104
  c: OptionalPropertyType<Type<2>>;
104
- },
105
- ['a']
105
+ }>,
106
+ readonly ['a']
106
107
  >,
107
108
  Readonly<{
108
109
  a: Type<0>;
@@ -165,12 +166,12 @@ expectType<
165
166
 
166
167
  expectType<
167
168
  RequiredType<
168
- {
169
+ Readonly<{
169
170
  a: OptionalPropertyType<Type<0>>;
170
171
  b: Type<1>;
171
172
  c: OptionalPropertyType<Type<2>>;
172
- },
173
- ['a']
173
+ }>,
174
+ readonly ['a']
174
175
  >,
175
176
  Type<
176
177
  Readonly<{
@@ -192,12 +193,12 @@ expectType<
192
193
 
193
194
  expectType<
194
195
  RequiredType<
195
- {
196
+ Readonly<{
196
197
  a: OptionalPropertyType<Type<0>>;
197
198
  b: OptionalPropertyType<Type<1>>;
198
199
  c: Type<2>;
199
- },
200
- ['a', 'b']
200
+ }>,
201
+ readonly ['a', 'b']
201
202
  >,
202
203
  Type<
203
204
  Readonly<{
@@ -219,11 +220,11 @@ expectType<
219
220
 
220
221
  expectType<
221
222
  RequiredType<
222
- {
223
+ Readonly<{
223
224
  a: OptionalPropertyType<Type<0>>;
224
225
  b: OptionalPropertyType<Type<1>>;
225
226
  c: OptionalPropertyType<Type<2>>;
226
- },
227
+ }>,
227
228
  undefined
228
229
  >,
229
230
  Type<
@@ -246,13 +247,13 @@ expectType<
246
247
 
247
248
  expectType<
248
249
  RequiredType<
249
- {
250
+ Readonly<{
250
251
  a: OptionalPropertyType<Type<0>>;
251
252
  b: Type<1>;
252
253
  c: OptionalPropertyType<Type<2>>;
253
- },
254
+ }>,
254
255
  // @ts-expect-error key "d" doesn't exist
255
- ['a', 'd']
256
+ readonly ['a', 'd']
256
257
  >,
257
258
  0
258
259
  >('!=');
@@ -5,9 +5,11 @@ import { type RecordType, type Type } from '../type.mjs';
5
5
 
6
6
  export const valueof = <const R extends ReadonlyRecord<string, Type<unknown>>>(
7
7
  recordType: RecordType<R>,
8
- options?: PartialReadonly<{
9
- typeName: string;
10
- }>,
8
+ options?: Partial<
9
+ Readonly<{
10
+ typeName: string;
11
+ }>
12
+ >,
11
13
  ): ValueOfType<R> => {
12
14
  const types = Object.values(recordType.shape);
13
15
 
@@ -38,18 +40,18 @@ type ValueOfType<R extends ReadonlyRecord<string, Type<unknown>>> =
38
40
  expectType<ValueOfType<{}>, Type<undefined>>('=');
39
41
 
40
42
  expectType<
41
- ValueOfType<{ a: Type<0>; b: Type<1>; c: Type<2> }>,
43
+ ValueOfType<Readonly<{ a: Type<0>; b: Type<1>; c: Type<2> }>>,
42
44
  Type<0 | 1 | 2>
43
45
  >('=');
44
46
 
45
47
  expectType<
46
- ValueOfType<{ x: Type<string>; y: Type<number>; z: Type<boolean> }>,
48
+ ValueOfType<Readonly<{ x: Type<string>; y: Type<number>; z: Type<boolean> }>>,
47
49
  Type<string | number | boolean>
48
50
  >('=');
49
51
 
50
52
  expectType<
51
- ValueOfType<{ same: Type<string>; value: Type<string> }>,
53
+ ValueOfType<Readonly<{ same: Type<string>; value: Type<string> }>>,
52
54
  Type<string>
53
55
  >('=');
54
56
 
55
- expectType<ValueOfType<{ never: Type<never> }>, Type<never>>('=');
57
+ expectType<ValueOfType<Readonly<{ never: Type<never> }>>, Type<never>>('=');
package/src/type.mts CHANGED
@@ -56,10 +56,10 @@ export type RecordType<
56
56
  }>;
57
57
 
58
58
  expectType<
59
- RecordType<{ a: Type<0>; b: Type<1>; c: Type<2> }>,
59
+ RecordType<Readonly<{ a: Type<0>; b: Type<1>; c: Type<2> }>>,
60
60
  Type<Readonly<{ a: 0; b: 1; c: 2 }>> &
61
61
  Readonly<{
62
- shape: { a: Type<0>; b: Type<1>; c: Type<2> };
62
+ shape: Readonly<{ a: Type<0>; b: Type<1>; c: Type<2> }>;
63
63
  excessPropertyValidation: 'strip';
64
64
  excessPropertyFill: ExcessPropertyFillBehavior;
65
65
  }>
@@ -78,26 +78,20 @@ export namespace TsFortressInternal {
78
78
  OptionalKeys extends keyof A,
79
79
  > =
80
80
  TypeEq<OptionalKeys, never> extends true
81
- ? Readonly<{
82
- [key in Exclude<keyof A, OptionalKeys>]: TypeOf<A[key]>;
83
- }>
81
+ ? Readonly<{ [key in Exclude<keyof A, OptionalKeys>]: TypeOf<A[key]> }>
84
82
  : TypeEq<keyof A, OptionalKeys> extends true
85
- ? Readonly<
86
- MergeIntersection<{
87
- [key in OptionalKeys]?: TypeOf<A[key]>;
88
- }>
83
+ ? MergeIntersection<
84
+ Readonly<{ [key in OptionalKeys]?: TypeOf<A[key]> }>
89
85
  >
90
- : Readonly<
91
- MergeIntersection<
92
- {
93
- [key in OptionalKeys]?: TypeOf<A[key]>;
94
- } & {
86
+ : MergeIntersection<
87
+ Readonly<
88
+ { [key in OptionalKeys]?: TypeOf<A[key]> } & {
95
89
  [key in Exclude<keyof A, OptionalKeys>]: TypeOf<A[key]>;
96
90
  }
97
91
  >
98
92
  >;
99
93
 
100
94
  type OptionalTypeKeys<A extends ReadonlyRecord<string, Type<unknown>>> = {
101
- [K in keyof A]: A[K] extends { optional: true } ? K : never;
95
+ [K in keyof A]: A[K] extends Readonly<{ optional: true }> ? K : never;
102
96
  }[keyof A];
103
97
  }