File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -3789,7 +3789,11 @@ namespace ts {
37893789 // other than those within the declared type.
37903790 isNewIdentifierLocation = true ;
37913791
3792+ // If the object literal is being assigned to something of type 'null | { hello: string }',
3793+ // it clearly isn't trying to satisfy the 'null' type. So we grab the non-nullable type if possible.
37923794 typeForObject = typeChecker . getContextualType ( < ObjectLiteralExpression > objectLikeContainer ) ;
3795+ typeForObject = typeForObject && typeForObject . getNonNullableType ( ) ;
3796+
37933797 existingMembers = ( < ObjectLiteralExpression > objectLikeContainer ) . properties ;
37943798 }
37953799 else if ( objectLikeContainer . kind === SyntaxKind . ObjectBindingPattern ) {
@@ -3801,7 +3805,7 @@ namespace ts {
38013805 // We don't want to complete using the type acquired by the shape
38023806 // of the binding pattern; we are only interested in types acquired
38033807 // through type declaration or inference.
3804- // Also proceed if rootDeclaration is parameter and if its containing function expression\ arrow function is contextually typed -
3808+ // Also proceed if rootDeclaration is a parameter and if its containing function expression/ arrow function is contextually typed -
38053809 // type of parameter will flow in from the contextual type of the function
38063810 let canGetType = ! ! ( rootDeclaration . initializer || rootDeclaration . type ) ;
38073811 if ( ! canGetType && rootDeclaration . kind === SyntaxKind . Parameter ) {
You can’t perform that action at this time.
0 commit comments