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:
parent
ed69a8a161
commit
f0b210cb59
1 changed files with 3 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue