diff --git a/src/services/services.ts b/src/services/services.ts index 83f0d7152fd..39dd688254d 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4541,8 +4541,10 @@ namespace ts { } // For properties, variables and local vars: show the type + // Also handle methods that have a union type (i.e. that may be undefined) if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & SymbolFlags.Variable || + symbolFlags & SymbolFlags.Method && type.flags & TypeFlags.Union || symbolKind === ScriptElementKind.localVariableElement || isThisExpression) { displayParts.push(punctuationPart(SyntaxKind.ColonToken));