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

Method namedTypeKindOf

ark/aot/graph.ts:2382–2494  ·  view source on GitHub ↗
(
		rootName: string,
		qualified: string | undefined | null,
		argNodes: readonly TSType[] | undefined,
		context: TypeContext,
		module: SourceModule,
		kindOfKey: KindOfKey,
		depth: number,
		typeArgs: TypeArgs | undefined,
		state: TypeEvalState
	)

Source from the content-addressed store, hash-verified

2380
2381 // qualified: undefined for bare `Foo`, string for `NS.Foo`, null for deeper
2382 private namedTypeKindOf(
2383 rootName: string,
2384 qualified: string | undefined | null,
2385 argNodes: readonly TSType[] | undefined,
2386 context: TypeContext,
2387 module: SourceModule,
2388 kindOfKey: KindOfKey,
2389 depth: number,
2390 typeArgs: TypeArgs | undefined,
2391 state: TypeEvalState
2392 ): KindBits | undefined {
2393 // e.g. `T` in `<T extends Type>(t: T) => ...`
2394 if (qualified === undefined) {
2395 const parameter = typeParameterOf(context, rootName)
2396 if (parameter) {
2397 if (typeArgs?.has(parameter)) return typeArgs.get(parameter)
2398 return parameter.constraint ?
2399 this.typeKindOf(
2400 parameter.constraint,
2401 context,
2402 module,
2403 kindOfKey,
2404 depth,
2405 typeArgs,
2406 state
2407 )
2408 : undefined
2409 }
2410 }
2411 const imported = importedNameOf(module, rootName)
2412 if (imported) {
2413 const [specifier, importedName] = imported
2414 if (localSpecifier.test(specifier)) {
2415 // e.g. `T.Options` for `import type * as T from "./types.ts"`
2416 const exportName =
2417 qualified === undefined ? importedName
2418 : typeof qualified === "string" && importedName === "*" ? qualified
2419 : undefined
2420 return exportName === undefined ? undefined : (
2421 this.exportedTypeKindOf(
2422 specifier,
2423 exportName,
2424 context,
2425 module,
2426 kindOfKey,
2427 depth,
2428 argNodes,
2429 module,
2430 typeArgs,
2431 state
2432 )
2433 )
2434 }
2435 const isArkTypeName =
2436 qualified !== undefined ?
2437 typeof qualified === "string" &&
2438 (importedName === "*" ?
2439 qualified in arkTypeNames

Callers 2

referenceKindOfMethod · 0.95
heritageKindOfMethod · 0.95

Calls 11

typeKindOfMethod · 0.95
exportedTypeKindOfMethod · 0.95
localTypeOfMethod · 0.95
declaredTypeKindOfMethod · 0.95
unionKindOfMethod · 0.95
typeParameterOfFunction · 0.85
arkTypeKindOfFunction · 0.85
testMethod · 0.80
importedNameOfFunction · 0.70
getMethod · 0.65
hasMethod · 0.45

Tested by

no test coverage detected