@@ -28241,10 +28241,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
28241
28241
checkDerived ?
28242
28242
t => isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType :
28243
28243
t => {
28244
- // isTypeStrictSubtypeOf(t, c) ? t : isTypeStrictSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : isTypeSubtypeOf(c, t) ? c : neverType;
28244
+ // WAS: isTypeStrictSubtypeOf(t, c) ? t : isTypeStrictSubtypeOf(c, t) ? c : isTypeSubtypeOf(t, c) ? t : isTypeSubtypeOf(c, t) ? c : neverType;
28245
28245
28246
- if (t.flags & TypeFlags.Literal && c.flags & TypeFlags.Literal) {
28247
- if (t.flags & TypeFlags.BooleanLiteral && c.flags & TypeFlags.BooleanLiteral) {
28246
+ // Avoid going through relations for comparison between literals of the same types;
28247
+ // if they're not equal then they're not related and we can skip doing a bunch of work.
28248
+ if (t.flags & TypeFlags.Literal && (t.flags & TypeFlags.Literal) === (c.flags & TypeFlags.Literal)) {
28249
+ if (t.flags & TypeFlags.BooleanLiteral) {
28248
28250
return t === c ? t : neverType;
28249
28251
}
28250
28252
return (t as LiteralType).value === (c as LiteralType).value ? t : neverType;
@@ -28253,6 +28255,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
28253
28255
if (isTypeStrictSubtypeOf(t, c)) return t;
28254
28256
if (isTypeStrictSubtypeOf(c, t)) return c;
28255
28257
28258
+ // Strict subtyping is equivalent to subtyping for these types (and likely others).
28256
28259
if (t.flags & TypeFlags.Unit && c.flags & TypeFlags.Unit) return neverType;
28257
28260
28258
28261
if (isTypeSubtypeOf(t, c)) return t;
0 commit comments