@@ -217,6 +217,7 @@ export class Decoder<A> {
217
217
* | constant(true) | Decoder<true> |
218
218
* | constant(false) | Decoder<false> |
219
219
* | constant(null) | Decoder<null> |
220
+ * | constant(undefined) | Decoder<undefined> |
220
221
* | constant('alaska') | Decoder<string> |
221
222
* | constant<'alaska'>('alaska') | Decoder<'alaska'> |
222
223
* | constant(50) | Decoder<number> |
@@ -472,18 +473,18 @@ export class Decoder<A> {
472
473
* ```
473
474
*
474
475
* Note that the `decoder` is ran on the value found at the last key in the
475
- * path, even if the last key is not found. This allows the `optional`
476
- * decoder to succeed when appropriate.
476
+ * path, even if the last key is not found. This allows the value to be
477
+ * `undefined` when appropriate.
477
478
* ```
478
- * const optionalDecoder = valueAt(['a', 'b', 'c'], optional (string()));
479
+ * const decoder = valueAt(['a', 'b', 'c'], union (string(), constant(undefined )));
479
480
*
480
- * optionalDecoder .run({a: {b: {c: 'surprise!'}}})
481
+ * decoder .run({a: {b: {c: 'surprise!'}}})
481
482
* // => {ok: true, result: 'surprise!'}
482
483
*
483
- * optionalDecoder .run({a: {b: 'cats'}})
484
+ * decoder .run({a: {b: 'cats'}})
484
485
* // => {ok: false, error: {... at: 'input.a.b.c' message: 'expected an object, got "cats"'}
485
486
*
486
- * optionalDecoder .run({a: {b: {z: 1}}})
487
+ * decoder .run({a: {b: {z: 1}}})
487
488
* // => {ok: true, result: undefined}
488
489
* ```
489
490
*/
0 commit comments