Skip to content

Commit f6691cd

Browse files
committed
deprecate type / fromType in favour of struct / fromStruct
1 parent 2dc13a8 commit f6691cd

37 files changed

+572
-295
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
- **Experimental**
2020
- `Schemable`
2121
- (\*) add `readonly` combinator (@gcanti)
22+
- (\*) add `struct` combinator (@gcanti)
23+
- deprecate `type` in favour of `struct` (@gcanti)
24+
- deprecate `fromType` in favour of `fromStruct` (@gcanti)
2225

2326
(\*) breaking change
2427

docs/modules/Codec.ts.md

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,21 @@ Added in v2.2.3
2727
- [fromArray](#fromarray)
2828
- [fromPartial](#frompartial)
2929
- [fromRecord](#fromrecord)
30+
- [fromStruct](#fromstruct)
3031
- [fromSum](#fromsum)
3132
- [fromTuple](#fromtuple)
32-
- [fromType](#fromtype)
3333
- [intersect](#intersect)
3434
- [lazy](#lazy)
3535
- [mapLeftWithInput](#mapleftwithinput)
3636
- [nullable](#nullable)
3737
- [partial](#partial)
3838
- [record](#record)
3939
- [refine](#refine)
40+
- [struct](#struct)
4041
- [sum](#sum)
4142
- [tuple](#tuple)
42-
- [type](#type)
43+
- [~~fromType~~](#fromtype)
44+
- [~~type~~](#type)
4345
- [constructors](#constructors)
4446
- [fromDecoder](#fromdecoder)
4547
- [literal](#literal)
@@ -137,6 +139,18 @@ export declare function fromRecord<I, O, A>(
137139

138140
Added in v2.2.3
139141

142+
## fromStruct
143+
144+
**Signature**
145+
146+
```ts
147+
export declare function fromStruct<P extends Record<string, Codec<any, any, any>>>(
148+
properties: P
149+
): Codec<{ [K in keyof P]: InputOf<P[K]> }, { [K in keyof P]: OutputOf<P[K]> }, { [K in keyof P]: TypeOf<P[K]> }>
150+
```
151+
152+
Added in v2.2.15
153+
140154
## fromSum
141155

142156
**Signature**
@@ -167,18 +181,6 @@ export declare const fromTuple: <C extends readonly Codec<any, any, any>[]>(
167181

168182
Added in v2.2.8
169183

170-
## fromType
171-
172-
**Signature**
173-
174-
```ts
175-
export declare function fromType<P extends Record<string, Codec<any, any, any>>>(
176-
properties: P
177-
): Codec<{ [K in keyof P]: InputOf<P[K]> }, { [K in keyof P]: OutputOf<P[K]> }, { [K in keyof P]: TypeOf<P[K]> }>
178-
```
179-
180-
Added in v2.2.8
181-
182184
## intersect
183185

184186
**Signature**
@@ -260,6 +262,18 @@ export declare const refine: <A, B extends A>(
260262

261263
Added in v2.2.3
262264

265+
## struct
266+
267+
**Signature**
268+
269+
```ts
270+
export declare function struct<P extends Record<string, Codec<unknown, any, any>>>(
271+
properties: P
272+
): Codec<unknown, { [K in keyof P]: OutputOf<P[K]> }, { [K in keyof P]: TypeOf<P[K]> }>
273+
```
274+
275+
Added in v2.2.15
276+
263277
## sum
264278

265279
**Signature**
@@ -286,14 +300,26 @@ export declare function tuple<C extends ReadonlyArray<Codec<unknown, any, any>>>
286300

287301
Added in v2.2.3
288302

289-
## type
303+
## ~~fromType~~
304+
305+
Use `fromStruct` instead.
290306

291307
**Signature**
292308

293309
```ts
294-
export declare function type<P extends Record<string, Codec<unknown, any, any>>>(
295-
properties: P
296-
): Codec<unknown, { [K in keyof P]: OutputOf<P[K]> }, { [K in keyof P]: TypeOf<P[K]> }>
310+
export declare const fromType: typeof fromStruct
311+
```
312+
313+
Added in v2.2.8
314+
315+
## ~~type~~
316+
317+
Use `struct` instead.
318+
319+
**Signature**
320+
321+
```ts
322+
export declare const type: typeof struct
297323
```
298324

299325
Added in v2.2.3

docs/modules/Decoder.ts.md

Lines changed: 56 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ Added in v2.2.7
3737
- [fromArray](#fromarray)
3838
- [fromPartial](#frompartial)
3939
- [fromRecord](#fromrecord)
40+
- [fromStruct](#fromstruct)
4041
- [fromSum](#fromsum)
4142
- [fromTuple](#fromtuple)
42-
- [fromType](#fromtype)
4343
- [intersect](#intersect)
4444
- [lazy](#lazy)
4545
- [mapLeftWithInput](#mapleftwithinput)
@@ -49,11 +49,13 @@ Added in v2.2.7
4949
- [readonly](#readonly)
5050
- [record](#record)
5151
- [refine](#refine)
52+
- [struct](#struct)
5253
- [sum](#sum)
5354
- [tuple](#tuple)
54-
- [type](#type)
5555
- [union](#union)
5656
- [withMessage](#withmessage)
57+
- [~~fromType~~](#fromtype)
58+
- [~~type~~](#type)
5759
- [constructors](#constructors)
5860
- [fromGuard](#fromguard)
5961
- [fromRefinement](#fromrefinement)
@@ -223,6 +225,18 @@ export declare const fromRecord: <I, A>(codomain: Decoder<I, A>) => Decoder<Reco
223225
224226
Added in v2.2.8
225227
228+
## fromStruct
229+
230+
**Signature**
231+
232+
```ts
233+
export declare const fromStruct: <P extends Record<string, Decoder<any, any>>>(
234+
properties: P
235+
) => Decoder<{ [K in keyof P]: K.InputOf<'Either', P[K]> }, { [K in keyof P]: K.TypeOf<'Either', P[K]> }>
236+
```
237+
238+
Added in v2.2.15
239+
226240
## fromSum
227241
228242
**Signature**
@@ -249,18 +263,6 @@ export declare const fromTuple: <C extends readonly Decoder<any, any>[]>(
249263
250264
Added in v2.2.8
251265
252-
## fromType
253-
254-
**Signature**
255-
256-
```ts
257-
export declare const fromType: <P extends Record<string, Decoder<any, any>>>(
258-
properties: P
259-
) => Decoder<{ [K in keyof P]: K.InputOf<'Either', P[K]> }, { [K in keyof P]: K.TypeOf<'Either', P[K]> }>
260-
```
261-
262-
Added in v2.2.8
263-
264266
## intersect
265267
266268
**Signature**
@@ -362,6 +364,18 @@ export declare const refine: <A, B extends A>(
362364
363365
Added in v2.2.7
364366
367+
## struct
368+
369+
**Signature**
370+
371+
```ts
372+
export declare const struct: <A>(
373+
properties: { [K in keyof A]: Decoder<unknown, A[K]> }
374+
) => Decoder<unknown, { [K in keyof A]: A[K] }>
375+
```
376+
377+
Added in v2.2.15
378+
365379
## sum
366380
367381
**Signature**
@@ -386,18 +400,6 @@ export declare const tuple: <A extends readonly unknown[]>(
386400
387401
Added in v2.2.7
388402
389-
## type
390-
391-
**Signature**
392-
393-
```ts
394-
export declare const type: <A>(
395-
properties: { [K in keyof A]: Decoder<unknown, A[K]> }
396-
) => Decoder<unknown, { [K in keyof A]: A[K] }>
397-
```
398-
399-
Added in v2.2.7
400-
401403
## union
402404
403405
**Signature**
@@ -422,6 +424,34 @@ export declare const withMessage: <I>(
422424
423425
Added in v2.2.9
424426
427+
## ~~fromType~~
428+
429+
Use `fromStruct` instead.
430+
431+
**Signature**
432+
433+
```ts
434+
export declare const fromType: <P extends Record<string, Decoder<any, any>>>(
435+
properties: P
436+
) => Decoder<{ [K in keyof P]: K.InputOf<'Either', P[K]> }, { [K in keyof P]: K.TypeOf<'Either', P[K]> }>
437+
```
438+
439+
Added in v2.2.8
440+
441+
## ~~type~~
442+
443+
Use `struct` instead.
444+
445+
**Signature**
446+
447+
```ts
448+
export declare const type: <A>(
449+
properties: { [K in keyof A]: Decoder<unknown, A[K]> }
450+
) => Decoder<unknown, { [K in keyof A]: A[K] }>
451+
```
452+
453+
Added in v2.2.7
454+
425455
# constructors
426456
427457
## fromGuard

docs/modules/Encoder.ts.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ Added in v2.2.3
3232
- [nullable](#nullable)
3333
- [partial](#partial)
3434
- [record](#record)
35+
- [struct](#struct)
3536
- [sum](#sum)
3637
- [tuple](#tuple)
37-
- [type](#type)
38+
- [~~type~~](#type)
3839
- [instances](#instances)
3940
- [Category](#category-1)
4041
- [Contravariant](#contravariant-1)
@@ -148,6 +149,18 @@ export declare function record<O, A>(codomain: Encoder<O, A>): Encoder<Record<st
148149

149150
Added in v2.2.3
150151

152+
## struct
153+
154+
**Signature**
155+
156+
```ts
157+
export declare function struct<P extends Record<string, Encoder<any, any>>>(
158+
properties: P
159+
): Encoder<{ [K in keyof P]: OutputOf<P[K]> }, { [K in keyof P]: TypeOf<P[K]> }>
160+
```
161+
162+
Added in v2.2.15
163+
151164
## sum
152165

153166
**Signature**
@@ -172,14 +185,14 @@ export declare function tuple<C extends ReadonlyArray<Encoder<any, any>>>(
172185

173186
Added in v2.2.3
174187

175-
## type
188+
## ~~type~~
189+
190+
Use `struct` instead.
176191

177192
**Signature**
178193

179194
```ts
180-
export declare function type<P extends Record<string, Encoder<any, any>>>(
181-
properties: P
182-
): Encoder<{ [K in keyof P]: OutputOf<P[K]> }, { [K in keyof P]: TypeOf<P[K]> }>
195+
export declare const type: typeof struct
183196
```
184197

185198
Added in v2.2.3

docs/modules/Eq.ts.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ Added in v2.2.2
2727
- [partial](#partial)
2828
- [readonly](#readonly)
2929
- [record](#record)
30+
- [struct](#struct)
3031
- [sum](#sum)
3132
- [tuple](#tuple)
32-
- [type](#type)
33+
- [~~type~~](#type)
3334
- [instances](#instances)
3435
- [Schemable](#schemable)
3536
- [WithRefine](#withrefine)
@@ -118,6 +119,16 @@ export declare const record: <A>(codomain: E.Eq<A>) => E.Eq<Record<string, A>>
118119

119120
Added in v2.2.2
120121

122+
## struct
123+
124+
**Signature**
125+
126+
```ts
127+
export declare const struct: <A>(eqs: { [K in keyof A]: E.Eq<A[K]> }) => E.Eq<{ [K in keyof A]: A[K] }>
128+
```
129+
130+
Added in v2.2.15
131+
121132
## sum
122133

123134
**Signature**
@@ -140,7 +151,9 @@ export declare const tuple: <A extends readonly unknown[]>(...components: { [K i
140151

141152
Added in v2.2.2
142153

143-
## type
154+
## ~~type~~
155+
156+
Use `struct` instead.
144157

145158
**Signature**
146159

0 commit comments

Comments
 (0)