diff --git a/src/services/services.ts b/src/services/services.ts index 85b2bfb58e8a0..6761c487c6cc8 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3823,7 +3823,7 @@ namespace ts { return undefined; } - const { symbols, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot, isJsDocTagName } = completionData; + const { symbols, isMemberCompletion, isNewIdentifierLocation, location, isJsDocTagName } = completionData; if (isJsDocTagName) { // If the current position is a jsDoc tag name, only tag names should be provided for completion @@ -3834,7 +3834,7 @@ namespace ts { const entries: CompletionEntry[] = []; - if (isRightOfDot && isSourceFileJavaScript(sourceFile)) { + if (isSourceFileJavaScript(sourceFile)) { const uniqueNames = getCompletionEntriesFromSymbols(symbols, entries); addRange(entries, getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames)); } diff --git a/tests/cases/fourslash/getJavaScriptGlobalCompletions1.ts b/tests/cases/fourslash/getJavaScriptGlobalCompletions1.ts new file mode 100644 index 0000000000000..240df24bf5233 --- /dev/null +++ b/tests/cases/fourslash/getJavaScriptGlobalCompletions1.ts @@ -0,0 +1,15 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: Foo.js +//// function f() { +//// // helloWorld leaks from here into the global space? +//// if (helloWorld) { +//// return 3; +//// } +//// return 5; +//// } +//// +//// hello/**/ + +verify.completionListContains('helloWorld');