File tree 2 files changed +24
-2
lines changed
2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -3913,9 +3913,14 @@ namespace ts.Completions {
3913
3913
if ( type ) {
3914
3914
return type ;
3915
3915
}
3916
- if ( isBinaryExpression ( node . parent ) && node . parent . operatorToken . kind === SyntaxKind . EqualsToken && node === node . parent . left ) {
3916
+ const parent = walkUpParenthesizedExpressions ( node . parent ) ;
3917
+ if ( isBinaryExpression ( parent ) && parent . operatorToken . kind === SyntaxKind . EqualsToken && node === parent . left ) {
3917
3918
// Object literal is assignment pattern: ({ | } = x)
3918
- return typeChecker . getTypeAtLocation ( node . parent ) ;
3919
+ return typeChecker . getTypeAtLocation ( parent ) ;
3920
+ }
3921
+ if ( isExpression ( parent ) ) {
3922
+ // f(() => (({ | })));
3923
+ return typeChecker . getContextualType ( parent ) ;
3919
3924
}
3920
3925
return undefined ;
3921
3926
}
Original file line number Diff line number Diff line change
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
+ } ) ;
You can’t perform that action at this time.
0 commit comments