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