From 49596d7158eb75aecff4baae306746e2932465c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 8 Oct 2024 21:43:43 +0200 Subject: [PATCH] Don't use property symbols from contextual types with binding patterns for quick info --- src/services/services.ts | 2 +- ...InfoOnPropertyAssignedToDestructuringName1.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/quickInfoOnPropertyAssignedToDestructuringName1.ts diff --git a/src/services/services.ts b/src/services/services.ts index 8f749a3217f..a159ae7b7fa 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -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); } diff --git a/tests/cases/fourslash/quickInfoOnPropertyAssignedToDestructuringName1.ts b/tests/cases/fourslash/quickInfoOnPropertyAssignedToDestructuringName1.ts new file mode 100644 index 00000000000..772c4df98fb --- /dev/null +++ b/tests/cases/fourslash/quickInfoOnPropertyAssignedToDestructuringName1.ts @@ -0,0 +1,16 @@ +/// + +// @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");