@@ -898,8 +898,8 @@ namespace ts.Completions {
898
898
return undefined ;
899
899
}
900
900
901
- const { parent, kind } = contextToken ;
902
- if ( kind === SyntaxKind . DotToken ) {
901
+ let parent = contextToken . parent ;
902
+ if ( contextToken . kind === SyntaxKind . DotToken ) {
903
903
if ( parent . kind === SyntaxKind . PropertyAccessExpression ) {
904
904
node = ( < PropertyAccessExpression > contextToken . parent ) . expression ;
905
905
isRightOfDot = true ;
@@ -915,16 +915,24 @@ namespace ts.Completions {
915
915
}
916
916
}
917
917
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 ) {
919
927
case SyntaxKind . JsxClosingElement :
920
- if ( kind === SyntaxKind . SlashToken ) {
928
+ if ( contextToken . kind === SyntaxKind . SlashToken ) {
921
929
isStartingCloseTag = true ;
922
930
location = contextToken ;
923
931
}
924
932
break ;
925
933
926
934
case SyntaxKind . BinaryExpression :
927
- if ( ! ( ( contextToken . parent as BinaryExpression ) . left . flags & NodeFlags . ThisNodeHasError ) ) {
935
+ if ( ! ( ( parent as BinaryExpression ) . left . flags & NodeFlags . ThisNodeHasError ) ) {
928
936
// It has a left-hand side, so we're not in an opening JSX tag.
929
937
break ;
930
938
}
@@ -933,7 +941,7 @@ namespace ts.Completions {
933
941
case SyntaxKind . JsxSelfClosingElement :
934
942
case SyntaxKind . JsxElement :
935
943
case SyntaxKind . JsxOpeningElement :
936
- if ( kind === SyntaxKind . LessThanToken ) {
944
+ if ( contextToken . kind === SyntaxKind . LessThanToken ) {
937
945
isRightOfOpenTag = true ;
938
946
location = contextToken ;
939
947
}
@@ -1401,6 +1409,7 @@ namespace ts.Completions {
1401
1409
case SyntaxKind . LessThanSlashToken :
1402
1410
case SyntaxKind . SlashToken :
1403
1411
case SyntaxKind . Identifier :
1412
+ case SyntaxKind . PropertyAccessExpression :
1404
1413
case SyntaxKind . JsxAttributes :
1405
1414
case SyntaxKind . JsxAttribute :
1406
1415
case SyntaxKind . JsxSpreadAttribute :
0 commit comments