From f41b7b59ce8919702baff6ab7caf4363a001af60 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Thu, 17 Oct 2019 10:54:01 -0700 Subject: [PATCH] Fix quick info for methods whose contextual type is a mapped type property (#33930) --- src/services/symbolDisplay.ts | 2 +- tests/cases/fourslash/quickInfoMappedTypeMethods.ts | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/quickInfoMappedTypeMethods.ts diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 0dc540dcaca..faff3620d62 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -237,7 +237,7 @@ namespace ts.SymbolDisplay { // get the signature from the declaration and write it const functionDeclaration = location.parent; // Use function declaration to write the signatures only if the symbol corresponding to this declaration - const locationIsSymbolDeclaration = find(symbol.declarations, declaration => + const locationIsSymbolDeclaration = symbol.declarations && find(symbol.declarations, declaration => declaration === (location.kind === SyntaxKind.ConstructorKeyword ? functionDeclaration.parent : functionDeclaration)); if (locationIsSymbolDeclaration) { diff --git a/tests/cases/fourslash/quickInfoMappedTypeMethods.ts b/tests/cases/fourslash/quickInfoMappedTypeMethods.ts new file mode 100644 index 00000000000..8107775b9e4 --- /dev/null +++ b/tests/cases/fourslash/quickInfoMappedTypeMethods.ts @@ -0,0 +1,9 @@ +/// +// https://github.com/microsoft/TypeScript/issues/32983 + +////type M = { [K in 'one']: any }; +////const x: M = { +//// /**/one() {} +////} + +verify.quickInfoAt("", "(property) one: any");