@@ -34206,8 +34206,8 @@ namespace ts {
34206
34206
function isLiteralOfContextualType(candidateType: Type, contextualType: Type | undefined): boolean {
34207
34207
if (contextualType) {
34208
34208
if (contextualType.flags & TypeFlags.UnionOrIntersection) {
34209
- const types = (contextualType as UnionType).types ;
34210
- return some(types, t => isLiteralOfContextualType(candidateType, t));
34209
+ const skipBooleanLiterals = containsBooleanType (contextualType) ;
34210
+ return some((contextualType as UnionType). types, t => !(skipBooleanLiterals && t.flags & TypeFlags.BooleanLiteral) && isLiteralOfContextualType(candidateType, t));
34211
34211
}
34212
34212
if (contextualType.flags & TypeFlags.InstantiableNonPrimitive) {
34213
34213
// If the contextual type is a type variable constrained to a primitive type, consider
@@ -34217,6 +34217,7 @@ namespace ts {
34217
34217
return maybeTypeOfKind(constraint, TypeFlags.String) && maybeTypeOfKind(candidateType, TypeFlags.StringLiteral) ||
34218
34218
maybeTypeOfKind(constraint, TypeFlags.Number) && maybeTypeOfKind(candidateType, TypeFlags.NumberLiteral) ||
34219
34219
maybeTypeOfKind(constraint, TypeFlags.BigInt) && maybeTypeOfKind(candidateType, TypeFlags.BigIntLiteral) ||
34220
+ containsBooleanType(constraint) && maybeTypeOfKind(candidateType, TypeFlags.BooleanLiteral) ||
34220
34221
maybeTypeOfKind(constraint, TypeFlags.ESSymbol) && maybeTypeOfKind(candidateType, TypeFlags.UniqueESSymbol) ||
34221
34222
isLiteralOfContextualType(candidateType, constraint);
34222
34223
}
@@ -34231,6 +34232,10 @@ namespace ts {
34231
34232
return false;
34232
34233
}
34233
34234
34235
+ function containsBooleanType(type: Type) {
34236
+ return !!(type.flags & TypeFlags.Union) && containsType((type as UnionType).types, regularFalseType) && containsType((type as UnionType).types, regularTrueType);
34237
+ }
34238
+
34234
34239
function isConstContext(node: Expression): boolean {
34235
34240
const parent = node.parent;
34236
34241
return isAssertionExpression(parent) && isConstTypeReference(parent.type) ||
0 commit comments