@@ -11459,16 +11459,25 @@ namespace ts {
11459
11459
}
11460
11460
11461
11461
const propType = getTypeOfSymbol(prop);
11462
+ const assignmentKind = getAssignmentTargetKind(node);
11463
+
11464
+ if (assignmentKind) {
11465
+ if (isReferenceToReadonlyEntity(<Expression>node, prop) || isReferenceThroughNamespaceImport(<Expression>node)) {
11466
+ error(right, Diagnostics.Cannot_assign_to_0_because_it_is_a_constant_or_a_read_only_property, right.text);
11467
+ return unknownType;
11468
+ }
11469
+ }
11462
11470
11463
11471
// Only compute control flow type if this is a property access expression that isn't an
11464
11472
// assignment target, and the referenced property was declared as a variable, property,
11465
11473
// accessor, or optional method.
11466
- if (node.kind !== SyntaxKind.PropertyAccessExpression || isAssignmentTarget(node) ||
11474
+ if (node.kind !== SyntaxKind.PropertyAccessExpression || assignmentKind === AssignmentKind.Definite ||
11467
11475
!(prop.flags & (SymbolFlags.Variable | SymbolFlags.Property | SymbolFlags.Accessor)) &&
11468
11476
!(prop.flags & SymbolFlags.Method && propType.flags & TypeFlags.Union)) {
11469
11477
return propType;
11470
11478
}
11471
- return getFlowTypeOfReference(node, propType, /*assumeInitialized*/ true, /*flowContainer*/ undefined);
11479
+ const flowType = getFlowTypeOfReference(node, propType, /*assumeInitialized*/ true, /*flowContainer*/ undefined);
11480
+ return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
11472
11481
}
11473
11482
11474
11483
function isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean {
@@ -13515,7 +13524,7 @@ namespace ts {
13515
13524
error(expr, invalidReferenceMessage);
13516
13525
return false;
13517
13526
}
13518
- if (node.kind === SyntaxKind.Identifier) {
13527
+ if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.PropertyAccessExpression ) {
13519
13528
return true;
13520
13529
}
13521
13530
// Because we get the symbol from the resolvedSymbol property, it might be of kind
0 commit comments