@@ -6,7 +6,7 @@ import type { SignatureReflection } from "./signature";
66import type { ParameterReflection } from "./parameter" ;
77import { IntrinsicType } from "../types" ;
88import type { TypeParameterReflection } from "./type-parameter" ;
9- import { removeIfPresent } from "../../utils" ;
9+ import { removeIf , removeIfPresent } from "../../utils" ;
1010import type * as ts from "typescript" ;
1111import { ReflectionKind } from "./kind" ;
1212import { Comment , CommentDisplayPart } from "../comments" ;
@@ -103,7 +103,37 @@ export class ProjectReflection extends ContainerReflection {
103103
104104 if ( symbol ) {
105105 this . reflectionIdToSymbolMap . set ( reflection . id , symbol ) ;
106- this . registerSymbolId ( reflection , new ReflectionSymbolId ( symbol ) ) ;
106+ const id = new ReflectionSymbolId ( symbol ) ;
107+ this . registerSymbolId ( reflection , id ) ;
108+
109+ // #2466
110+ // If we just registered a member of a class or interface, then we need to check if
111+ // we've registered this symbol before under the wrong parent reflection.
112+ // This can happen because the compiler API will use non-dependently-typed symbols
113+ // for properties of classes/interfaces which inherit them, so we can't rely on the
114+ // property being unique for each class.
115+ if (
116+ reflection . parent ?. kindOf ( ReflectionKind . ClassOrInterface ) &&
117+ reflection . kindOf ( ReflectionKind . SomeMember )
118+ ) {
119+ const saved = this . symbolToReflectionIdMap . get ( id ) ;
120+ const parentSymbolReflection =
121+ symbol . parent &&
122+ this . getReflectionFromSymbol ( symbol . parent ) ;
123+
124+ if (
125+ typeof saved === "object" &&
126+ saved . length > 1 &&
127+ parentSymbolReflection
128+ ) {
129+ removeIf (
130+ saved ,
131+ ( item ) =>
132+ this . getReflectionById ( item ) ?. parent !==
133+ parentSymbolReflection ,
134+ ) ;
135+ }
136+ }
107137 }
108138 }
109139
0 commit comments