@@ -741,6 +741,7 @@ namespace ts {
741741 declaration : SignatureDeclaration ;
742742 typeParameters : TypeParameter [ ] ;
743743 parameters : Symbol [ ] ;
744+ thisType : Type ;
744745 resolvedReturnType : Type ;
745746 minArgumentCount : number ;
746747 hasRestParameter : boolean ;
@@ -4109,6 +4110,9 @@ namespace ts {
41094110 if ( typeChecker . isArgumentsSymbol ( symbol ) ) {
41104111 return ScriptElementKind . localVariableElement ;
41114112 }
4113+ if ( location . kind === SyntaxKind . ThisKeyword && isExpression ( location ) ) {
4114+ return ScriptElementKind . parameterElement ;
4115+ }
41124116 if ( flags & SymbolFlags . Variable ) {
41134117 if ( isFirstDeclarationOfSymbolParameter ( symbol ) ) {
41144118 return ScriptElementKind . parameterElement ;
@@ -4171,6 +4175,7 @@ namespace ts {
41714175 const symbolFlags = symbol . flags ;
41724176 let symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar ( symbol , symbolFlags , location ) ;
41734177 let hasAddedSymbolInfo : boolean ;
4178+ const isThisExpression : boolean = location . kind === SyntaxKind . ThisKeyword && isExpression ( location ) ;
41744179 let type : Type ;
41754180
41764181 // Class at constructor site need to be shown as constructor apart from property,method, vars
@@ -4181,7 +4186,7 @@ namespace ts {
41814186 }
41824187
41834188 let signature : Signature ;
4184- type = typeChecker . getTypeOfSymbolAtLocation ( symbol , location ) ;
4189+ type = isThisExpression ? typeChecker . getTypeAtLocation ( location ) : typeChecker . getTypeOfSymbolAtLocation ( symbol , location ) ;
41854190 if ( type ) {
41864191 if ( location . parent && location . parent . kind === SyntaxKind . PropertyAccessExpression ) {
41874192 const right = ( < PropertyAccessExpression > location . parent ) . name ;
@@ -4292,7 +4297,7 @@ namespace ts {
42924297 }
42934298 }
42944299 }
4295- if ( symbolFlags & SymbolFlags . Class && ! hasAddedSymbolInfo ) {
4300+ if ( symbolFlags & SymbolFlags . Class && ! hasAddedSymbolInfo && ! isThisExpression ) {
42964301 if ( getDeclarationOfKind ( symbol , SyntaxKind . ClassExpression ) ) {
42974302 // Special case for class expressions because we would like to indicate that
42984303 // the class name is local to the class body (similar to function expression)
@@ -4434,11 +4439,19 @@ namespace ts {
44344439 if ( ! hasAddedSymbolInfo ) {
44354440 if ( symbolKind !== ScriptElementKind . unknown ) {
44364441 if ( type ) {
4437- addPrefixForAnyFunctionOrVar ( symbol , symbolKind ) ;
4442+ if ( isThisExpression ) {
4443+ addNewLineIfDisplayPartsExist ( ) ;
4444+ displayParts . push ( keywordPart ( SyntaxKind . ThisKeyword ) ) ;
4445+ }
4446+ else {
4447+ addPrefixForAnyFunctionOrVar ( symbol , symbolKind ) ;
4448+ }
4449+
44384450 // For properties, variables and local vars: show the type
44394451 if ( symbolKind === ScriptElementKind . memberVariableElement ||
44404452 symbolFlags & SymbolFlags . Variable ||
4441- symbolKind === ScriptElementKind . localVariableElement ) {
4453+ symbolKind === ScriptElementKind . localVariableElement ||
4454+ isThisExpression ) {
44424455 displayParts . push ( punctuationPart ( SyntaxKind . ColonToken ) ) ;
44434456 displayParts . push ( spacePart ( ) ) ;
44444457 // If the type is type parameter, format it specially
0 commit comments