MCPcopy Create free account
hub / github.com/arktypeio/arktype / constructor

Method constructor

ark/schema/structure/optional.ts:69–85  ·  view source on GitHub ↗
(...args: ConstructorParameters<typeof BaseProp>)

Source from the content-addressed store, hash-verified

67
68export class OptionalNode extends BaseProp<"optional"> {
69 constructor(...args: ConstructorParameters<typeof BaseProp>) {
70 super(...args)
71 if (!$ark.sets && this.$.cfg.exactOptionalPropertyTypes === false)
72 throwParseError(missingSetEngineMessage)
73 if ("default" in this.inner) {
74 // a default of undefined would replace undefined with itself
75 assertDefaultValueAssignability(
76 this.requiredValue,
77 this.inner.default,
78 this.key,
79 this
80 )
81 }
82 // a function default can fail as it's applied, like a morph
83 this.hasMorph ||= typeof this.inner.default === "function"
84 this.ctxMorph ||= this.defMorph?.length === 2
85 }
86
87 override getIo(ioKind: "in" | "out"): BaseNode {
88 if (ioKind === "out" || !this.hasDef()) return super.getIo(ioKind)

Callers

nothing calls this directly

Calls 2

throwParseErrorFunction · 0.90

Tested by

no test coverage detected