mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-22 22:55:36 -05:00
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:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user