@@ -1467,10 +1467,7 @@ namespace ts {
1467
1467
const sourceFile = getValidSourceFile ( fileName ) ;
1468
1468
const node = getTouchingPropertyName ( sourceFile , position , /*includeJsDocComment*/ true ) ;
1469
1469
if ( node === sourceFile ) {
1470
- return undefined ;
1471
- }
1472
-
1473
- if ( isLabelName ( node ) ) {
1470
+ // Avoid giving quickInfo for the sourceFile as a whole.
1474
1471
return undefined ;
1475
1472
}
1476
1473
@@ -1481,36 +1478,39 @@ namespace ts {
1481
1478
// Try getting just type at this position and show
1482
1479
switch ( node . kind ) {
1483
1480
case SyntaxKind . Identifier :
1481
+ if ( isLabelName ( node ) ) {
1482
+ // Type here will be 'any', avoid displaying this.
1483
+ return undefined ;
1484
+ }
1485
+ // falls through
1484
1486
case SyntaxKind . PropertyAccessExpression :
1485
1487
case SyntaxKind . QualifiedName :
1486
1488
case SyntaxKind . ThisKeyword :
1487
1489
case SyntaxKind . ThisType :
1488
1490
case SyntaxKind . SuperKeyword :
1489
1491
// For the identifiers/this/super etc get the type at position
1490
1492
const type = typeChecker . getTypeAtLocation ( node ) ;
1491
- if ( type ) {
1492
- return {
1493
- kind : ScriptElementKind . unknown ,
1494
- kindModifiers : ScriptElementKindModifier . none ,
1495
- textSpan : createTextSpan ( node . getStart ( ) , node . getWidth ( ) ) ,
1496
- displayParts : typeToDisplayParts ( typeChecker , type , getContainerNode ( node ) ) ,
1497
- documentation : type . symbol ? type . symbol . getDocumentationComment ( typeChecker ) : undefined ,
1498
- tags : type . symbol ? type . symbol . getJsDocTags ( ) : undefined
1499
- } ;
1500
- }
1493
+ return type && {
1494
+ kind : ScriptElementKind . unknown ,
1495
+ kindModifiers : ScriptElementKindModifier . none ,
1496
+ textSpan : createTextSpanFromNode ( node , sourceFile ) ,
1497
+ displayParts : typeToDisplayParts ( typeChecker , type , getContainerNode ( node ) ) ,
1498
+ documentation : type . symbol ? type . symbol . getDocumentationComment ( typeChecker ) : undefined ,
1499
+ tags : type . symbol ? type . symbol . getJsDocTags ( ) : undefined
1500
+ } ;
1501
1501
}
1502
1502
1503
1503
return undefined ;
1504
1504
}
1505
1505
1506
- const displayPartsDocumentationsAndKind = SymbolDisplay . getSymbolDisplayPartsDocumentationAndSymbolKind ( typeChecker , symbol , sourceFile , getContainerNode ( node ) , node ) ;
1506
+ const { symbolKind , displayParts , documentation , tags } = SymbolDisplay . getSymbolDisplayPartsDocumentationAndSymbolKind ( typeChecker , symbol , sourceFile , getContainerNode ( node ) , node ) ;
1507
1507
return {
1508
- kind : displayPartsDocumentationsAndKind . symbolKind ,
1508
+ kind : symbolKind ,
1509
1509
kindModifiers : SymbolDisplay . getSymbolModifiers ( symbol ) ,
1510
- textSpan : createTextSpan ( node . getStart ( ) , node . getWidth ( ) ) ,
1511
- displayParts : displayPartsDocumentationsAndKind . displayParts ,
1512
- documentation : displayPartsDocumentationsAndKind . documentation ,
1513
- tags : displayPartsDocumentationsAndKind . tags
1510
+ textSpan : createTextSpanFromNode ( node , sourceFile ) ,
1511
+ displayParts,
1512
+ documentation,
1513
+ tags,
1514
1514
} ;
1515
1515
}
1516
1516
@@ -1519,11 +1519,9 @@ namespace ts {
1519
1519
&& isPropertyAssignment ( node . parent )
1520
1520
&& node . parent . name === node ) {
1521
1521
const type = checker . getContextualType ( node . parent . parent ) ;
1522
- if ( type ) {
1523
- const property = checker . getPropertyOfType ( type , getTextOfIdentifierOrLiteral ( node ) ) ;
1524
- if ( property ) {
1525
- return property ;
1526
- }
1522
+ const property = type && checker . getPropertyOfType ( type , getTextOfIdentifierOrLiteral ( node ) ) ;
1523
+ if ( property ) {
1524
+ return property ;
1527
1525
}
1528
1526
}
1529
1527
return checker . getSymbolAtLocation ( node ) ;
0 commit comments