From 33341342430153eacfc09a507307d433a295b0ec Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 12 May 2016 07:25:21 -0700 Subject: [PATCH] Fix #7966: A non-anonymous type can still fail to have a symbol. For example, an intersection type. (We still need the check for the Anonymous flags or else anonymous function tooltips will look like `var lambdaFoo: (Anonymous function)(a: number, b: number) => number'` instead of `var lambdaFoo: (a: number, b: number) => number`) --- src/services/services.ts | 2 +- tests/cases/fourslash/getQuickInfoForIntersectionTypes.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/getQuickInfoForIntersectionTypes.ts diff --git a/src/services/services.ts b/src/services/services.ts index 83f0d7152fd..4d4917ec601 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4349,7 +4349,7 @@ namespace ts { displayParts.push(keywordPart(SyntaxKind.NewKeyword)); displayParts.push(spacePart()); } - if (!(type.flags & TypeFlags.Anonymous)) { + if (!(type.flags & TypeFlags.Anonymous) && type.symbol) { addRange(displayParts, symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, SymbolFormatFlags.WriteTypeParametersOrArguments)); } addSignatureDisplayParts(signature, allSignatures, TypeFormatFlags.WriteArrowStyleSignature); diff --git a/tests/cases/fourslash/getQuickInfoForIntersectionTypes.ts b/tests/cases/fourslash/getQuickInfoForIntersectionTypes.ts new file mode 100644 index 00000000000..ecdd0954617 --- /dev/null +++ b/tests/cases/fourslash/getQuickInfoForIntersectionTypes.ts @@ -0,0 +1,8 @@ +////function f(): string & {(): any} { +//// return {}; +////} +////let x = f(); +////x/**/(); + +goTo.marker(); +verify.quickInfoIs("let x: () => any");