@@ -13,7 +13,7 @@ import { ReferenceType, ReflectionType, type SomeType, type Type } from "../../m
13
13
import { filterMap , type TranslatedString , zip } from "#utils" ;
14
14
import { ConverterComponent } from "../components.js" ;
15
15
import type { Context } from "../context.js" ;
16
- import { getHumanName } from "../../utils/index.js" ;
16
+ import { findPackageForPath , getHumanName } from "../../utils/index.js" ;
17
17
import { ConverterEvents } from "../converter-events.js" ;
18
18
import type { Converter } from "../converter.js" ;
19
19
@@ -182,18 +182,34 @@ export class ImplementsPlugin extends ConverterComponent {
182
182
183
183
for ( const child of reflection . children || [ ] ) {
184
184
if ( child . inheritedFrom && ! isValidRef ( child . inheritedFrom ) ) {
185
- child . inheritedFrom = ReferenceType . createBrokenReference ( child . inheritedFrom . name , project ) ;
185
+ child . inheritedFrom = ReferenceType . createBrokenReference (
186
+ child . inheritedFrom . name ,
187
+ project ,
188
+ child . inheritedFrom . package ,
189
+ ) ;
186
190
}
187
191
if ( child . overwrites && ! isValidRef ( child . overwrites ) ) {
188
- child . overwrites = ReferenceType . createBrokenReference ( child . overwrites . name , project ) ;
192
+ child . overwrites = ReferenceType . createBrokenReference (
193
+ child . overwrites . name ,
194
+ project ,
195
+ child . overwrites . package ,
196
+ ) ;
189
197
}
190
198
191
199
for ( const childSig of child . getAllSignatures ( ) ) {
192
200
if ( childSig . inheritedFrom && ! isValidRef ( childSig . inheritedFrom ) ) {
193
- childSig . inheritedFrom = ReferenceType . createBrokenReference ( childSig . inheritedFrom . name , project ) ;
201
+ childSig . inheritedFrom = ReferenceType . createBrokenReference (
202
+ childSig . inheritedFrom . name ,
203
+ project ,
204
+ childSig . inheritedFrom . package ,
205
+ ) ;
194
206
}
195
207
if ( childSig . overwrites && ! isValidRef ( childSig . overwrites ) ) {
196
- childSig . overwrites = ReferenceType . createBrokenReference ( childSig . overwrites . name , project ) ;
208
+ childSig . overwrites = ReferenceType . createBrokenReference (
209
+ childSig . overwrites . name ,
210
+ project ,
211
+ childSig . overwrites . package ,
212
+ ) ;
197
213
}
198
214
}
199
215
}
@@ -522,6 +538,18 @@ export class ImplementsPlugin extends ConverterComponent {
522
538
}
523
539
}
524
540
541
+ function getConstructorPackagePath ( context : Context , clause : ts . ExpressionWithTypeArguments ) : string | undefined {
542
+ const symbol = context . getSymbolAtLocation ( clause . expression ) ;
543
+ if ( ! symbol ) return undefined ;
544
+
545
+ const resolvedSymbol = context . resolveAliasedSymbol ( symbol ) ;
546
+
547
+ const symbolPath = resolvedSymbol ?. declarations ?. [ 0 ] ?. getSourceFile ( ) . fileName ;
548
+ if ( ! symbolPath ) return undefined ;
549
+
550
+ return findPackageForPath ( symbolPath ) ?. [ 0 ] ;
551
+ }
552
+
525
553
function constructorInheritance (
526
554
context : Context ,
527
555
reflection : DeclarationReflection ,
@@ -533,17 +561,21 @@ function constructorInheritance(
533
561
) ;
534
562
535
563
if ( ! extendsClause ) return ;
536
- const name = `${ extendsClause . types [ 0 ] . getText ( ) } .constructor` ;
564
+ const extendsType = extendsClause . types [ 0 ] ;
565
+ const refPackage = getConstructorPackagePath ( context , extendsType ) ;
566
+
567
+ const name = `${ extendsType . getText ( ) } .constructor` ;
537
568
538
569
const key = constructorDecl ? "overwrites" : "inheritedFrom" ;
539
570
540
571
reflection [ key ] ??= ReferenceType . createBrokenReference (
541
572
name ,
542
573
context . project ,
574
+ refPackage ,
543
575
) ;
544
576
545
577
for ( const sig of reflection . signatures ?? [ ] ) {
546
- sig [ key ] ??= ReferenceType . createBrokenReference ( name , context . project ) ;
578
+ sig [ key ] ??= ReferenceType . createBrokenReference ( name , context . project , refPackage ) ;
547
579
}
548
580
}
549
581
@@ -576,7 +608,7 @@ function createLink(
576
608
const rootSymbols = context . checker . getRootSymbols ( symbol ) ;
577
609
const ref = rootSymbols . length && rootSymbols [ 0 ] != symbol
578
610
? context . createSymbolReference ( rootSymbols [ 0 ] , context , name )
579
- : ReferenceType . createBrokenReference ( name , context . project ) ;
611
+ : ReferenceType . createBrokenReference ( name , context . project , undefined ) ;
580
612
581
613
link ( reflection ) ;
582
614
link ( reflection . getSignature ) ;
0 commit comments