Implement fix for this type comparison false positive

Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-07-15 03:59:49 +00:00
parent 6355df5d95
commit c3df353a8d
5 changed files with 262 additions and 5 deletions

View File

@@ -22143,11 +22143,26 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
(source as NumberLiteralType).value === (target as NumberLiteralType).value
) return true;
if (s & TypeFlags.BigIntLike && t & TypeFlags.BigInt) return true;
if (s & TypeFlags.BooleanLike && t & TypeFlags.Boolean) return true;
if (s & TypeFlags.ESSymbolLike && t & TypeFlags.ESSymbol) return true;
if (
s & TypeFlags.Enum && t & TypeFlags.Enum && source.symbol.escapedName === target.symbol.escapedName &&
isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)
if (s & TypeFlags.BooleanLike && t & TypeFlags.Boolean) return true;
if (s & TypeFlags.ESSymbolLike && t & TypeFlags.ESSymbol) return true;
// For comparable relation, revert `this` type parameters back to their constrained class type
if (relation === comparableRelation) {
if (s & TypeFlags.TypeParameter && (source as TypeParameter).isThisType) {
const constraint = getConstraintOfTypeParameter(source as TypeParameter);
if (constraint && isTypeRelatedTo(constraint, target, relation)) {
return true;
}
}
if (t & TypeFlags.TypeParameter && (target as TypeParameter).isThisType) {
const constraint = getConstraintOfTypeParameter(target as TypeParameter);
if (constraint && isTypeRelatedTo(source, constraint, relation)) {
return true;
}
}
}
if (
s & TypeFlags.Enum && t & TypeFlags.Enum && source.symbol.escapedName === target.symbol.escapedName &&
isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)
) return true;
if (s & TypeFlags.EnumLiteral && t & TypeFlags.EnumLiteral) {
if (s & TypeFlags.Union && t & TypeFlags.Union && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter)) return true;