Skip to content

Commit 4b84a59

Browse files
committed
fix: use exact to ensure the order of completions
1 parent a91b5e2 commit 4b84a59

5 files changed

+27
-16
lines changed

tests/cases/fourslash/completionPropertyShorthandForObjectLiteral.ts

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
//// declare function f9<T extends {}>(obj: T): void;
1616
//// declare function f10<T extends Empty>(obj: T): void;
1717
//// declare function f11<T extends (Empty | Record<string, any> | {})>(obj: T): void;
18-
//// declare function f12(obj: Object): void;
19-
//// declare function f13<T extends Object>(obj: T): void;
20-
//// declare function f14(obj: Typed): void;
21-
//// declare function f15<T extends (Empty | Object | Typed)>(obj: T): void;
22-
//// declare function f16(obj: Record<number, any>): void;
23-
//// declare function f17(obj: { [key: string]: number, prop: number }): void;
24-
//// declare function f18(obj: { [key: number]: number }): void;
18+
//// declare function f12(obj: Typed): void;
19+
//// declare function f13<T extends (Empty | Typed)>(obj: T): void;
20+
//// declare function f14(obj: { [key: string]: number, prop: number }): void;
21+
//// declare function f15(obj: Record<number, any>): void;
22+
//// declare function f16(obj: { [key: number]: number }): void;
2523

2624
//// f1({f/*1*/});
2725
//// f2({f/*2*/});
@@ -39,11 +37,24 @@
3937
//// f14({f/*14*/});
4038
//// f15({f/*15*/});
4139
//// f16({f/*16*/});
42-
//// f17({f/*17*/});
43-
//// f18({f/*18*/});
4440

41+
const locals = [
42+
...(() => {
43+
const symbols = [];
44+
for (let i = 1; i <= 16; i ++) {
45+
symbols.push(`f${i}`);
46+
}
47+
return symbols;
48+
})(),
49+
"foo"
50+
];
4551
verify.completions(
46-
{ marker: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"], includes: ["foo"]},
47-
{ marker: ["12", "13", "14", "15"], excludes: ["foo"]},
48-
{ marker: ["16", "17", "18"], excludes: ["foo"], isNewIdentifierLocation: true},
52+
// Non-contextual, any, unknown, object, Record<string, ..>, [key: string]: .., Type parameter, etc..
53+
{ marker: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"], exact: completion.globalsPlus(locals)},
54+
// Has named property
55+
{ marker: ["12", "13"], exact: "typed"},
56+
// Has both StringIndexType and named property
57+
{ marker: ["14"], exact: "prop", isNewIdentifierLocation: true},
58+
// NumberIndexType
59+
{ marker: ["15", "16"], exact: [], isNewIdentifierLocation: true},
4960
);

tests/cases/fourslash/completionPropertyShorthandForObjectLiteral2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313

1414
verify.completions({
1515
marker: test.markers(),
16-
includes: ["bar"]
16+
exact: completion.globalsPlus(["foo", "bar", "obj1", "obj2"]),
1717
});

tests/cases/fourslash/completionPropertyShorthandForObjectLiteral3.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77

88
verify.completions({
99
marker: ["1"],
10-
includes: ["bar"]
10+
exact: completion.globalsPlus(["foo", "bar", "obj"])
1111
});

tests/cases/fourslash/completionPropertyShorthandForObjectLiteral4.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77

88
verify.completions({
99
marker: ["1"],
10-
includes: ["bar"]
10+
exact: completion.globalsPlus(["foo", "bar", "obj"])
1111
});

tests/cases/fourslash/completionPropertyShorthandForObjectLiteral5.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88

99
verify.completions({
1010
marker: "",
11-
exact: completion.globalsPlus(['obj']),
11+
exact: completion.globalsPlus(["obj"]),
1212
preferences: { includeCompletionsForModuleExports: true }
1313
});

0 commit comments

Comments
 (0)