Skip to content

Commit

Permalink
Handle intersections in isGenericTypeWithoutNullableConstraint
Browse files Browse the repository at this point in the history
  • Loading branch information
ahejlsberg committed Aug 28, 2022
1 parent 6e8337e commit 40a5fc1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25789,8 +25789,10 @@ namespace ts {
!!(type.flags & TypeFlags.Instantiable && getBaseConstraintOrType(type).flags & (TypeFlags.Nullable | TypeFlags.Union));
}

function isGenericTypeWithoutNullableConstraint(type: Type) {
return !!(type.flags & TypeFlags.Instantiable && !maybeTypeOfKind(getBaseConstraintOrType(type), TypeFlags.Nullable));
function isGenericTypeWithoutNullableConstraint(type: Type): boolean {
return type.flags & TypeFlags.Intersection ?
some((type as IntersectionType).types, isGenericTypeWithoutNullableConstraint) :
!!(type.flags & TypeFlags.Instantiable && !maybeTypeOfKind(getBaseConstraintOrType(type), TypeFlags.Nullable));
}

function hasContextualTypeWithNoGenericTypes(node: Node, checkMode: CheckMode | undefined) {
Expand Down

0 comments on commit 40a5fc1

Please sign in to comment.