MCPcopy
hub / github.com/arktypeio/arktype / preparseOwnAliasEntry

Method preparseOwnAliasEntry

ark/type/scope.ts:214–253  ·  view source on GitHub ↗
(alias: string, def: unknown)

Source from the content-addressed store, hash-verified

212 }
213
214 protected preparseOwnAliasEntry(alias: string, def: unknown): AliasDefEntry {
215 const firstParamIndex = alias.indexOf("<")
216 if (firstParamIndex === -1) {
217 if (hasArkKind(def, "module") || hasArkKind(def, "generic"))
218 return [alias, def]
219
220 const qualifiedName =
221 this.name === "ark" ? alias
222 : alias === "root" ? this.name
223 : `${this.name}.${alias}`
224
225 const config = this.resolvedConfig.keywords?.[qualifiedName]
226
227 if (config) def = [def, "@", config] satisfies TupleExpression
228
229 return [alias, def]
230 }
231
232 if (alias[alias.length - 1] !== ">") {
233 throwParseError(
234 `'>' must be the last character of a generic declaration in a scope`
235 )
236 }
237
238 const name = alias.slice(0, firstParamIndex)
239 const paramString = alias.slice(firstParamIndex + 1, -1)
240
241 return [
242 name,
243 // use a thunk definition for the generic so that we can parse
244 // constraints within the current scope
245 () => {
246 const params = this.parseGenericParams(paramString, { alias: name })
247
248 const generic = parseGeneric(params, def, this as never)
249
250 return generic
251 }
252 ]
253 }
254
255 parseGenericParams(
256 def: string,

Callers

nothing calls this directly

Calls 4

parseGenericParamsMethod · 0.95
hasArkKindFunction · 0.90
throwParseErrorFunction · 0.90
parseGenericFunction · 0.90

Tested by

no test coverage detected