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