Offer JSX attribute intellisense between string-literal props

and the closing tag. Fixes #4098
This commit is contained in:
Ryan Cavanaugh 2015-07-31 00:36:47 -07:00
parent 7e9e920d1e
commit f224b5022e
2 changed files with 28 additions and 5 deletions

View File

@ -3392,16 +3392,24 @@ namespace ts {
case SyntaxKind.LessThanSlashToken:
case SyntaxKind.SlashToken:
case SyntaxKind.Identifier:
if(parent && (parent.kind === SyntaxKind.JsxSelfClosingElement || parent.kind === SyntaxKind.JsxOpeningElement)) {
case SyntaxKind.JsxAttribute:
if (parent && (parent.kind === SyntaxKind.JsxSelfClosingElement || parent.kind === SyntaxKind.JsxOpeningElement)) {
return <JsxOpeningLikeElement>parent;
}
break;
// The context token is the closing } or " of an attribute, which means
// its parent is a JsxExpression, whose parent is a JsxAttribute,
// whose parent is a JsxOpeningLikeElement
case SyntaxKind.StringLiteral:
if (parent && parent.kind === SyntaxKind.JsxAttribute) {
return <JsxOpeningLikeElement>parent.parent;
}
break;
case SyntaxKind.CloseBraceToken:
// The context token is the closing } of an attribute, which means
// its parent is a JsxExpression, whose parent is a JsxAttribute,
// whose parent is a JsxOpeningLikeElement
if(parent &&
if (parent &&
parent.kind === SyntaxKind.JsxExpression &&
parent.parent &&
parent.parent.kind === SyntaxKind.JsxAttribute) {

View File

@ -0,0 +1,15 @@
/// <reference path='fourslash.ts' />
//@Filename: file.tsx
//// declare module JSX {
//// interface Element { }
//// interface IntrinsicElements {
//// div: { ONE: string; TWO: number; }
//// }
//// }
//// var x = <div ONE='hello' /**/ />;
goTo.marker();
verify.completionListContains("TWO");
verify.not.completionListAllowsNewIdentifier();