mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Make comparable relationship bidirectional for primitive types
This commit is contained in:
1 parent
9d56f7b7c1
commit
7d5f5fd555
1 file changed
+5
-2
@@ -8907,7 +8907,9 @@ namespace ts {
|
||||
if (target.flags & TypeFlags.StringOrNumberLiteral && target.flags & TypeFlags.FreshLiteral) {
|
||||
target = (<LiteralType>target).regularType;
|
||||
}
|
||||
if (source === target || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) {
|
||||
if (source === target ||
|
||||
relation === comparableRelation && !(target.flags & TypeFlags.Never) && isSimpleTypeRelatedTo(target, source, relation) ||
|
||||
relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) {
|
||||
return true;
|
||||
}
|
||||
if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) {
|
||||
@@ -9050,7 +9052,8 @@ namespace ts {
|
||||
return isIdenticalTo(source, target);
|
||||
}
|
||||
|
||||
if (isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return Ternary.True;
|
||||
if (relation === comparableRelation && !(target.flags & TypeFlags.Never) && isSimpleTypeRelatedTo(target, source, relation) ||
|
||||
isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return Ternary.True;
|
||||
|
||||
if (isObjectLiteralType(source) && source.flags & TypeFlags.FreshLiteral) {
|
||||
if (hasExcessProperties(<FreshObjectLiteralType>source, target, reportErrors)) {
|
||||
|
||||
Reference in new issue
Block a user