@@ -2321,8 +2321,6 @@ namespace ts {
2321
2321
printFollowingPunctuation = true;
2322
2322
}
2323
2323
}
2324
- // TODO: Only print if this is directly on the type -- not on the subtype somewhere.
2325
- // (This is not crucial, though, since the extra info *might* be nice.)
2326
2324
const resolved = resolveStructuredTypeMembers(type);
2327
2325
writeIndexSignature(resolved.stringIndexInfo, SyntaxKind.StringKeyword);
2328
2326
writeIndexSignature(resolved.numberIndexInfo, SyntaxKind.NumberKeyword);
@@ -6656,23 +6654,42 @@ namespace ts {
6656
6654
}
6657
6655
}
6658
6656
6659
- if (source.flags & TypeFlags.Spread && target.flags & TypeFlags.Spread) {
6660
- const sourceParameters = filter((source as SpreadType).types, t => !!(t.flags & TypeFlags.TypeParameter));
6661
- const targetParameters = filter((target as SpreadType).types, t => !!(t.flags & TypeFlags.TypeParameter));
6662
- if (sourceParameters.length !== targetParameters.length) {
6663
- reportRelationError(headMessage, source, target);
6664
- return Ternary.False;
6657
+ if (source.flags & TypeFlags.Spread) {
6658
+ if (target.flags & TypeFlags.TypeParameter) {
6659
+ let hasTypeParameter = false;
6660
+ let typeParametersAreEqual = true;
6661
+ for (const t of (source as SpreadType).types) {
6662
+ if (t.flags & TypeFlags.TypeParameter) {
6663
+ hasTypeParameter = true;
6664
+ if (t !== target) {
6665
+ typeParametersAreEqual = false;
6666
+ break;
6667
+ }
6668
+ }
6669
+ }
6670
+ if (hasTypeParameter && typeParametersAreEqual) {
6671
+ errorInfo = saveErrorInfo;
6672
+ return Ternary.True;
6673
+ }
6665
6674
}
6666
- for (let i = 0; i < sourceParameters.length; i++) {
6667
- if (sourceParameters[i].symbol !== targetParameters[i].symbol) {
6675
+ else if (target.flags & TypeFlags.Spread) {
6676
+ const sourceParameters = filter((source as SpreadType).types, t => !!(t.flags & TypeFlags.TypeParameter));
6677
+ const targetParameters = filter((target as SpreadType).types, t => !!(t.flags & TypeFlags.TypeParameter));
6678
+ if (sourceParameters.length !== targetParameters.length) {
6668
6679
reportRelationError(headMessage, source, target);
6669
6680
return Ternary.False;
6670
6681
}
6671
- }
6672
- const reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo;
6673
- if (result = objectTypeRelatedTo(source, source, target, reportStructuralErrors)) {
6674
- errorInfo = saveErrorInfo;
6675
- return result;
6682
+ for (let i = 0; i < sourceParameters.length; i++) {
6683
+ if (sourceParameters[i].symbol !== targetParameters[i].symbol) {
6684
+ reportRelationError(headMessage, source, target);
6685
+ return Ternary.False;
6686
+ }
6687
+ }
6688
+ const reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo;
6689
+ if (result = objectTypeRelatedTo(source, source, target, reportStructuralErrors)) {
6690
+ errorInfo = saveErrorInfo;
6691
+ return result;
6692
+ }
6676
6693
}
6677
6694
}
6678
6695
0 commit comments