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

Method declaredTypeKindOf

ark/aot/graph.ts:2741–2860  ·  view source on GitHub ↗
(
		declaration: LocalType,
		context: TypeContext,
		module: SourceModule,
		kindOfKey: KindOfKey,
		depth: number,
		argNodes: readonly TSType[] | undefined,
		argModule: SourceModule | undefined,
		callerTypeArgs: TypeArgs | undefined,
		state: TypeEvalState
	)

Source from the content-addressed store, hash-verified

2739 }
2740
2741 private declaredTypeKindOf(
2742 declaration: LocalType,
2743 context: TypeContext,
2744 module: SourceModule,
2745 kindOfKey: KindOfKey,
2746 depth: number,
2747 argNodes: readonly TSType[] | undefined,
2748 argModule: SourceModule | undefined,
2749 callerTypeArgs: TypeArgs | undefined,
2750 state: TypeEvalState
2751 ): KindBits | undefined {
2752 if (this.resolving.has(declaration)) {
2753 const activeDepth = state.active.get(declaration)
2754 state.minCycle = Math.min(
2755 state.minCycle,
2756 activeDepth === undefined ? -1 : activeDepth
2757 )
2758 return kinds.data
2759 }
2760 if (state.recursion >= maxTypeRecursion) {
2761 state.aborted = true
2762 return
2763 }
2764 state.recursion++
2765 const topLevel = isTopLevelType(declaration)
2766 try {
2767 const params = declaration.typeParameters?.params
2768 const boundArgs = this.bindTypeArgs(
2769 params,
2770 argNodes,
2771 context,
2772 argModule ?? module,
2773 declaration,
2774 module,
2775 kindOfKey,
2776 depth,
2777 callerTypeArgs,
2778 topLevel,
2779 state
2780 )
2781 if (state.aborted) return
2782 let cacheKey: string | undefined
2783 let byKey: Map<string, KindBits | undefined> | undefined
2784 if (topLevel) {
2785 cacheKey = typeCacheKeyOf(depth, params, boundArgs)
2786 byKey = this.declaredTypeKinds.get(declaration)
2787 if (byKey?.has(cacheKey)) return byKey.get(cacheKey)
2788 }
2789 const myDepth = state.active.size
2790 const outerMinCycle = state.minCycle
2791 const outerQueried = state.queried
2792 state.minCycle = Infinity
2793 state.queried = false
2794 this.resolving.add(declaration)
2795 state.active.set(declaration, myDepth)
2796 let result: KindBits | undefined
2797 try {
2798 if (declaration.type === "TSInterfaceDeclaration") {

Callers 2

namedTypeKindOfMethod · 0.95
exportedTypeKindOfMethod · 0.95

Calls 11

bindTypeArgsMethod · 0.95
signaturesKindOfMethod · 0.95
heritageKindOfMethod · 0.95
typeKindOfMethod · 0.95
isTopLevelTypeFunction · 0.85
typeCacheKeyOfFunction · 0.85
getMethod · 0.65
hasMethod · 0.45
addMethod · 0.45
setMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected