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

Method intersectionKindOf

ark/aot/graph.ts:2278–2311  ·  view source on GitHub ↗
(
		type: TSIntersectionType,
		context: TypeContext,
		module: SourceModule,
		kindOfKey: KindOfKey,
		depth: number,
		typeArgs: TypeArgs | undefined,
		state: TypeEvalState
	)

Source from the content-addressed store, hash-verified

2276
2277 // e.g. `typeof def & { in: unknown }`, a Type only if some part says so
2278 private intersectionKindOf(
2279 type: TSIntersectionType,
2280 context: TypeContext,
2281 module: SourceModule,
2282 kindOfKey: KindOfKey,
2283 depth: number,
2284 typeArgs: TypeArgs | undefined,
2285 state: TypeEvalState
2286 ): KindBits | undefined {
2287 const parts: (KindBits | undefined)[] = []
2288 for (const t of type.types) {
2289 parts.push(
2290 this.typeKindOf(t, context, module, kindOfKey, depth, typeArgs, state)
2291 )
2292 if (state.aborted) return
2293 }
2294 const declared = parts.filter(
2295 kind =>
2296 kind !== undefined && !(kind & (kinds.unknown | kinds.opaque | arkBits))
2297 )
2298 if (
2299 declared.length &&
2300 parts.every(
2301 kind => kind === undefined || !(kind & (kinds.unknown | arkBits))
2302 )
2303 )
2304 return declared.reduce<KindBits>((result, kind) => result | kind!, 0)
2305 let result: KindBits = kinds.data
2306 for (const kind of parts) {
2307 if (kind === undefined) return
2308 result |= kind
2309 }
2310 return result
2311 }
2312
2313 // e.g. `typeof names`, or `typeof User.infer`, data whatever `User` is
2314 private queryKindOf(

Callers 1

typeKindOfMethod · 0.95

Calls 4

typeKindOfMethod · 0.95
filterMethod · 0.80
reduceMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected