@@ -447,8 +447,8 @@ namespace ts.Completions {
447
447
return undefined ;
448
448
}
449
449
450
- const { parent, kind } = contextToken ;
451
- if ( kind === SyntaxKind . DotToken ) {
450
+ let parent = contextToken . parent ;
451
+ if ( contextToken . kind === SyntaxKind . DotToken ) {
452
452
if ( parent . kind === SyntaxKind . PropertyAccessExpression ) {
453
453
node = ( < PropertyAccessExpression > contextToken . parent ) . expression ;
454
454
isRightOfDot = true ;
@@ -464,16 +464,24 @@ namespace ts.Completions {
464
464
}
465
465
}
466
466
else if ( sourceFile . languageVariant === LanguageVariant . JSX ) {
467
- switch ( contextToken . parent . kind ) {
467
+ // <UI.Test /* completion position */ />
468
+ // If the tagname is a property access expression, we will then walk up to the top most of property access expression.
469
+ // Then, try to get a JSX container and its associated attributes type.
470
+ if ( parent && parent . kind === SyntaxKind . PropertyAccessExpression ) {
471
+ contextToken = parent ;
472
+ parent = parent . parent ;
473
+ }
474
+
475
+ switch ( parent . kind ) {
468
476
case SyntaxKind . JsxClosingElement :
469
- if ( kind === SyntaxKind . SlashToken ) {
477
+ if ( contextToken . kind === SyntaxKind . SlashToken ) {
470
478
isStartingCloseTag = true ;
471
479
location = contextToken ;
472
480
}
473
481
break ;
474
482
475
483
case SyntaxKind . BinaryExpression :
476
- if ( ! ( ( contextToken . parent as BinaryExpression ) . left . flags & NodeFlags . ThisNodeHasError ) ) {
484
+ if ( ! ( ( parent as BinaryExpression ) . left . flags & NodeFlags . ThisNodeHasError ) ) {
477
485
// It has a left-hand side, so we're not in an opening JSX tag.
478
486
break ;
479
487
}
@@ -482,7 +490,7 @@ namespace ts.Completions {
482
490
case SyntaxKind . JsxSelfClosingElement :
483
491
case SyntaxKind . JsxElement :
484
492
case SyntaxKind . JsxOpeningElement :
485
- if ( kind === SyntaxKind . LessThanToken ) {
493
+ if ( contextToken . kind === SyntaxKind . LessThanToken ) {
486
494
isRightOfOpenTag = true ;
487
495
location = contextToken ;
488
496
}
@@ -950,6 +958,7 @@ namespace ts.Completions {
950
958
case SyntaxKind . LessThanSlashToken :
951
959
case SyntaxKind . SlashToken :
952
960
case SyntaxKind . Identifier :
961
+ case SyntaxKind . PropertyAccessExpression :
953
962
case SyntaxKind . JsxAttributes :
954
963
case SyntaxKind . JsxAttribute :
955
964
case SyntaxKind . JsxSpreadAttribute :
0 commit comments