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

Method paramKindOf

ark/aot/graph.ts:1921–1969  ·  view source on GitHub ↗
(
		binding: Binding,
		module: SourceModule,
		kindOfKey: KindOfKey
	)

Source from the content-addressed store, hash-verified

1919
1920 // e.g. `A | B` for `t` given `f(A)` and `f(B)`, or any if `f` escapes
1921 private paramKindOf(
1922 binding: Binding,
1923 module: SourceModule,
1924 kindOfKey: KindOfKey
1925 ): KindBits {
1926 const fn = binding.declaration as FunctionNode
1927 const params = runtimeParamsOf(fn)
1928 const index = params.findIndex(param => contains(param, binding.id))
1929 const calls = this.callsOf(fn, module)
1930 if (index === -1) return kinds.data
1931 const param = params[index]
1932 // e.g. `ts` in `(...ts) => ts[0].or("null")`, holding what it's passed
1933 if (param.type === "RestElement") {
1934 let held = calls ? 0 : this.passedKindOf(fn, module, kindOfKey)
1935 for (const call of calls ?? [])
1936 held |= this.argsKindOf(call.arguments.slice(index), module, kindOfKey)
1937 return this.patternKindOf(
1938 binding.id,
1939 param.argument,
1940 holderOf(held),
1941 module,
1942 kindOfKey
1943 )
1944 }
1945 const annotated =
1946 this.annotatedKindOf(
1947 param.type === "AssignmentPattern" ? param.left : param,
1948 module,
1949 kindOfKey
1950 ) ??
1951 this.declaredParamKindOf(fn, index, module, kindOfKey) ??
1952 this.jsxCallbackParamKindOf(fn, index, module, kindOfKey)
1953 let result = 0
1954 for (const call of calls ?? [undefined]) {
1955 result |= this.patternKindOf(
1956 binding.id,
1957 param,
1958 annotate(
1959 call ?
1960 this.argKindOf(call, params, index, module, kindOfKey)
1961 : this.passedKindOf(fn, module, kindOfKey),
1962 annotated
1963 ),
1964 module,
1965 kindOfKey
1966 )
1967 }
1968 return result
1969 }
1970
1971 // e.g. what `[A]` holds for `t` given `f(...[A])`, or an array of it for `...ts`
1972 private argKindOf(

Callers 1

keyKindOfMethod · 0.95

Calls 12

callsOfMethod · 0.95
passedKindOfMethod · 0.95
argsKindOfMethod · 0.95
patternKindOfMethod · 0.95
annotatedKindOfMethod · 0.95
declaredParamKindOfMethod · 0.95
argKindOfMethod · 0.95
runtimeParamsOfFunction · 0.90
containsFunction · 0.70
holderOfFunction · 0.70
annotateFunction · 0.70

Tested by

no test coverage detected