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

Method definesGeneric

ark/aot/graph.ts:4497–4516  ·  view source on GitHub ↗
(
		call: CallExpression,
		module: SourceModule,
		kindOfKey: KindOfKey
	)

Source from the content-addressed store, hash-verified

4495
4496 // e.g. `scope({ ... })`, `generic("t")({ ... })` or `type("<t>", { ... })`
4497 private definesGeneric(
4498 call: CallExpression,
4499 module: SourceModule,
4500 kindOfKey: KindOfKey
4501 ): boolean {
4502 const callee = unwrapChain(call.callee)
4503 const [params] = call.arguments
4504 if (
4505 call.arguments.length === 2 &&
4506 params.type === "Literal" &&
4507 /^<.*>$/.test(String(params.value))
4508 )
4509 return this.isParser(callee, "type", module, kindOfKey)
4510 if (callee.type !== "CallExpression") return false
4511 const parser = unwrapChain(callee.callee)
4512 return (
4513 this.arkExportNameOf(parser, module) === "generic" ||
4514 this.isParser(parser, "generic", module, kindOfKey)
4515 )
4516 }
4517
4518 private isParser(
4519 node: Node,

Callers 1

calledKindOfMethod · 0.95

Calls 5

isParserMethod · 0.95
arkExportNameOfMethod · 0.95
unwrapChainFunction · 0.90
StringInterface · 0.85
testMethod · 0.80

Tested by

no test coverage detected