Merge pull request #19770 from Microsoft/remove-readonly-from-spread-index-sigs

Remove readonly from index signatures of a spread
This commit is contained in:
Nathan Shively-Sanders
2017-11-06 10:20:57 -08:00
committed by GitHub
6 changed files with 55 additions and 2 deletions

View File

@@ -8000,11 +8000,16 @@ namespace ts {
}
}
const spread = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo);
const spread = createAnonymousType(
symbol,
members,
emptyArray,
emptyArray,
getNonReadonlyIndexSignature(stringIndexInfo),
getNonReadonlyIndexSignature(numberIndexInfo));
spread.flags |= propagatedFlags;
spread.flags |= TypeFlags.FreshLiteral | TypeFlags.ContainsObjectLiteral;
(spread as ObjectType).objectFlags |= (ObjectFlags.ObjectLiteral | ObjectFlags.ContainsSpread);
spread.symbol = symbol;
return spread;
}
@@ -8020,6 +8025,13 @@ namespace ts {
return result;
}
function getNonReadonlyIndexSignature(index: IndexInfo) {
if (index && index.isReadonly) {
return createIndexInfo(index.type, /*isReadonly*/ false, index.declaration);
}
return index;
}
function isClassMethod(prop: Symbol) {
return prop.flags & SymbolFlags.Method && find(prop.declarations, decl => isClassLike(decl.parent));
}