From 19f31abc1cea7017e90933d8679f42c83672c88b Mon Sep 17 00:00:00 2001 From: skrustev Date: Thu, 21 May 2026 10:56:39 +0300 Subject: [PATCH 1/2] feat(typedoc): Add base type extracting and original Igc name for lookup. --- .../src/main.ts | 67 ++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/plugins/typedoc-plugin-react-components/src/main.ts b/plugins/typedoc-plugin-react-components/src/main.ts index 555cf8f..4338185 100644 --- a/plugins/typedoc-plugin-react-components/src/main.ts +++ b/plugins/typedoc-plugin-react-components/src/main.ts @@ -6,9 +6,11 @@ import { type Context, Converter, DeclarationReflection, + IntersectionType, IntrinsicType, ParameterReflection, PredicateType, + ReferenceType, ReflectionFlag, ReflectionKind, ReflectionType, @@ -37,6 +39,18 @@ export function load(app: Application) { context.project.removeReflection(reflection); } + if ( + reflection.name?.startsWith('Igr') && + reflection.escapedName && + reflection.name !== reflection.escapedName + ) { + reflection.implementationOf = ReferenceType.createResolvedReference( + reflection.escapedName, + reflection, + context.project, + ); + } + // This renders the Alias for `PopoverPlacement` a bit better but still no like. Possibly add handling for aliases? // if (reflection.name === "PopoverPlacement") { // reflection.kind = ReflectionKind.TypeParameter; @@ -75,6 +89,16 @@ export function load(app: Application) { ); // The 3rd element is for the `renderProps` prop of the `createComponent` method, but this is only declaration of them. // Definition of them should be handled in the 1st part. + + // Fill out "extendedTypes" section in TypeDoc with base types + extractBaseType(type.aliasTypeArguments[0], context, reflection); + + // Save a reference to the wc component name for reference in case of deeper WC types being resolved. + reflection.implementationOf = ReferenceType.createResolvedReference( + type.aliasTypeArguments[0].symbol.name, + reflection, + context.project, + ); } // Clear out component signature parameters, since they are only internal and we should already have processed them correctly. @@ -154,7 +178,7 @@ export function load(app: Application) { }); } -function parseTypeProperties(type: any, context: any) { +function parseTypeProperties(type: any, context: Context) { if (excludeBaseTypes.includes(type.symbol?.name)) { return; } @@ -330,6 +354,47 @@ function createEventDeclaration(context: Context, value: ts.Symbol) { return reflection; } +function extractBaseType(type: any, context: Context, reflection: SignatureReflection) { + if (!type.baseTypesResolved) { + return; + } + assert(context.scope instanceof DeclarationReflection); + // Expected only 1 item so far? + const resolvedBaseTypeString = context.checker.typeToString(type.resolvedBaseTypes[0]); + const intersectTypes = resolvedBaseTypeString.split('&').map((t) => t.trim()); + if (intersectTypes.length > 1) { + for (const [index, typeName] of intersectTypes.entries()) { + if (typeName.includes('EventEmitterInterface') || excludeBaseTypes.includes(typeName)) { + continue; + } + + const baseType = type.resolvedBaseTypes[0].types[index]; + const refType = ReferenceType.createResolvedReference( + baseType.symbol.name, + reflection, + context.project, + ); + if (context.scope.extendedTypes && context.scope.extendedTypes[0].type === 'intersection') { + (context.scope.extendedTypes[0] as IntersectionType).types.push(refType); + } else if (context.scope.extendedTypes) { + context.scope.extendedTypes = [new IntersectionType(context.scope.extendedTypes)]; + } else { + context.scope.extendedTypes = [refType]; + } + } + } else if (!excludeBaseTypes.includes(resolvedBaseTypeString)) { + const baseType = type.resolvedBaseTypes[0]; + const refType = ReferenceType.createResolvedReference( + baseType.symbol.name, + reflection, + context.project, + ); + context.scope.extendedTypes = context.scope.extendedTypes + ? [...context.scope.extendedTypes, refType] + : [refType]; + } +} + //#region Taken from typedoc source for creating a generic signature of a Symbol. function removeUndefined(type: SomeType): SomeType { if (type instanceof UnionType) { From e4803ddf4deefcdbdbff57b83113b5610ac015b7 Mon Sep 17 00:00:00 2001 From: Svetoslav Krastev Date: Thu, 21 May 2026 17:26:48 +0300 Subject: [PATCH 2/2] fix(typedoc): Include refType when there's already present extended type. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- plugins/typedoc-plugin-react-components/src/main.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/typedoc-plugin-react-components/src/main.ts b/plugins/typedoc-plugin-react-components/src/main.ts index 4338185..a085f39 100644 --- a/plugins/typedoc-plugin-react-components/src/main.ts +++ b/plugins/typedoc-plugin-react-components/src/main.ts @@ -377,7 +377,9 @@ function extractBaseType(type: any, context: Context, reflection: SignatureRefle if (context.scope.extendedTypes && context.scope.extendedTypes[0].type === 'intersection') { (context.scope.extendedTypes[0] as IntersectionType).types.push(refType); } else if (context.scope.extendedTypes) { - context.scope.extendedTypes = [new IntersectionType(context.scope.extendedTypes)]; + const intersectionType = new IntersectionType(context.scope.extendedTypes); + intersectionType.types.push(refType); + context.scope.extendedTypes = [intersectionType]; } else { context.scope.extendedTypes = [refType]; }