File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -3504,7 +3504,11 @@ namespace ts {
3504
3504
// We don't want to complete using the type acquired by the shape
3505
3505
// of the binding pattern; we are only interested in types acquired
3506
3506
// through type declaration or inference.
3507
- if ( rootDeclaration . initializer || rootDeclaration . type ) {
3507
+ // Also proceed if rootDeclaration is parameter and if its containing function expression\arrow function is contextually typed -
3508
+ // type of parameter will flow in from the contextual type of the function
3509
+ if ( rootDeclaration . initializer ||
3510
+ rootDeclaration . type ||
3511
+ ( rootDeclaration . kind === SyntaxKind . Parameter && isExpression ( rootDeclaration . parent ) && typeChecker . getContextualType ( < Expression > rootDeclaration . parent ) ) ) {
3508
3512
typeForObject = typeChecker . getTypeAtLocation ( objectLikeContainer ) ;
3509
3513
existingMembers = ( < BindingPattern > objectLikeContainer ) . elements ;
3510
3514
}
Original file line number Diff line number Diff line change
1
+ /// <reference path="fourslash.ts"/>
2
+
3
+ ////interface I { x1: number; x2: string }
4
+ ////function f(cb: (ev: I) => any) { }
5
+ ////f(({/*1*/}) => 0);
6
+
7
+ ////[<I>null].reduce(({/*2*/}, b) => b);
8
+
9
+ goTo . marker ( "1" ) ;
10
+ verify . completionListContains ( "x1" ) ;
11
+ verify . completionListContains ( "x2" ) ;
12
+
13
+ goTo . marker ( "2" ) ;
14
+ verify . completionListContains ( "x1" ) ;
15
+ verify . completionListContains ( "x2" ) ;
You can’t perform that action at this time.
0 commit comments