mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 11:24:29 -05:00
Make optional properties assignable to string index signatures (#41921)
This commit is contained in:
@@ -18609,7 +18609,11 @@ namespace ts {
|
||||
continue;
|
||||
}
|
||||
if (kind === IndexKind.String || isNumericLiteralName(prop.escapedName)) {
|
||||
const related = isRelatedTo(getTypeOfSymbol(prop), target, reportErrors);
|
||||
const propType = getTypeOfSymbol(prop);
|
||||
const type = propType.flags & TypeFlags.Undefined || !(kind === IndexKind.String && prop.flags & SymbolFlags.Optional)
|
||||
? propType
|
||||
: getTypeWithFacts(propType, TypeFacts.NEUndefined);
|
||||
const related = isRelatedTo(type, target, reportErrors);
|
||||
if (!related) {
|
||||
if (reportErrors) {
|
||||
reportError(Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop));
|
||||
|
||||
Reference in New Issue
Block a user