Skip to content

Commit

Permalink
fix(46605): show completions in object literal parameters (#46743)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk authored Nov 9, 2021
1 parent 416571c commit b12d5c5
Show file tree
Hide file tree
Showing 2 changed files with 23 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 @@ -3529,6 +3529,7 @@ namespace ts.Completions {
// function f<T>(x: T) {}
// f({ abc/**/: "" }) // `abc` is a member of `T` but only because it declares itself
function hasDeclarationOtherThanSelf(member: Symbol) {
if (!length(member.declarations)) return true;
return some(member.declarations, decl => decl.parent !== obj);
}
}
Expand Down
22 changes: 22 additions & 0 deletions tests/cases/fourslash/completionListInObjectLiteral6.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/// <reference path='fourslash.ts'/>

////const foo = {
//// a: "a",
//// b: "b"
////};
////function fn<T extends { [key: string]: any }>(obj: T, events: { [Key in `on_${string & keyof T}`]?: Key }) {}
////
////fn(foo, {
//// /*1*/
////})
////fn({ a: "a", b: "b" }, {
//// /*2*/
////})

verify.completions({
marker: ["1", "2"],
exact: [
{ name: "on_a", sortText: completion.SortText.OptionalMember },
{ name: "on_b", sortText: completion.SortText.OptionalMember }
]
});

0 comments on commit b12d5c5

Please sign in to comment.