@@ -7669,38 +7669,37 @@ namespace ts {
7669
7669
return props[0];
7670
7670
}
7671
7671
let declarations: Declaration[] | undefined;
7672
- let commonType : Type | undefined;
7672
+ let firstType : Type | undefined;
7673
7673
let nameType: Type | undefined;
7674
7674
const propTypes: Type[] = [];
7675
- let first = true;
7676
- let commonValueDeclaration: Declaration | undefined;
7675
+ let firstValueDeclaration: Declaration | undefined;
7677
7676
let hasNonUniformValueDeclaration = false;
7678
7677
for (const prop of props) {
7679
- if (!commonValueDeclaration ) {
7680
- commonValueDeclaration = prop.valueDeclaration;
7678
+ if (!firstValueDeclaration ) {
7679
+ firstValueDeclaration = prop.valueDeclaration;
7681
7680
}
7682
- else if (prop.valueDeclaration !== commonValueDeclaration ) {
7681
+ else if (prop.valueDeclaration !== firstValueDeclaration ) {
7683
7682
hasNonUniformValueDeclaration = true;
7684
7683
}
7685
7684
declarations = addRange(declarations, prop.declarations);
7686
7685
const type = getTypeOfSymbol(prop);
7687
- if (first ) {
7688
- commonType = type;
7686
+ if (!firstType ) {
7687
+ firstType = type;
7689
7688
nameType = prop.nameType;
7690
- first = false;
7691
7689
}
7692
- else {
7693
- if (type !== commonType) {
7694
- checkFlags |= CheckFlags.HasNonUniformType;
7695
- }
7690
+ else if (type !== firstType) {
7691
+ checkFlags |= CheckFlags.HasNonUniformType;
7692
+ }
7693
+ if (isLiteralType(type)) {
7694
+ checkFlags |= CheckFlags.HasLiteralType;
7696
7695
}
7697
7696
propTypes.push(type);
7698
7697
}
7699
7698
addRange(propTypes, indexTypes);
7700
7699
const result = createSymbol(SymbolFlags.Property | commonFlags, name, syntheticFlag | checkFlags);
7701
7700
result.containingType = containingType;
7702
- if (!hasNonUniformValueDeclaration && commonValueDeclaration ) {
7703
- result.valueDeclaration = commonValueDeclaration ;
7701
+ if (!hasNonUniformValueDeclaration && firstValueDeclaration ) {
7702
+ result.valueDeclaration = firstValueDeclaration ;
7704
7703
}
7705
7704
result.declarations = declarations!;
7706
7705
result.nameType = nameType;
@@ -14814,25 +14813,18 @@ namespace ts {
14814
14813
}
14815
14814
14816
14815
function isDiscriminantType(type: Type): boolean {
14817
- if (type.flags & TypeFlags.Union) {
14818
- if (type.flags & (TypeFlags.Boolean | TypeFlags.EnumLiteral)) {
14819
- return true;
14820
- }
14821
- let combined = 0;
14822
- for (const t of (<UnionType>type).types) combined |= t.flags;
14823
- if (combined & TypeFlags.Unit && !(combined & TypeFlags.Instantiable)) {
14824
- return true;
14825
- }
14826
- }
14827
- return false;
14816
+ return !!(type.flags & TypeFlags.Union &&
14817
+ (type.flags & (TypeFlags.Boolean | TypeFlags.EnumLiteral) || !isGenericIndexType(type)));
14828
14818
}
14829
14819
14830
14820
function isDiscriminantProperty(type: Type | undefined, name: __String) {
14831
14821
if (type && type.flags & TypeFlags.Union) {
14832
14822
const prop = getUnionOrIntersectionProperty(<UnionType>type, name);
14833
14823
if (prop && getCheckFlags(prop) & CheckFlags.SyntheticProperty) {
14834
14824
if ((<TransientSymbol>prop).isDiscriminantProperty === undefined) {
14835
- (<TransientSymbol>prop).isDiscriminantProperty = !!((<TransientSymbol>prop).checkFlags & CheckFlags.HasNonUniformType) && isDiscriminantType(getTypeOfSymbol(prop));
14825
+ (<TransientSymbol>prop).isDiscriminantProperty =
14826
+ ((<TransientSymbol>prop).checkFlags & CheckFlags.Discriminant) === CheckFlags.Discriminant &&
14827
+ isDiscriminantType(getTypeOfSymbol(prop));
14836
14828
}
14837
14829
return !!(<TransientSymbol>prop).isDiscriminantProperty;
14838
14830
}
0 commit comments