Hyperlinkv0.8.0-beta.28

SchemaAST

SchemaAST.optionalKeyfunctioneffect/SchemaAST.ts:3240
<A extends AST>(ast: A): A

Marks an AST node's property key as optional by setting Context.isOptional to true.

Details

Also propagates the optional flag through the last link of the encoding chain if present.

transformingContext.isOptionalisOptionalContext
export function optionalKey<A extends AST>(ast: A): A {
  const context = ast.context ?
    ast.context.isOptional === false ?
      new Context(true, ast.context.isMutable, ast.context.defaultValue, ast.context.annotations) :
      ast.context :
    new Context(true, false)
  return optionalKeyLastLink(replaceContext(ast, context))
}
Referenced by 1 symbols