mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Offer JSX attribute intellisense between string-literal props
and the closing tag. Fixes #4098
This commit is contained in:
parent
7e9e920d1e
commit
f224b5022e
@ -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) {
|
||||
|
||||
15
tests/cases/fourslash/tsxCompletion6.ts
Normal file
15
tests/cases/fourslash/tsxCompletion6.ts
Normal 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();
|
||||
Loading…
x
Reference in New Issue
Block a user