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

Function appendOptionalElement

ark/type/parser/tupleLiteral.ts:138–148  ·  view source on GitHub ↗
(
	base: mutableInnerOfKind<"sequence">,
	element: BaseRoot
)

Source from the content-addressed store, hash-verified

136}
137
138const appendOptionalElement = (
139 base: mutableInnerOfKind<"sequence">,
140 element: BaseRoot
141): mutableInnerOfKind<"sequence"> => {
142 if (base.variadic)
143 // e.g. [...string[], number?]
144 return throwParseError(optionalOrDefaultableAfterVariadicMessage)
145 // e.g. [string, number?]
146 base.optionals = append(base.optionals, element)
147 return base
148}
149
150const appendDefaultableElement = (
151 base: mutableInnerOfKind<"sequence">,

Callers 2

parseTupleLiteralFunction · 0.85
appendSpreadBranchFunction · 0.85

Calls 2

throwParseErrorFunction · 0.90
appendFunction · 0.90

Tested by

no test coverage detected