Skip to content

Commit b12d5c5

Browse files
authored
fix(46605): show completions in object literal parameters (microsoft#46743)
1 parent 416571c commit b12d5c5

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/services/completions.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3529,6 +3529,7 @@ namespace ts.Completions {
35293529
// function f<T>(x: T) {}
35303530
// f({ abc/**/: "" }) // `abc` is a member of `T` but only because it declares itself
35313531
function hasDeclarationOtherThanSelf(member: Symbol) {
3532+
if (!length(member.declarations)) return true;
35323533
return some(member.declarations, decl => decl.parent !== obj);
35333534
}
35343535
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
////const foo = {
4+
//// a: "a",
5+
//// b: "b"
6+
////};
7+
////function fn<T extends { [key: string]: any }>(obj: T, events: { [Key in `on_${string & keyof T}`]?: Key }) {}
8+
////
9+
////fn(foo, {
10+
//// /*1*/
11+
////})
12+
////fn({ a: "a", b: "b" }, {
13+
//// /*2*/
14+
////})
15+
16+
verify.completions({
17+
marker: ["1", "2"],
18+
exact: [
19+
{ name: "on_a", sortText: completion.SortText.OptionalMember },
20+
{ name: "on_b", sortText: completion.SortText.OptionalMember }
21+
]
22+
});

0 commit comments

Comments
 (0)