Skip to content

Commit 62ac4a1

Browse files
committed
fix(typedoc): Fix base class properties not registered.
1 parent 003c724 commit 62ac4a1

1 file changed

Lines changed: 49 additions & 41 deletions

File tree

  • plugins/typedoc-plugin-react-components/src

plugins/typedoc-plugin-react-components/src/main.ts

Lines changed: 49 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
PredicateType,
1212
ReflectionFlag,
1313
ReflectionKind,
14-
ReflectionSymbolId,
1514
ReflectionType,
1615
Renderer,
1716
SignatureReflection,
@@ -65,46 +64,7 @@ export function load(app: Application) {
6564

6665
if (type.aliasTypeArguments) {
6766
// The 1st element is the ref to the node of the component it pretty much implements or otherwise `elementClass` prop of `createComponent`.
68-
type.aliasTypeArguments[0].symbol?.members?.forEach(
69-
(value: ts.Symbol, key: ts.__String) => {
70-
const memberDeclaration = value?.declarations?.length
71-
? (value.declarations[0] as any)
72-
: null;
73-
const modifiers = ts.getCombinedModifierFlags(memberDeclaration);
74-
if (
75-
!key.toString().startsWith('_') &&
76-
(modifiers === ModifierFlags.None ||
77-
modifiers === ModifierFlags.Public ||
78-
modifiers === ModifierFlags.Static)
79-
) {
80-
let reflectionKind = ReflectionKind.Property;
81-
let category = 'Other';
82-
switch (value.flags) {
83-
case SymbolFlags.GetAccessor:
84-
category = 'Accessors';
85-
reflectionKind = ReflectionKind.Accessor;
86-
break;
87-
case SymbolFlags.Method:
88-
category = 'Methods';
89-
reflectionKind = ReflectionKind.Method;
90-
break;
91-
case SymbolFlags.Accessor:
92-
case SymbolFlags.Property:
93-
category = 'Properties';
94-
}
95-
if (value.flags.toString() === '16777220') {
96-
// For some reason optional properties get flagged to this number, even though the optional is 16777216
97-
category = 'Properties';
98-
}
99-
if (category === 'Other') {
100-
// Other types we just ignore creating.
101-
return;
102-
}
103-
104-
createMemberDeclaration(context, value, reflectionKind, category);
105-
}
106-
},
107-
);
67+
parseTypeProperties(type.aliasTypeArguments[0], context);
10868
// The 2nd element is the `events` prop of the `createComponent` method.
10969
type.aliasTypeArguments[1].symbol?.members?.forEach(
11070
(value: ts.Symbol, key: ts.__String) => {
@@ -192,6 +152,54 @@ export function load(app: Application) {
192152
});
193153
}
194154

155+
function parseTypeProperties(type: any, context: any) {
156+
if (type.symbol?.name === 'LitElement') {
157+
return;
158+
}
159+
type.declaredProperties?.forEach((value: ts.Symbol, key: ts.__String) => {
160+
const memberDeclaration = value?.declarations?.length ? (value.declarations[0] as any) : null;
161+
const modifiers = ts.getCombinedModifierFlags(memberDeclaration);
162+
if (
163+
!key.toString().startsWith('_') &&
164+
(modifiers === ModifierFlags.None ||
165+
modifiers === ModifierFlags.Public ||
166+
modifiers === ModifierFlags.Static)
167+
) {
168+
let reflectionKind = ReflectionKind.Property;
169+
let category = 'Other';
170+
switch (value.flags) {
171+
case SymbolFlags.GetAccessor:
172+
category = 'Accessors';
173+
reflectionKind = ReflectionKind.Accessor;
174+
break;
175+
case SymbolFlags.Method:
176+
category = 'Methods';
177+
reflectionKind = ReflectionKind.Method;
178+
break;
179+
case SymbolFlags.Accessor:
180+
case SymbolFlags.Property:
181+
category = 'Properties';
182+
}
183+
if (value.flags.toString() === '16777220') {
184+
// For some reason optional properties get flagged to this number, even though the optional is 16777216
185+
category = 'Properties';
186+
}
187+
if (category === 'Other') {
188+
// Other types we just ignore creating.
189+
return;
190+
}
191+
192+
createMemberDeclaration(context, value, reflectionKind, category);
193+
}
194+
});
195+
196+
if (type.resolvedBaseTypes) {
197+
for (const baseType of type.resolvedBaseTypes) {
198+
parseTypeProperties(baseType, context);
199+
}
200+
}
201+
}
202+
195203
function clearProps(inObj: any, propName: string) {
196204
if (!inObj || typeof inObj !== 'object') {
197205
return;

0 commit comments

Comments
 (0)