@@ -447,8 +447,8 @@ namespace ts.Completions {
447447 return undefined ;
448448 }
449449
450- const { parent, kind } = contextToken ;
451- if ( kind === SyntaxKind . DotToken ) {
450+ let parent = contextToken . parent ;
451+ if ( contextToken . kind === SyntaxKind . DotToken ) {
452452 if ( parent . kind === SyntaxKind . PropertyAccessExpression ) {
453453 node = ( < PropertyAccessExpression > contextToken . parent ) . expression ;
454454 isRightOfDot = true ;
@@ -464,16 +464,24 @@ namespace ts.Completions {
464464 }
465465 }
466466 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 ) {
468476 case SyntaxKind . JsxClosingElement :
469- if ( kind === SyntaxKind . SlashToken ) {
477+ if ( contextToken . kind === SyntaxKind . SlashToken ) {
470478 isStartingCloseTag = true ;
471479 location = contextToken ;
472480 }
473481 break ;
474482
475483 case SyntaxKind . BinaryExpression :
476- if ( ! ( ( contextToken . parent as BinaryExpression ) . left . flags & NodeFlags . ThisNodeHasError ) ) {
484+ if ( ! ( ( parent as BinaryExpression ) . left . flags & NodeFlags . ThisNodeHasError ) ) {
477485 // It has a left-hand side, so we're not in an opening JSX tag.
478486 break ;
479487 }
@@ -482,7 +490,7 @@ namespace ts.Completions {
482490 case SyntaxKind . JsxSelfClosingElement :
483491 case SyntaxKind . JsxElement :
484492 case SyntaxKind . JsxOpeningElement :
485- if ( kind === SyntaxKind . LessThanToken ) {
493+ if ( contextToken . kind === SyntaxKind . LessThanToken ) {
486494 isRightOfOpenTag = true ;
487495 location = contextToken ;
488496 }
@@ -950,6 +958,7 @@ namespace ts.Completions {
950958 case SyntaxKind . LessThanSlashToken :
951959 case SyntaxKind . SlashToken :
952960 case SyntaxKind . Identifier :
961+ case SyntaxKind . PropertyAccessExpression :
953962 case SyntaxKind . JsxAttributes :
954963 case SyntaxKind . JsxAttribute :
955964 case SyntaxKind . JsxSpreadAttribute :
0 commit comments