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

Method bindTypeArgs

ark/aot/graph.ts:2538–2587  ·  view source on GitHub ↗
(
		params: readonly TSTypeParameter[] | undefined,
		argNodes: readonly TSType[] | undefined,
		argContext: TypeContext,
		argModule: SourceModule,
		declContext: TypeContext,
		declModule: SourceModule,
		kindOfKey: KindOfKey,
		depth: number,
		callerTypeArgs: TypeArgs | undefined,
		topLevel: boolean,
		state: TypeEvalState
	)

Source from the content-addressed store, hash-verified

2536 }
2537
2538 private bindTypeArgs(
2539 params: readonly TSTypeParameter[] | undefined,
2540 argNodes: readonly TSType[] | undefined,
2541 argContext: TypeContext,
2542 argModule: SourceModule,
2543 declContext: TypeContext,
2544 declModule: SourceModule,
2545 kindOfKey: KindOfKey,
2546 depth: number,
2547 callerTypeArgs: TypeArgs | undefined,
2548 topLevel: boolean,
2549 state: TypeEvalState
2550 ): TypeArgs | undefined {
2551 if (!params?.length) return topLevel ? undefined : callerTypeArgs
2552 let bound: Map<TSTypeParameter, KindBits | undefined> | undefined
2553 const ensureBound = () =>
2554 (bound ??= new Map(topLevel ? undefined : callerTypeArgs))
2555 for (let i = 0; i < params.length; i++) {
2556 const param = params[i]
2557 if (argNodes?.[i]) {
2558 ensureBound().set(
2559 param,
2560 this.typeKindOf(
2561 argNodes[i],
2562 argContext,
2563 argModule,
2564 kindOfKey,
2565 depth,
2566 callerTypeArgs,
2567 state
2568 )
2569 )
2570 } else if (param.default) {
2571 ensureBound().set(
2572 param,
2573 this.typeKindOf(
2574 param.default,
2575 declContext,
2576 declModule,
2577 kindOfKey,
2578 depth,
2579 bound ?? (topLevel ? undefined : callerTypeArgs),
2580 state
2581 )
2582 )
2583 }
2584 if (state.aborted) return
2585 }
2586 return bound ?? (topLevel ? undefined : callerTypeArgs)
2587 }
2588
2589 // what a `typeof` names, with its value where a const or an export
2590 // declares one: a binding, or what a type-only import names, which the

Callers 2

declaredTypeKindOfMethod · 0.95
propTypesOfMethod · 0.95

Calls 2

typeKindOfMethod · 0.95
setMethod · 0.45

Tested by

no test coverage detected