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

Method typeKindOf

ark/aot/graph.ts:2090–2248  ·  view source on GitHub ↗
(
		type: TSType | TSTypeAnnotation,
		context: TypeContext,
		module: SourceModule,
		kindOfKey: KindOfKey,
		depth = 0,
		typeArgs?: TypeArgs,
		state: TypeEvalState = newTypeEvalState()
	)

Source from the content-addressed store, hash-verified

2088 }
2089
2090 private typeKindOf(
2091 type: TSType | TSTypeAnnotation,
2092 context: TypeContext,
2093 module: SourceModule,
2094 kindOfKey: KindOfKey,
2095 depth = 0,
2096 typeArgs?: TypeArgs,
2097 state: TypeEvalState = newTypeEvalState()
2098 ): KindBits | undefined {
2099 if (state.aborted || ++state.steps > maxTypeSteps) {
2100 state.aborted = true
2101 return
2102 }
2103 const union = (
2104 types: (TSType | TSTypeAnnotation | null)[],
2105 depth: number
2106 ) =>
2107 this.unionKindOf(
2108 types,
2109 context,
2110 module,
2111 kindOfKey,
2112 depth,
2113 typeArgs,
2114 state
2115 )
2116 switch (type.type) {
2117 case "TSTypeAnnotation":
2118 case "TSParenthesizedType":
2119 return this.typeKindOf(
2120 type.typeAnnotation,
2121 context,
2122 module,
2123 kindOfKey,
2124 depth,
2125 typeArgs,
2126 state
2127 )
2128 case "TSAnyKeyword":
2129 return
2130 // says nothing at the top level, but data where nested
2131 case "TSUnknownKeyword":
2132 case "TSObjectKeyword":
2133 return depth < 2 ? undefined : kinds.data
2134 case "TSUnionType":
2135 return union(type.types, depth)
2136 case "TSConditionalType":
2137 return hasInferType(type.extendsType) ? undefined : (
2138 union([type.trueType, type.falseType], depth)
2139 )
2140 case "TSIntersectionType":
2141 return this.intersectionKindOf(
2142 type,
2143 context,
2144 module,
2145 kindOfKey,
2146 depth,
2147 typeArgs,

Callers 9

annotatedKindOfMethod · 0.95
unionKindOfMethod · 0.95
intersectionKindOfMethod · 0.95
namedTypeKindOfMethod · 0.95
bindTypeArgsMethod · 0.95
signaturesKindOfMethod · 0.95
declaredTypeKindOfMethod · 0.95
returnKindInMethod · 0.95

Calls 11

intersectionKindOfMethod · 0.95
signaturesKindOfMethod · 0.95
queryKindOfMethod · 0.95
referenceKindOfMethod · 0.95
newTypeEvalStateFunction · 0.85
hasInferTypeFunction · 0.85
memberKindOfFunction · 0.85
functionKindOfFunction · 0.85
isArkFunction · 0.70
mapMethod · 0.65
unionFunction · 0.50

Tested by

no test coverage detected