(type?: TsType)
| 70 | * Format a TypeScript type. |
| 71 | */ |
| 72 | export 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 | |
| 82 | const TYPE_FORMATTERS: Partial<Record<TsType['kind'], (type: TsType) => string>> = { |
| 83 | keyword: type => type.keyword || '', |
no test coverage detected