Skip to content

findType

Resolve a bare type name to a documented TypeInfo.

The model map is keyed by a qualified ${namespace}#${name} identity, because a package can export the same simple name from different modules. Resolution is best-effort: 1. Prefer a type in currentNamespace (the referencing page’s module). 2. Otherwise, if exactly one type across all modules has that bare name, use it. 3. If the bare name is ambiguous (multiple modules), give up (caller renders plain code).

Import:

import { findType } from '@mnaoumov/typescript-dev-toolkit/docs-site/api-doc-link-rendering';

Signature:

function findType(allTypes: Map<string, TypeInfo>, name: string, currentNamespace: string | undefined): TypeInfo | undefined

Parameters:

Parameter Type Description
allTypes Map<string, TypeInfo> Every documented type, keyed by $\{namespace\}#$\{name\}.
name string The type’s name.
currentNamespace string | undefined The namespace of the referencing page, preferred when the name is ambiguous.

Returns: TypeInfo | undefined — The type, or undefined when no type or more than one has that name.