MCPcopy
hub / github.com/npmx-dev/npmx.dev / formatType

Function formatType

server/utils/docs/format.ts:72–80  ·  view source on GitHub ↗
(type?: TsType)

Source from the content-addressed store, hash-verified

70 * Format a TypeScript type.
71 */
72export function formatType(type?: TsType): string {
73 if (!type) return ''
74
75 const formatter = TYPE_FORMATTERS[type.kind]
76 const formatted = formatter?.(type)
77
78 if (formatted) return formatted
79 return type.repr ? stripAnsi(type.repr) : 'unknown'
80}
81
82const TYPE_FORMATTERS: Partial<Record<TsType['kind'], (type: TsType) => string>> = {
83 keyword: type => type.keyword || '',

Callers 8

format.spec.tsFile · 0.90
renderClassMembersFunction · 0.90
renderInterfaceMembersFunction · 0.90
getNodeSignatureFunction · 0.85
formatParamFunction · 0.85
format.tsFile · 0.85
formatTypeLiteralTypeFunction · 0.85

Calls 1

stripAnsiFunction · 0.90

Tested by

no test coverage detected