Skip to content

Commit dbac85e

Browse files
Bugfix: TypeParameter equality does not check for unconstrained types, see #119
1 parent cc757e0 commit dbac85e

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

bin/typedoc.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6851,9 +6851,21 @@ var td;
68516851
* @returns TRUE if the given type equals this type, FALSE otherwise.
68526852
*/
68536853
TypeParameterType.prototype.equals = function (type) {
6854-
return type instanceof TypeParameterType &&
6854+
if (!(type instanceof TypeParameterType)) {
6855+
return false;
6856+
}
6857+
var constraintEquals;
6858+
if (this.constraint && type.constraint) {
6859+
constraintEquals = type.constraint.equals(this.constraint);
6860+
}
6861+
else if (!this.constraint && !type.constraint) {
6862+
constraintEquals = true;
6863+
}
6864+
else {
6865+
return false;
6866+
}
6867+
return constraintEquals &&
68556868
type.isArray == this.isArray &&
6856-
type.constraint.equals(this.constraint) &&
68576869
type.name == this.name;
68586870
};
68596871
/**

src/td/models/types/TypeParameterType.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,21 @@ module td.models
3939
* @returns TRUE if the given type equals this type, FALSE otherwise.
4040
*/
4141
equals(type:TypeParameterType):boolean {
42-
return type instanceof TypeParameterType &&
42+
if (!(type instanceof TypeParameterType)) {
43+
return false;
44+
}
45+
46+
var constraintEquals;
47+
if (this.constraint && type.constraint) {
48+
constraintEquals = type.constraint.equals(this.constraint);
49+
} else if (!this.constraint && !type.constraint) {
50+
constraintEquals = true;
51+
} else {
52+
return false;
53+
}
54+
55+
return constraintEquals &&
4356
type.isArray == this.isArray &&
44-
type.constraint.equals(this.constraint) &&
4557
type.name == this.name;
4658
}
4759

0 commit comments

Comments
 (0)