fix(46605): show completions in object literal parameters (#46743)
This commit is contained in:
parent
416571ca90
commit
b12d5c5dc5
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
22
tests/cases/fourslash/completionListInObjectLiteral6.ts
Normal file
22
tests/cases/fourslash/completionListInObjectLiteral6.ts
Normal file
|
@ -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 }
|
||||
]
|
||||
});
|
Loading…
Reference in a new issue