fix jsx completions after attributes (#39859)

closes #39530
This commit is contained in:
Zen
2020-08-14 07:14:12 +08:00
committed by GitHub
parent edc88c51ca
commit 0ed523bb60
2 changed files with 40 additions and 0 deletions

View File

@@ -1038,7 +1038,20 @@ namespace ts.Completions {
}
break;
case SyntaxKind.JsxExpression:
// For `<div foo={true} [||] ></div>`, `parent` will be `{true}` and `previousToken` will be `}`
if (previousToken.kind === SyntaxKind.CloseBraceToken && currentToken.kind === SyntaxKind.GreaterThanToken) {
isJsxIdentifierExpected = true;
}
break;
case SyntaxKind.JsxAttribute:
// For `<div className="x" [||] ></div>`, `parent` will be JsxAttribute and `previousToken` will be its initializer
if ((parent as JsxAttribute).initializer === previousToken &&
previousToken.end < position) {
isJsxIdentifierExpected = true;
break;
}
switch (previousToken.kind) {
case SyntaxKind.EqualsToken:
isJsxInitializer = true;