Skip to content

Commit b330fbc

Browse files
committed
Bail early in getNarrowedTypeWorker if type is candidate
1 parent efc343a commit b330fbc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28163,6 +28163,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2816328163
if (type.flags & TypeFlags.AnyOrUnknown) {
2816428164
return candidate;
2816528165
}
28166+
28167+
// TODO(jakebailey): should this just be type === candidate?
28168+
if (isTypeIdenticalTo(type, candidate)) {
28169+
return candidate;
28170+
}
28171+
2816628172
// We first attempt to filter the current type, narrowing constituents as appropriate and removing
2816728173
// constituents that are unrelated to the candidate.
2816828174
const isRelated = checkDerived ? isTypeDerivedFrom : isTypeSubtypeOf;

0 commit comments

Comments
 (0)