diff --git a/src/services/completions.ts b/src/services/completions.ts index cd4d64b3b09..3b76fdc8c3b 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1082,6 +1082,7 @@ namespace ts.Completions { isGlobalCompletion = scopeNode.kind === SyntaxKind.SourceFile || scopeNode.kind === SyntaxKind.TemplateExpression || + scopeNode.kind === SyntaxKind.JsxExpression || isStatement(scopeNode); } diff --git a/tests/cases/fourslash/completionListIsGlobalCompletion.ts b/tests/cases/fourslash/completionListIsGlobalCompletion.ts index 3961f4fadae..a1fadc6bb12 100644 --- a/tests/cases/fourslash/completionListIsGlobalCompletion.ts +++ b/tests/cases/fourslash/completionListIsGlobalCompletion.ts @@ -33,6 +33,7 @@ ////const y =
; // no globals in jsx attribute found ////const z = ; // no globals in jsx attribute with syntax error ////const x = `/*14*/ ${/*15*/}`; // globals only in template expression +////var user = *16*/User name=/*17*/{ /*18*/window.isLoggedIn ? window.name : '/*19*/'} />; // globals only in JSX expression (but not in JSX expression strings) goTo.marker("1"); verify.completionListIsGlobal(false); goTo.marker("2"); @@ -62,4 +63,12 @@ verify.completionListIsGlobal(false); goTo.marker("14"); verify.completionListIsGlobal(false); goTo.marker("15"); -verify.completionListIsGlobal(true); \ No newline at end of file +verify.completionListIsGlobal(true); +goTo.marker("16"); +verify.completionListIsGlobal(false); +goTo.marker("17"); +verify.completionListIsGlobal(false); +goTo.marker("18"); +verify.completionListIsGlobal(true); +goTo.marker("19"); +verify.completionListIsGlobal(false); \ No newline at end of file