@@ -44,7 +44,7 @@ const userDecoder = fields(
44
44
active: field (" is_active" , boolean ),
45
45
age: field (" age" , optional (number )),
46
46
interests: field (" interests" , array (string )),
47
- })
47
+ }),
48
48
);
49
49
50
50
const payload: unknown = getSomeJSON ();
@@ -299,7 +299,7 @@ Decodes a JSON string into a TypeScript `string`.
299
299
300
300
``` ts
301
301
function stringUnion<T extends [string , ... Array <string >]>(
302
- variants : T
302
+ variants : T ,
303
303
): Decoder <T [number ]>;
304
304
```
305
305
@@ -347,15 +347,15 @@ For example, `record(number)` decodes an object where the keys can be anything a
347
347
function fields<T >(
348
348
callback : (
349
349
field : <U >(key : string , decoder : Decoder <U >) => U ,
350
- object : Record <string , unknown >
350
+ object : Record <string , unknown >,
351
351
) => T ,
352
352
{
353
353
exact = " allow extra" ,
354
354
allow = " object" ,
355
355
}: {
356
356
exact? : " allow extra" | " throw" ;
357
357
allow? : " array" | " object" ;
358
- } = {}
358
+ } = {},
359
359
): Decoder <T >;
360
360
```
361
361
@@ -386,7 +386,7 @@ const userDecoder = fields(
386
386
description: field (" description" , optional (string )),
387
387
// Hardcoded field:
388
388
version: 1 ,
389
- })
389
+ }),
390
390
);
391
391
392
392
// Plucking a single field out of an object:
@@ -460,7 +460,7 @@ type Values<T> = T[keyof T];
460
460
461
461
function fieldsUnion<T extends Record <string , Decoder <unknown >>>(
462
462
key : string ,
463
- mapping : T
463
+ mapping : T ,
464
464
): Decoder <
465
465
Values <{ [P in keyof T ]: T [P ] extends Decoder <infer U , infer _ > ? U : never }>
466
466
>;
@@ -498,7 +498,7 @@ See also the [renaming union field example](examples/renaming-union-field.test.t
498
498
499
499
` ` ` ts
500
500
function tuple<T extends Array <unknown >>(
501
- mapping : readonly [... { [P in keyof T ]: Decoder <T [P ]> }]
501
+ mapping : readonly [... { [P in keyof T ]: Decoder <T [P ]> }],
502
502
): Decoder <[... T ]>;
503
503
` ` `
504
504
@@ -524,7 +524,7 @@ function multi<
524
524
T4 = never ,
525
525
T5 = never ,
526
526
T6 = never ,
527
- T7 = never
527
+ T7 = never ,
528
528
>(mapping : {
529
529
undefined? : Decoder <T1 , undefined >;
530
530
null? : Decoder <T2 , null >;
@@ -590,7 +590,7 @@ Example:
590
590
` ` ` ts
591
591
const numberSetDecoder: Decoder <Set <number >> = chain (
592
592
array (number ),
593
- (arr ) => new Set (arr )
593
+ (arr ) => new Set (arr ),
594
594
);
595
595
` ` `
596
596
@@ -658,7 +658,7 @@ class DecoderError extends TypeError {
658
658
constructor (
659
659
params :
660
660
| { message: string ; value: unknown ; key? : Key }
661
- | (DecoderErrorVariant & { key? : Key })
661
+ | (DecoderErrorVariant & { key? : Key }),
662
662
);
663
663
664
664
static MISSING_VALUE: symbol ;
@@ -714,7 +714,7 @@ const decoder: Decoder<Array<[RegExp, number]>> = Decode.chain(
714
714
} catch (error ) {
715
715
throw Decode .DecoderError .at (error , key );
716
716
}
717
- })
717
+ }),
718
718
);
719
719
` ` `
720
720
@@ -752,7 +752,7 @@ function repr(
752
752
maxLength = 100 ,
753
753
recurseMaxLength = 20 ,
754
754
sensitive = false ,
755
- }: ReprOptions = {}
755
+ }: ReprOptions = {},
756
756
): string ;
757
757
` ` `
758
758
@@ -819,7 +819,7 @@ const personDecoder = fields(
819
819
(field ): Person => ({
820
820
name: field (" name" , string ),
821
821
age: field (" age" , optional (number )),
822
- })
822
+ }),
823
823
);
824
824
825
825
// Annotate the generic.
@@ -897,7 +897,7 @@ This decoder would ignore its input and always “succeed” with a given value.
897
897
` ` ` ts
898
898
export function either<T , U >(
899
899
decoder1 : Decoder <T >,
900
- decoder2 : Decoder <U >
900
+ decoder2 : Decoder <U >,
901
901
): Decoder <T | U >;
902
902
` ` `
903
903
0 commit comments