File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ import type { ProjectReflection } from "../reflections";
3
3
import { Reflection } from "../reflections/abstract" ;
4
4
import { Type } from "./abstract" ;
5
5
6
+ const BROKEN_REFERENCE_ID = - 1 ;
7
+
6
8
/**
7
9
* Represents a type that refers to another reflection like a class, interface or enum.
8
10
*
@@ -66,7 +68,7 @@ export class ReferenceType extends Type {
66
68
67
69
/** @internal this is used for type parameters, which don't actually point to something */
68
70
static createBrokenReference ( name : string , project : ProjectReflection ) {
69
- return new ReferenceType ( name , - 1 , project ) ;
71
+ return new ReferenceType ( name , BROKEN_REFERENCE_ID , project ) ;
70
72
}
71
73
72
74
/**
@@ -93,7 +95,14 @@ export class ReferenceType extends Type {
93
95
94
96
let matchesTarget ;
95
97
if ( ! this . reflection ) {
96
- matchesTarget = this . _target === other . _target ;
98
+ if (
99
+ this . _target === BROKEN_REFERENCE_ID &&
100
+ other . _target === BROKEN_REFERENCE_ID
101
+ ) {
102
+ matchesTarget = this . name === other . name ;
103
+ } else {
104
+ matchesTarget = this . _target === other . _target ;
105
+ }
97
106
} else {
98
107
matchesTarget = this . reflection === other . reflection ;
99
108
}
Original file line number Diff line number Diff line change @@ -66,5 +66,11 @@ describe("Reference Type", () => {
66
66
67
67
equal ( type1 . equals ( type2 ) , false ) ;
68
68
} ) ;
69
+
70
+ it ( "intentionally broken reference types with different names are not equal" , ( ) => {
71
+ const type1 = ReferenceType . createBrokenReference ( "Type1" , project ) ;
72
+ const type2 = ReferenceType . createBrokenReference ( "Type2" , project ) ;
73
+ equal ( type1 . equals ( type2 ) , false ) ;
74
+ } ) ;
69
75
} ) ;
70
76
} ) ;
You can’t perform that action at this time.
0 commit comments