Skip to content

Commit

Permalink
Remove null and undefined from apparent contextual types
Browse files Browse the repository at this point in the history
  • Loading branch information
ahejlsberg committed Apr 30, 2024
1 parent 5c682f6 commit 8d4f369
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30879,7 +30879,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// That would evaluate mapped types with array or tuple type constraints too eagerly
// and thus it would prevent `getTypeOfPropertyOfContextualType` from obtaining per-position contextual type for elements of array literal expressions.
// Apparent type of other mapped types is already the mapped type itself so we can just avoid calling `getApparentType` here for all mapped types.
t => getObjectFlags(t) & ObjectFlags.Mapped ? t : getApparentType(t),
t => t.flags & TypeFlags.Nullable ? neverType : getObjectFlags(t) & ObjectFlags.Mapped ? t : getApparentType(t),
/*noReductions*/ true,
);
return apparentType.flags & TypeFlags.Union && isObjectLiteralExpression(node) ? discriminateContextualTypeByObjectMembers(node, apparentType as UnionType) :
Expand Down

0 comments on commit 8d4f369

Please sign in to comment.