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

Function appendRequiredElement

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

Source from the content-addressed store, hash-verified

113 : never
114
115const appendRequiredElement = (
116 base: mutableInnerOfKind<"sequence">,
117 element: BaseRoot
118): mutableInnerOfKind<"sequence"> => {
119 if (base.defaultables || base.optionals) {
120 return throwParseError(
121 base.variadic ?
122 // e.g. [boolean = true, ...string[], number]
123 postfixAfterOptionalOrDefaultableMessage
124 // e.g. [string?, number]
125 : requiredPostOptionalMessage
126 )
127 }
128 if (base.variadic) {
129 // e.g. [...string[], number]
130 base.postfix = append(base.postfix, element)
131 } else {
132 // e.g. [string, number]
133 base.prefix = append(base.prefix, element)
134 }
135 return base
136}
137
138const appendOptionalElement = (
139 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