diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts
index ee86ae50306c7..2259632654456 100644
--- a/src/compiler/checker.ts
+++ b/src/compiler/checker.ts
@@ -11484,7 +11484,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
getWriteTypeOfSymbolWithDeferredType(symbol) || getTypeOfSymbolWithDeferredType(symbol) :
// NOTE: cast to TransientSymbol should be safe because only TransientSymbols can have CheckFlags.SyntheticProperty
(symbol as TransientSymbol).links.writeType || (symbol as TransientSymbol).links.type! :
- getTypeOfSymbol(symbol);
+ removeMissingType(getTypeOfSymbol(symbol), !!(symbol.flags & SymbolFlags.Optional));
}
if (symbol.flags & SymbolFlags.Accessor) {
return checkFlags & CheckFlags.Instantiated ?
@@ -27645,7 +27645,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
location = location.parent;
}
if (isExpressionNode(location) && (!isAssignmentTarget(location) || isWriteAccess(location))) {
- const type = removeOptionalTypeMarker(getTypeOfExpression(location as Expression));
+ const type = removeOptionalTypeMarker(
+ isWriteAccess(location) && location.kind === SyntaxKind.PropertyAccessExpression ?
+ checkPropertyAccessExpression(location as PropertyAccessExpression, /*checkMode*/ undefined, /*writeOnly*/ true) :
+ getTypeOfExpression(location as Expression)
+ );
if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) {
return type;
}
diff --git a/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation1.ts b/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation1.ts
new file mode 100644
index 0000000000000..81299002a12e5
--- /dev/null
+++ b/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation1.ts
@@ -0,0 +1,8 @@
+///
+
+// @strict: true
+// @exactOptionalPropertyTypes: true
+//// declare const xx: { prop?: number };
+//// xx.prop/*1*/ = 1;
+
+verify.quickInfoAt('1', '(property) prop?: number');
diff --git a/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation2.ts b/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation2.ts
new file mode 100644
index 0000000000000..02babc99c2250
--- /dev/null
+++ b/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation2.ts
@@ -0,0 +1,8 @@
+///
+
+// @strict: true
+// @exactOptionalPropertyTypes: true
+//// declare const xx: { prop?: number };
+//// xx.prop/*1*/ += 1;
+
+verify.quickInfoAt('1', '(property) prop?: number');
diff --git a/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation3.ts b/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation3.ts
new file mode 100644
index 0000000000000..6b2e7092c33b2
--- /dev/null
+++ b/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation3.ts
@@ -0,0 +1,8 @@
+///
+
+// @strict: true
+// @exactOptionalPropertyTypes: true
+//// declare const xx: { prop?: number };
+//// xx.prop/*1*/ ??= 1;
+
+verify.quickInfoAt('1', '(property) prop?: number');
diff --git a/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation4.ts b/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation4.ts
new file mode 100644
index 0000000000000..acf55817c39ee
--- /dev/null
+++ b/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation4.ts
@@ -0,0 +1,11 @@
+///
+
+// @strict: true
+//// interface Serializer {
+//// set value(v: string | number | boolean);
+//// get value(): string;
+//// }
+//// declare let box: Serializer;
+//// box.value/*1*/ = true;
+
+verify.quickInfoAt('1', '(property) Serializer.value: string | number | boolean');
diff --git a/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation5.ts b/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation5.ts
new file mode 100644
index 0000000000000..06ea4ba9166d3
--- /dev/null
+++ b/tests/cases/fourslash/quickInfoOnPropertyAccessInWriteLocation5.ts
@@ -0,0 +1,11 @@
+///
+
+// @strict: true
+//// interface Serializer {
+//// set value(v: string | number);
+//// get value(): string;
+//// }
+//// declare let box: Serializer;
+//// box.value/*1*/ += 10;
+
+verify.quickInfoAt('1', '(property) Serializer.value: string | number');