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 {
3789
3789
// other than those within the declared type.
3790
3790
isNewIdentifierLocation = true ;
3791
3791
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.
3792
3794
typeForObject = typeChecker . getContextualType ( < ObjectLiteralExpression > objectLikeContainer ) ;
3795
+ typeForObject = typeForObject && typeForObject . getNonNullableType ( ) ;
3796
+
3793
3797
existingMembers = ( < ObjectLiteralExpression > objectLikeContainer ) . properties ;
3794
3798
}
3795
3799
else if ( objectLikeContainer . kind === SyntaxKind . ObjectBindingPattern ) {
@@ -3801,7 +3805,7 @@ namespace ts {
3801
3805
// We don't want to complete using the type acquired by the shape
3802
3806
// of the binding pattern; we are only interested in types acquired
3803
3807
// 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 -
3805
3809
// type of parameter will flow in from the contextual type of the function
3806
3810
let canGetType = ! ! ( rootDeclaration . initializer || rootDeclaration . type ) ;
3807
3811
if ( ! canGetType && rootDeclaration . kind === SyntaxKind . Parameter ) {
You can’t perform that action at this time.
0 commit comments