@@ -217,6 +217,7 @@ export class Decoder<A> {
217217 * | constant(true) | Decoder<true> |
218218 * | constant(false) | Decoder<false> |
219219 * | constant(null) | Decoder<null> |
220+ * | constant(undefined) | Decoder<undefined> |
220221 * | constant('alaska') | Decoder<string> |
221222 * | constant<'alaska'>('alaska') | Decoder<'alaska'> |
222223 * | constant(50) | Decoder<number> |
@@ -472,18 +473,18 @@ export class Decoder<A> {
472473 * ```
473474 *
474475 * 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.
477478 * ```
478- * const optionalDecoder = valueAt(['a', 'b', 'c'], optional (string()));
479+ * const decoder = valueAt(['a', 'b', 'c'], union (string(), constant(undefined )));
479480 *
480- * optionalDecoder .run({a: {b: {c: 'surprise!'}}})
481+ * decoder .run({a: {b: {c: 'surprise!'}}})
481482 * // => {ok: true, result: 'surprise!'}
482483 *
483- * optionalDecoder .run({a: {b: 'cats'}})
484+ * decoder .run({a: {b: 'cats'}})
484485 * // => {ok: false, error: {... at: 'input.a.b.c' message: 'expected an object, got "cats"'}
485486 *
486- * optionalDecoder .run({a: {b: {z: 1}}})
487+ * decoder .run({a: {b: {z: 1}}})
487488 * // => {ok: true, result: undefined}
488489 * ```
489490 */
0 commit comments