Skip to content

Commit 8d4f369

Browse files
committed
Remove null and undefined from apparent contextual types
1 parent 5c682f6 commit 8d4f369

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30879,7 +30879,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3087930879
// That would evaluate mapped types with array or tuple type constraints too eagerly
3088030880
// and thus it would prevent `getTypeOfPropertyOfContextualType` from obtaining per-position contextual type for elements of array literal expressions.
3088130881
// Apparent type of other mapped types is already the mapped type itself so we can just avoid calling `getApparentType` here for all mapped types.
30882-
t => getObjectFlags(t) & ObjectFlags.Mapped ? t : getApparentType(t),
30882+
t => t.flags & TypeFlags.Nullable ? neverType : getObjectFlags(t) & ObjectFlags.Mapped ? t : getApparentType(t),
3088330883
/*noReductions*/ true,
3088430884
);
3088530885
return apparentType.flags & TypeFlags.Union && isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType as UnionType) :

0 commit comments

Comments
 (0)