Skip to content

Commit f979d62

Browse files
committed
fix(47081): show completion list in parenthesized object literal arguments
1 parent df87a8c commit f979d62

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/services/completions.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3754,6 +3754,12 @@ namespace ts.Completions {
37543754
// Object literal is assignment pattern: ({ | } = x)
37553755
return typeChecker.getTypeAtLocation(node.parent);
37563756
}
3757+
if (isParenthesizedExpression(node.parent)) {
3758+
const parent = walkUpParenthesizedExpressions(node.parent);
3759+
if (isExpression(parent)) {
3760+
return typeChecker.getContextualType(parent);
3761+
}
3762+
}
37573763
return undefined;
37583764
}
37593765

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
////type Foo = { foo: boolean };
4+
////function f<T>(shape: Foo): any;
5+
////function f<T>(shape: () => Foo): any;
6+
////function f(arg: any) {
7+
//// return arg;
8+
////}
9+
////
10+
////f({ /*1*/ });
11+
////f(() => ({ /*2*/ }));
12+
////f(() => (({ /*3*/ })));
13+
14+
verify.completions({
15+
marker: ["1", "2", "3"],
16+
exact: ["foo"]
17+
});

0 commit comments

Comments
 (0)