fix(46605): show completions in object literal parameters (#46743)

This commit is contained in:
Oleksandr T 2021-11-10 00:50:26 +02:00 committed by GitHub
parent 416571ca90
commit b12d5c5dc5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View file

@ -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);
}
}

View 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 }
]
});