File tree Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Expand file tree Collapse file tree 2 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -3506,9 +3506,16 @@ namespace ts {
3506
3506
// through type declaration or inference.
3507
3507
// Also proceed if rootDeclaration is parameter and if its containing function expression\arrow function is contextually typed -
3508
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 ) ) ) {
3509
+ let canGetType = ! ! ( rootDeclaration . initializer || rootDeclaration . type ) ;
3510
+ if ( ! canGetType && rootDeclaration . kind === SyntaxKind . Parameter ) {
3511
+ if ( isExpression ( rootDeclaration . parent ) ) {
3512
+ canGetType = ! ! typeChecker . getContextualType ( < Expression > rootDeclaration . parent ) ;
3513
+ }
3514
+ else if ( rootDeclaration . parent . kind === SyntaxKind . MethodDeclaration || rootDeclaration . parent . kind === SyntaxKind . SetAccessor ) {
3515
+ canGetType = isExpression ( rootDeclaration . parent . parent ) && ! ! typeChecker . getContextualType ( < Expression > rootDeclaration . parent . parent ) ;
3516
+ }
3517
+ }
3518
+ if ( canGetType ) {
3512
3519
typeForObject = typeChecker . getTypeAtLocation ( objectLikeContainer ) ;
3513
3520
existingMembers = ( < BindingPattern > objectLikeContainer ) . elements ;
3514
3521
}
Original file line number Diff line number Diff line change 6
6
7
7
////[<I>null].reduce(({/*2*/}, b) => b);
8
8
9
+ ////interface Foo {
10
+ //// m(x: { x1: number, x2: number }): void;
11
+ //// prop: I;
12
+ //// }
13
+ ////let x: Foo = {
14
+ //// m({ /*3*/ }) {
15
+ //// },
16
+ //// get prop(): I { return undefined; },
17
+ //// set prop({ /*4*/ }) {
18
+ //// }
19
+ //// };
20
+
9
21
goTo . marker ( "1" ) ;
10
22
verify . completionListContains ( "x1" ) ;
11
23
verify . completionListContains ( "x2" ) ;
12
24
13
25
goTo . marker ( "2" ) ;
14
26
verify . completionListContains ( "x1" ) ;
27
+ verify . completionListContains ( "x2" ) ;
28
+
29
+ goTo . marker ( "3" ) ;
30
+ verify . completionListContains ( "x1" ) ;
31
+ verify . completionListContains ( "x2" ) ;
32
+
33
+ goTo . marker ( "4" ) ;
34
+ verify . completionListContains ( "x1" ) ;
15
35
verify . completionListContains ( "x2" ) ;
You can’t perform that action at this time.
0 commit comments