@@ -128,14 +128,18 @@ namespace ts.SymbolDisplay {
128
128
let documentation : SymbolDisplayPart [ ] | undefined ;
129
129
let tags : JSDocTagInfo [ ] | undefined ;
130
130
const symbolFlags = getCombinedLocalAndExportSymbolFlags ( symbol ) ;
131
- let symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar ( typeChecker , symbol , location ) ;
131
+ let symbolKind = semanticMeaning & SemanticMeaning . Value ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar ( typeChecker , symbol , location ) : ScriptElementKind . unknown ;
132
132
let hasAddedSymbolInfo = false ;
133
- const isThisExpression = location . kind === SyntaxKind . ThisKeyword && isExpression ( location ) ;
133
+ const isThisExpression = location . kind === SyntaxKind . ThisKeyword && isInExpressionContext ( location ) ;
134
134
let type : Type | undefined ;
135
135
let printer : Printer ;
136
136
let documentationFromAlias : SymbolDisplayPart [ ] | undefined ;
137
137
let tagsFromAlias : JSDocTagInfo [ ] | undefined ;
138
138
139
+ if ( location . kind === SyntaxKind . ThisKeyword && ! isThisExpression ) {
140
+ return { displayParts : [ keywordPart ( SyntaxKind . ThisKeyword ) ] , documentation : [ ] , symbolKind : ScriptElementKind . primitiveType , tags : undefined } ;
141
+ }
142
+
139
143
// Class at constructor site need to be shown as constructor apart from property,method, vars
140
144
if ( symbolKind !== ScriptElementKind . unknown || symbolFlags & SymbolFlags . Class || symbolFlags & SymbolFlags . Alias ) {
141
145
// If it is accessor they are allowed only if location is at name of the accessor
@@ -285,7 +289,7 @@ namespace ts.SymbolDisplay {
285
289
addFullSymbolName ( symbol ) ;
286
290
writeTypeParametersOfSymbol ( symbol , sourceFile ) ;
287
291
}
288
- if ( symbolFlags & SymbolFlags . TypeAlias ) {
292
+ if ( ( symbolFlags & SymbolFlags . TypeAlias ) && ( semanticMeaning & SemanticMeaning . Type ) ) {
289
293
prefixNextMeaning ( ) ;
290
294
displayParts . push ( keywordPart ( SyntaxKind . TypeKeyword ) ) ;
291
295
displayParts . push ( spacePart ( ) ) ;
0 commit comments