Fix both new enum assignability predicates
And update error reporting baseline (new error is less elaborate)
This commit is contained in:
parent
bf3941da47
commit
a0c3d4f306
2 changed files with 10 additions and 10 deletions
|
@ -6220,13 +6220,15 @@ namespace ts {
|
|||
if (source.flags & TypeFlags.Null && (!strictNullChecks || target.flags & TypeFlags.Null)) return true;
|
||||
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 | TypeFlags.EnumLiteral) &&
|
||||
if (source.flags & (TypeFlags.Number | TypeFlags.NumberLiteral) && target.flags & TypeFlags.EnumLike) return true;
|
||||
if (source.flags & TypeFlags.NumberLiteral && target.flags & TypeFlags.EnumLiteral && (<LiteralType>source).text === (<LiteralType>target).text) return true;
|
||||
if (source.flags & TypeFlags.EnumLiteral &&
|
||||
target.flags & TypeFlags.EnumLiteral &&
|
||||
(<LiteralType>source).text === (<LiteralType>target).text) return true;
|
||||
(<LiteralType>source).text === (<LiteralType>target).text &&
|
||||
(<EnumLiteralType>source).baseType.symbol.name === (<EnumLiteralType>target).baseType.symbol.name &&
|
||||
!isConstEnumSymbol((<EnumLiteralType>source).baseType.symbol) && !isConstEnumSymbol((<EnumLiteralType>target).baseType.symbol)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
tests/cases/compiler/enumAssignmentCompat3.ts(68,1): error TS2322: Type 'Abcd.E' is not assignable to type 'First.E'.
|
||||
Property 'd' is missing in type 'First.E'.
|
||||
tests/cases/compiler/enumAssignmentCompat3.ts(70,1): error TS2322: Type 'Cd.E' is not assignable to type 'First.E'.
|
||||
Property 'd' is missing in type 'First.E'.
|
||||
tests/cases/compiler/enumAssignmentCompat3.ts(70,1): error TS2324: Property 'd' is missing in type 'First.E'.
|
||||
tests/cases/compiler/enumAssignmentCompat3.ts(71,1): error TS2322: Type 'Nope' is not assignable to type 'E'.
|
||||
tests/cases/compiler/enumAssignmentCompat3.ts(75,1): error TS2322: Type 'First.E' is not assignable to type 'Ab.E'.
|
||||
Property 'c' is missing in type 'Ab.E'.
|
||||
|
@ -89,8 +88,7 @@ tests/cases/compiler/enumAssignmentCompat3.ts(86,1): error TS2322: Type 'Merged.
|
|||
abc = secondAb; // ok
|
||||
abc = secondCd; // missing 'd'
|
||||
~~~
|
||||
!!! error TS2322: Type 'Cd.E' is not assignable to type 'First.E'.
|
||||
!!! error TS2322: Property 'd' is missing in type 'First.E'.
|
||||
!!! error TS2324: Property 'd' is missing in type 'First.E'.
|
||||
abc = nope; // nope!
|
||||
~~~
|
||||
!!! error TS2322: Type 'Nope' is not assignable to type 'E'.
|
||||
|
|
Loading…
Reference in a new issue