Skip to content

Commit dba0337

Browse files
committed
Adding JSXExpression check for isGlobalCompletion and associated tests
1 parent a69fc67 commit dba0337

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/services/completions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,7 @@ namespace ts.Completions {
10821082
isGlobalCompletion =
10831083
scopeNode.kind === SyntaxKind.SourceFile ||
10841084
scopeNode.kind === SyntaxKind.TemplateExpression ||
1085+
scopeNode.kind === SyntaxKind.JsxExpression ||
10851086
isStatement(scopeNode);
10861087
}
10871088

tests/cases/fourslash/completionListIsGlobalCompletion.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
////const y = <div /*12*/ />; // no globals in jsx attribute found
3434
////const z = <div =/*13*/ />; // no globals in jsx attribute with syntax error
3535
////const x = `/*14*/ ${/*15*/}`; // globals only in template expression
36+
////var user = </*16*/User name=/*17*/{ /*18*/window.isLoggedIn ? window.name : '/*19*/'} />; // globals only in JSX expression (but not in JSX expression strings)
3637
goTo.marker("1");
3738
verify.completionListIsGlobal(false);
3839
goTo.marker("2");
@@ -62,4 +63,12 @@ verify.completionListIsGlobal(false);
6263
goTo.marker("14");
6364
verify.completionListIsGlobal(false);
6465
goTo.marker("15");
65-
verify.completionListIsGlobal(true);
66+
verify.completionListIsGlobal(true);
67+
goTo.marker("16");
68+
verify.completionListIsGlobal(false);
69+
goTo.marker("17");
70+
verify.completionListIsGlobal(false);
71+
goTo.marker("18");
72+
verify.completionListIsGlobal(true);
73+
goTo.marker("19");
74+
verify.completionListIsGlobal(false);

0 commit comments

Comments
 (0)