Don't use property symbols from contextual types with binding patterns for quick info

This commit is contained in:
Mateusz Burzyński 2024-10-08 21:43:43 +02:00
Родитель 2149a0f31a
Коммит 49596d7158
2 изменённых файлов: 17 добавлений и 1 удалений

Просмотреть файл

@ -3560,7 +3560,7 @@ function getSymbolAtLocationForQuickInfo(node: Node, checker: TypeChecker): Symb
const object = getContainingObjectLiteralElement(node);
if (object) {
const contextualType = checker.getContextualType(object.parent);
const properties = contextualType && getPropertySymbolsFromContextualType(object, checker, contextualType, /*unionSymbolOk*/ false);
const properties = contextualType && !contextualType.pattern && getPropertySymbolsFromContextualType(object, checker, contextualType, /*unionSymbolOk*/ false);
if (properties && properties.length === 1) {
return first(properties);
}

Просмотреть файл

@ -0,0 +1,16 @@
/// <reference path='fourslash.ts'/>
// @strict: true
//// const { x } = { x/*1*/: 1 };
//// const { x: y } = { x/*2*/: 1 };
////
//// type Foo = {
//// /** awesome prop */
//// x: number;
//// };
//// const { x: z }: Foo = { x/*3*/: 1 };
verify.quickInfoAt("1", "(property) x: number");
verify.quickInfoAt("2", "(property) x: number");
verify.quickInfoAt("3", "(property) x: number", "awesome prop");