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

Function parameterOf

ark/aot/diagnostics.ts:63–76  ·  view source on GitHub ↗
(
	node: Node,
	module: SourceModule
)

Source from the content-addressed store, hash-verified

61
62// e.g. `T` in `<t>(T: Type<t>) => T.or("null")`, with the function's name
63export const parameterOf = (
64 node: Node,
65 module: SourceModule
66): { binding: Binding; fn: string; isAnnotated: boolean } | undefined => {
67 const id = unwrapChain(node)
68 const binding =
69 id.type === "Identifier" ? module.scopes.byId.get(id)?.binding : undefined
70 if (binding?.kind !== "param") return
71 return {
72 binding,
73 fn: inferredNameOf(binding.declaration as FunctionNode),
74 isAnnotated: !!(binding.id as { typeAnnotation?: unknown }).typeAnnotation
75 }
76}
77
78// e.g. "BeforeNavigate" for `nav: BeforeNavigate`
79export const annotationSnippetOf = (

Callers 2

opaqueHintOfMethod · 0.90

Calls 3

unwrapChainFunction · 0.90
inferredNameOfFunction · 0.90
getMethod · 0.65

Tested by

no test coverage detected