@@ -3062,20 +3062,17 @@ namespace ts {
3062
3062
}
3063
3063
else if ( jsxContainer ) {
3064
3064
let attrsType : Type ;
3065
- if ( jsxContainer . kind === SyntaxKind . JsxSelfClosingElement ) {
3066
- // Cursor is inside a JSX self-closing element
3067
- attrsType = typeChecker . getJsxElementAttributesType ( < JsxSelfClosingElement > jsxContainer ) ;
3068
- }
3069
- else if ( jsxContainer . kind === SyntaxKind . JsxOpeningElement ) {
3070
- // Cursor is inside a JSX element
3071
- attrsType = typeChecker . getJsxElementAttributesType ( < JsxOpeningElement > jsxContainer ) ;
3072
- }
3065
+ if ( ( jsxContainer . kind === SyntaxKind . JsxSelfClosingElement ) || ( jsxContainer . kind === SyntaxKind . JsxOpeningElement ) ) {
3066
+ // Cursor is inside a JSX self-closing element or opening element
3067
+ attrsType = typeChecker . getJsxElementAttributesType ( < JsxOpeningLikeElement > jsxContainer ) ;
3068
+
3069
+ if ( attrsType ) {
3070
+ symbols = filterJsxAttributes ( ( < JsxOpeningLikeElement > jsxContainer ) . attributes , typeChecker . getPropertiesOfType ( attrsType ) ) ;
3071
+ isMemberCompletion = true ;
3072
+ isNewIdentifierLocation = false ;
3073
+ return true ;
3074
+ }
3073
3075
3074
- if ( attrsType ) {
3075
- symbols = typeChecker . getPropertiesOfType ( attrsType ) ;
3076
- isMemberCompletion = true ;
3077
- isNewIdentifierLocation = false ;
3078
- return true ;
3079
3076
}
3080
3077
}
3081
3078
@@ -3476,6 +3473,22 @@ namespace ts {
3476
3473
}
3477
3474
}
3478
3475
3476
+ function filterJsxAttributes ( attributes : NodeArray < JsxAttribute | JsxSpreadAttribute > , symbols : Symbol [ ] ) : Symbol [ ] {
3477
+ let seenNames : Map < boolean > = { } ;
3478
+ for ( let attr of attributes ) {
3479
+ if ( attr . kind === SyntaxKind . JsxAttribute ) {
3480
+ seenNames [ ( < JsxAttribute > attr ) . name . text ] = true ;
3481
+ }
3482
+ }
3483
+ let result : Symbol [ ] = [ ] ;
3484
+ for ( let sym of symbols ) {
3485
+ if ( ! seenNames [ sym . name ] ) {
3486
+ result . push ( sym ) ;
3487
+ }
3488
+ }
3489
+ return result ;
3490
+ }
3491
+
3479
3492
function getCompletionsAtPosition ( fileName : string , position : number ) : CompletionInfo {
3480
3493
synchronizeHostData ( ) ;
3481
3494
0 commit comments