@@ -168,7 +168,8 @@ namespace ts.SignatureHelp {
168168 export const enum ArgumentListKind {
169169 TypeArguments ,
170170 CallArguments ,
171- TaggedTemplateArguments
171+ TaggedTemplateArguments ,
172+ JSXAttributesArguments
172173 }
173174
174175 export interface ArgumentListInfo {
@@ -264,18 +265,18 @@ namespace ts.SignatureHelp {
264265 if ( node . parent . kind === SyntaxKind . CallExpression || node . parent . kind === SyntaxKind . NewExpression ) {
265266 const callExpression = < CallExpression > node . parent ;
266267 // There are 3 cases to handle:
267- // 1. The token introduces a list, and should begin a sig help session
268+ // 1. The token introduces a list, and should begin a signature help session
268269 // 2. The token is either not associated with a list, or ends a list, so the session should end
269- // 3. The token is buried inside a list, and should give sig help
270+ // 3. The token is buried inside a list, and should give signature help
270271 //
271272 // The following are examples of each:
272273 //
273274 // Case 1:
274- // foo<#T, U>(#a, b) -> The token introduces a list, and should begin a sig help session
275+ // foo<#T, U>(#a, b) -> The token introduces a list, and should begin a signature help session
275276 // Case 2:
276277 // fo#o<T, U>#(a, b)# -> The token is either not associated with a list, or ends a list, so the session should end
277278 // Case 3:
278- // foo<T#, U#>(a#, #b#) -> The token is buried inside a list, and should give sig help
279+ // foo<T#, U#>(a#, #b#) -> The token is buried inside a list, and should give signature help
279280 // Find out if 'node' is an argument, a type argument, or neither
280281 if ( node . kind === SyntaxKind . LessThanToken ||
281282 node . kind === SyntaxKind . OpenParenToken ) {
@@ -295,7 +296,7 @@ namespace ts.SignatureHelp {
295296
296297 // findListItemInfo can return undefined if we are not in parent's argument list
297298 // or type argument list. This includes cases where the cursor is:
298- // - To the right of the closing paren , non-substitution template, or template tail.
299+ // - To the right of the closing parenthesize , non-substitution template, or template tail.
299300 // - Between the type arguments and the arguments (greater than token)
300301 // - On the target of the call (parent.func)
301302 // - On the 'new' keyword in a 'new' expression
@@ -352,6 +353,22 @@ namespace ts.SignatureHelp {
352353
353354 return getArgumentListInfoForTemplate ( tagExpression , argumentIndex , sourceFile ) ;
354355 }
356+ else if ( node . parent && isJsxOpeningLikeElement ( node . parent ) ) {
357+ // Provide a signature help for JSX opening element or JSX self-closing element.
358+ // This is not guarantee that JSX tag-name is resolved into stateless function component. (that is done in "getSignatureHelpItems")
359+ // i.e
360+ // export function MainButton(props: ButtonProps, context: any): JSX.Element { ... }
361+ // <MainBuntton /*signatureHelp*/
362+ const attributeSpanStart = node . parent . attributes . getFullStart ( ) ;
363+ const attributeSpanEnd = skipTrivia ( sourceFile . text , node . parent . attributes . getEnd ( ) , /*stopAfterLineBreak*/ false ) ;
364+ return {
365+ kind : ArgumentListKind . JSXAttributesArguments ,
366+ invocation : node . parent ,
367+ argumentsSpan : createTextSpan ( attributeSpanStart , attributeSpanEnd - attributeSpanStart ) ,
368+ argumentIndex : 0 ,
369+ argumentCount : 1
370+ } ;
371+ }
355372
356373 return undefined ;
357374 }
@@ -392,7 +409,7 @@ namespace ts.SignatureHelp {
392409 //
393410 // Note: this subtlety only applies to the last comma. If you had "Foo(a,," then
394411 // we'll have: 'a' '<comma>' '<missing>'
395- // That will give us 2 non-commas. We then add one for the last comma, givin us an
412+ // That will give us 2 non-commas. We then add one for the last comma, giving us an
396413 // arg count of 3.
397414 const listChildren = argumentsList . getChildren ( ) ;
398415
@@ -435,7 +452,6 @@ namespace ts.SignatureHelp {
435452 : ( < TemplateExpression > tagExpression . template ) . templateSpans . length + 1 ;
436453
437454 Debug . assert ( argumentIndex === 0 || argumentIndex < argumentCount , `argumentCount < argumentIndex, ${ argumentCount } < ${ argumentIndex } ` ) ;
438-
439455 return {
440456 kind : ArgumentListKind . TaggedTemplateArguments ,
441457 invocation : tagExpression ,
0 commit comments