mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Allow discriminant property to contain some non-unit types
This commit is contained in:
parent
07966dcb12
commit
d0698751ce
@ -12919,6 +12919,10 @@ namespace ts {
|
||||
isUnitType(type);
|
||||
}
|
||||
|
||||
function maybeUnitType(type: Type): boolean {
|
||||
return type.flags & TypeFlags.Union ? some((<UnionType>type).types, isUnitType) : isUnitType(type);
|
||||
}
|
||||
|
||||
function getBaseTypeOfLiteralType(type: Type): Type {
|
||||
return type.flags & TypeFlags.EnumLiteral ? getBaseTypeOfEnumLiteralType(<LiteralType>type) :
|
||||
type.flags & TypeFlags.StringLiteral ? stringType :
|
||||
@ -14217,7 +14221,7 @@ namespace ts {
|
||||
const prop = getUnionOrIntersectionProperty(<UnionType>type, name);
|
||||
if (prop && getCheckFlags(prop) & CheckFlags.SyntheticProperty) {
|
||||
if ((<TransientSymbol>prop).isDiscriminantProperty === undefined) {
|
||||
(<TransientSymbol>prop).isDiscriminantProperty = !!((<TransientSymbol>prop).checkFlags & CheckFlags.HasNonUniformType) && isLiteralType(getTypeOfSymbol(prop));
|
||||
(<TransientSymbol>prop).isDiscriminantProperty = !!((<TransientSymbol>prop).checkFlags & CheckFlags.HasNonUniformType) && maybeUnitType(getTypeOfSymbol(prop));
|
||||
}
|
||||
return !!(<TransientSymbol>prop).isDiscriminantProperty;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user