mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-08 22:29:37 -05:00
Number is assignable to enum, even inside union
Previously, numbers were not assignable to enums that were inside a union
This commit is contained in:
@@ -6227,6 +6227,9 @@ namespace ts {
|
||||
if (relation === assignableRelation || relation === comparableRelation) {
|
||||
if (source.flags & TypeFlags.Any) return true;
|
||||
if (source.flags & (TypeFlags.Number | TypeFlags.NumberLiteral) && target.flags & TypeFlags.Enum) return true;
|
||||
if (source.flags & (TypeFlags.Number | TypeFlags.NumberLiteral) &&
|
||||
target.flags & TypeFlags.Union &&
|
||||
forEach((target as UnionType).types, t => t.flags & TypeFlags.EnumLike)) return true;
|
||||
if (source.flags & TypeFlags.NumberLiteral && target.flags & TypeFlags.EnumLiteral && (<LiteralType>source).text === (<LiteralType>target).text) return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user