mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Display write type for property accesses in write locations (#54777)
This commit is contained in:
parent
0099e42451
commit
b8b0d26cb9
@ -11541,7 +11541,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 ?
|
||||
@ -27703,7 +27703,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;
|
||||
}
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @strict: true
|
||||
// @exactOptionalPropertyTypes: true
|
||||
//// declare const xx: { prop?: number };
|
||||
//// xx.prop/*1*/ = 1;
|
||||
|
||||
verify.quickInfoAt('1', '(property) prop?: number');
|
||||
@ -0,0 +1,8 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @strict: true
|
||||
// @exactOptionalPropertyTypes: true
|
||||
//// declare const xx: { prop?: number };
|
||||
//// xx.prop/*1*/ += 1;
|
||||
|
||||
verify.quickInfoAt('1', '(property) prop?: number');
|
||||
@ -0,0 +1,8 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @strict: true
|
||||
// @exactOptionalPropertyTypes: true
|
||||
//// declare const xx: { prop?: number };
|
||||
//// xx.prop/*1*/ ??= 1;
|
||||
|
||||
verify.quickInfoAt('1', '(property) prop?: number');
|
||||
@ -0,0 +1,11 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @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');
|
||||
@ -0,0 +1,11 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
// @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');
|
||||
Loading…
x
Reference in New Issue
Block a user