Skip to content

Commit

Permalink
Prefer global over object members completions after ... (#57542)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Feb 27, 2024
1 parent 65de938 commit df8d755
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/services/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4322,6 +4322,7 @@ function getCompletionData(
* @returns true if 'symbols' was successfully populated; false otherwise.
*/
function tryGetObjectLikeCompletionSymbols(): GlobalsSearch | undefined {
if (contextToken?.kind === SyntaxKind.DotDotDotToken) return GlobalsSearch.Continue;
const symbolsStartIndex = symbols.length;
const objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken, position, sourceFile);
if (!objectLikeContainer) return GlobalsSearch.Continue;
Expand Down
15 changes: 15 additions & 0 deletions tests/cases/fourslash/completionsDotDotDotInObjectLiteral1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/// <reference path="fourslash.ts" />

//// // https://github.com/microsoft/TypeScript/issues/57540
////
//// const foo = { b: 100 };
////
//// const bar: {
//// a: number;
//// b: number;
//// } = {
//// a: 42,
//// .../*1*/
//// };

verify.completions({ marker: "1", includes: ["foo"], excludes: ["b"] });

0 comments on commit df8d755

Please sign in to comment.