compodoc icon indicating copy to clipboard operation
compodoc copied to clipboard

[BUG] Compodoc does not resolve generic indexed types like UnwrapInputSignal<BadgeComponent['color']>

Open imike57 opened this issue 8 months ago • 0 comments

Compodoc fails to resolve a basic generic + indexed type expression, even when the types are simple and fully accessible. Instead, it outputs an incomplete or incorrect type.

// badge.component.ts
import { input } from '@angular/core';

export class BadgeComponent {
  color = input<string>('primary');
}
// types.ts
export type UnwrapInputSignal<T> = T extends InputSignal<infer V> ? V : T;
// menu-item.ts
import { BadgeComponent } from './badge.component';
import { UnwrapInputSignal } from './types';

export interface MenuItem {
  /**
   * Badge color
   */
  color?: UnwrapInputSignal<BadgeComponent['color']>;
}

Actual output from Compodoc

{
  "name": "color",
  "type": "UnwrapInputSignal<>",
  "optional": true,
  "description": "Badge color"
}

Expected output At minimum: "type": "UnwrapInputSignal<InputSignal<string>>"

But idealy we should be able to deconstruct the type...

Here UnwrapInputSignal is a simple conditional helper:

export type UnwrapInputSignal<T> = T extends InputSignal<infer V> ? V : T;

Suggested improvement Compodoc could improve type resolution by:

  • Following indexed access types (BadgeComponent['color'])
  • Expanding generic types using the TypeScript Compiler API
  • Falling back to a more informative string representation if full resolution isn't possible

Compodoc version : 1.1.26

imike57 avatar Jun 11 '25 14:06 imike57