@@ -898,8 +898,8 @@ namespace ts.Completions {
898898 return undefined ;
899899 }
900900
901- const { parent, kind } = contextToken ;
902- if ( kind === SyntaxKind . DotToken ) {
901+ let parent = contextToken . parent ;
902+ if ( contextToken . kind === SyntaxKind . DotToken ) {
903903 if ( parent . kind === SyntaxKind . PropertyAccessExpression ) {
904904 node = ( < PropertyAccessExpression > contextToken . parent ) . expression ;
905905 isRightOfDot = true ;
@@ -915,16 +915,24 @@ namespace ts.Completions {
915915 }
916916 }
917917 else if ( sourceFile . languageVariant === LanguageVariant . JSX ) {
918- switch ( contextToken . parent . kind ) {
918+ // <UI.Test /* completion position */ />
919+ // If the tagname is a property access expression, we will then walk up to the top most of property access expression.
920+ // Then, try to get a JSX container and its associated attributes type.
921+ if ( parent && parent . kind === SyntaxKind . PropertyAccessExpression ) {
922+ contextToken = parent ;
923+ parent = parent . parent ;
924+ }
925+
926+ switch ( parent . kind ) {
919927 case SyntaxKind . JsxClosingElement :
920- if ( kind === SyntaxKind . SlashToken ) {
928+ if ( contextToken . kind === SyntaxKind . SlashToken ) {
921929 isStartingCloseTag = true ;
922930 location = contextToken ;
923931 }
924932 break ;
925933
926934 case SyntaxKind . BinaryExpression :
927- if ( ! ( ( contextToken . parent as BinaryExpression ) . left . flags & NodeFlags . ThisNodeHasError ) ) {
935+ if ( ! ( ( parent as BinaryExpression ) . left . flags & NodeFlags . ThisNodeHasError ) ) {
928936 // It has a left-hand side, so we're not in an opening JSX tag.
929937 break ;
930938 }
@@ -933,7 +941,7 @@ namespace ts.Completions {
933941 case SyntaxKind . JsxSelfClosingElement :
934942 case SyntaxKind . JsxElement :
935943 case SyntaxKind . JsxOpeningElement :
936- if ( kind === SyntaxKind . LessThanToken ) {
944+ if ( contextToken . kind === SyntaxKind . LessThanToken ) {
937945 isRightOfOpenTag = true ;
938946 location = contextToken ;
939947 }
@@ -1401,6 +1409,7 @@ namespace ts.Completions {
14011409 case SyntaxKind . LessThanSlashToken :
14021410 case SyntaxKind . SlashToken :
14031411 case SyntaxKind . Identifier :
1412+ case SyntaxKind . PropertyAccessExpression :
14041413 case SyntaxKind . JsxAttributes :
14051414 case SyntaxKind . JsxAttribute :
14061415 case SyntaxKind . JsxSpreadAttribute :
0 commit comments