@@ -128,14 +128,18 @@ namespace ts.SymbolDisplay {
128128 let documentation : SymbolDisplayPart [ ] | undefined ;
129129 let tags : JSDocTagInfo [ ] | undefined ;
130130 const symbolFlags = getCombinedLocalAndExportSymbolFlags ( symbol ) ;
131- let symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar ( typeChecker , symbol , location ) ;
131+ let symbolKind = semanticMeaning & SemanticMeaning . Value ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar ( typeChecker , symbol , location ) : ScriptElementKind . unknown ;
132132 let hasAddedSymbolInfo = false ;
133- const isThisExpression = location . kind === SyntaxKind . ThisKeyword && isExpression ( location ) ;
133+ const isThisExpression = location . kind === SyntaxKind . ThisKeyword && isInExpressionContext ( location ) ;
134134 let type : Type | undefined ;
135135 let printer : Printer ;
136136 let documentationFromAlias : SymbolDisplayPart [ ] | undefined ;
137137 let tagsFromAlias : JSDocTagInfo [ ] | undefined ;
138138
139+ if ( location . kind === SyntaxKind . ThisKeyword && ! isThisExpression ) {
140+ return { displayParts : [ keywordPart ( SyntaxKind . ThisKeyword ) ] , documentation : [ ] , symbolKind : ScriptElementKind . primitiveType , tags : undefined } ;
141+ }
142+
139143 // Class at constructor site need to be shown as constructor apart from property,method, vars
140144 if ( symbolKind !== ScriptElementKind . unknown || symbolFlags & SymbolFlags . Class || symbolFlags & SymbolFlags . Alias ) {
141145 // If it is accessor they are allowed only if location is at name of the accessor
@@ -285,7 +289,7 @@ namespace ts.SymbolDisplay {
285289 addFullSymbolName ( symbol ) ;
286290 writeTypeParametersOfSymbol ( symbol , sourceFile ) ;
287291 }
288- if ( symbolFlags & SymbolFlags . TypeAlias ) {
292+ if ( ( symbolFlags & SymbolFlags . TypeAlias ) && ( semanticMeaning & SemanticMeaning . Type ) ) {
289293 prefixNextMeaning ( ) ;
290294 displayParts . push ( keywordPart ( SyntaxKind . TypeKeyword ) ) ;
291295 displayParts . push ( spacePart ( ) ) ;
0 commit comments