mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-13 06:20:23 -06:00
Fix both new enum assignability predicates
And update error reporting baseline (new error is less elaborate)
This commit is contained in:
parent
083f3426d1
commit
90d685b737
@ -6226,13 +6226,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…
x
Reference in New Issue
Block a user