Detect non-tag uses of <
in TSX completions
This commit is contained in:
parent
58b8a54e5f
commit
aa5c88f5a6
2 changed files with 37 additions and 7 deletions
|
@ -915,13 +915,29 @@ namespace ts.Completions {
|
|||
}
|
||||
}
|
||||
else if (sourceFile.languageVariant === LanguageVariant.JSX) {
|
||||
switch (contextToken.parent.kind) {
|
||||
case SyntaxKind.JsxClosingElement:
|
||||
if (kind === SyntaxKind.SlashToken) {
|
||||
isStartingCloseTag = true;
|
||||
location = contextToken;
|
||||
}
|
||||
break;
|
||||
|
||||
case SyntaxKind.BinaryExpression:
|
||||
if (!((contextToken.parent as BinaryExpression).left.flags & NodeFlags.ThisNodeHasError)) {
|
||||
// It has a left-hand side, so we're not in an opening JSX tag.
|
||||
break;
|
||||
}
|
||||
// fall through
|
||||
|
||||
case SyntaxKind.JsxSelfClosingElement:
|
||||
case SyntaxKind.JsxElement:
|
||||
case SyntaxKind.JsxOpeningElement:
|
||||
if (kind === SyntaxKind.LessThanToken) {
|
||||
isRightOfOpenTag = true;
|
||||
location = contextToken;
|
||||
}
|
||||
else if (kind === SyntaxKind.SlashToken && contextToken.parent.kind === SyntaxKind.JsxClosingElement) {
|
||||
isStartingCloseTag = true;
|
||||
location = contextToken;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
14
tests/cases/fourslash/tsxCompletionNonTagLessThan.ts
Normal file
14
tests/cases/fourslash/tsxCompletionNonTagLessThan.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////var x: Array<numb/*a*/;
|
||||
////[].map<numb/*b*/;
|
||||
////1 < Infini/*c*/;
|
||||
|
||||
for (const marker of ["a", "b"]) {
|
||||
goTo.marker(marker);
|
||||
verify.completionListContains("number");
|
||||
verify.not.completionListContains("SVGNumber");
|
||||
};
|
||||
|
||||
goTo.marker("c");
|
||||
verify.completionListContains("Infinity");
|
Loading…
Reference in a new issue