@@ -12776,26 +12776,17 @@ namespace ts {
12776
12776
if (isFreshLiteralType(target)) {
12777
12777
target = (<FreshableType>target).regularType;
12778
12778
}
12779
- if (source.flags & TypeFlags.Substitution) {
12780
- source = (<SubstitutionType>source).substitute;
12781
- }
12782
- if (target.flags & TypeFlags.Substitution) {
12783
- target = (<SubstitutionType>target).typeVariable;
12784
- }
12785
- if (source.flags & TypeFlags.Simplifiable) {
12786
- source = getSimplifiedType(source, /*writing*/ false);
12787
- }
12788
- if (target.flags & TypeFlags.Simplifiable) {
12789
- target = getSimplifiedType(target, /*writing*/ true);
12790
- }
12791
- if (source.flags & TypeFlags.Substitution) {
12792
- source = (<SubstitutionType>source).substitute;
12793
- }
12794
- if (target.flags & TypeFlags.Substitution) {
12795
- target = (<SubstitutionType>target).typeVariable;
12779
+ while (true) {
12780
+ const s = source.flags & TypeFlags.Substitution ? source = (<SubstitutionType>source).substitute :
12781
+ source.flags & TypeFlags.Simplifiable ? getSimplifiedType(source, /*writing*/ false) :
12782
+ source;
12783
+ const t = target.flags & TypeFlags.Substitution ? (<SubstitutionType>target).typeVariable :
12784
+ target.flags & TypeFlags.Simplifiable ? getSimplifiedType(target, /*writing*/ true) :
12785
+ target;
12786
+ if (s === source && t === target) break;
12787
+ source = s;
12788
+ target = t;
12796
12789
}
12797
- Debug.assert(!(source.flags & TypeFlags.Substitution), "Source type was a substitution - substitutes are unhandled in relationship checking");
12798
- Debug.assert(!(target.flags & TypeFlags.Substitution), "Target type was a substitution - substitutes are unhandled in relationship checking");
12799
12790
12800
12791
// Try to see if we're relating something like `Foo` -> `Bar | null | undefined`.
12801
12792
// If so, reporting the `null` and `undefined` in the type is hardly useful.
0 commit comments