Skip to content

Commit 629de0d

Browse files
committed
Fixup
1 parent 54d0bc7 commit 629de0d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28241,10 +28241,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2824128241
checkDerived ?
2824228242
t => isTypeDerivedFrom(t, c) ? t : isTypeDerivedFrom(c, t) ? c : neverType :
2824328243
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;
2824528245

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) {
2824828250
return t === c ? t : neverType;
2824928251
}
2825028252
return (t as LiteralType).value === (c as LiteralType).value ? t : neverType;
@@ -28253,6 +28255,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2825328255
if (isTypeStrictSubtypeOf(t, c)) return t;
2825428256
if (isTypeStrictSubtypeOf(c, t)) return c;
2825528257

28258+
// Strict subtyping is equivalent to subtyping for these types (and likely others).
2825628259
if (t.flags & TypeFlags.Unit && c.flags & TypeFlags.Unit) return neverType;
2825728260

2825828261
if (isTypeSubtypeOf(t, c)) return t;

0 commit comments

Comments
 (0)