@@ -1187,7 +1187,7 @@ namespace ts {
1187
1187
}
1188
1188
1189
1189
function resolveSymbol(symbol: Symbol): Symbol {
1190
- return symbol && symbol.flags & SymbolFlags.Alias && !(symbol.flags & (SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace)) ? resolveAlias(symbol) : symbol;
1190
+ return symbol && symbol.flags & SymbolFlags.Alias && !(symbol.flags & (SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace)) ? resolveAlias(symbol) : symbol;
1191
1191
}
1192
1192
1193
1193
function resolveAlias(symbol: Symbol): Symbol {
@@ -7892,25 +7892,21 @@ namespace ts {
7892
7892
}
7893
7893
if (flags & TypeFlags.TypeParameter) {
7894
7894
const constraint = getConstraintOfTypeParameter(<TypeParameter>type);
7895
- return constraint ? getTypeFacts(constraint) : TypeFacts.All ;
7895
+ return getTypeFacts(constraint || emptyObjectType) ;
7896
7896
}
7897
7897
if (flags & TypeFlags.UnionOrIntersection) {
7898
7898
return getTypeFactsOfTypes((<UnionOrIntersectionType>type).types);
7899
7899
}
7900
7900
return TypeFacts.All;
7901
7901
}
7902
7902
7903
- function getTypeWithFacts(type: Type, include: TypeFacts, intersectForTypeParameters = false ) {
7903
+ function getTypeWithFacts(type: Type, include: TypeFacts) {
7904
7904
if (!(type.flags & TypeFlags.Union)) {
7905
7905
return getTypeFacts(type) & include ? type : neverType;
7906
7906
}
7907
7907
let firstType: Type;
7908
- let hasTypeParameter = false;
7909
7908
let types: Type[];
7910
7909
for (const t of (type as UnionType).types) {
7911
- if (t.flags & TypeFlags.TypeParameter) {
7912
- hasTypeParameter = true;
7913
- }
7914
7910
if (getTypeFacts(t) & include) {
7915
7911
if (!firstType) {
7916
7912
firstType = t;
@@ -7923,19 +7919,8 @@ namespace ts {
7923
7919
}
7924
7920
}
7925
7921
}
7926
- const narrowed = types ? getUnionType(types) :
7927
- firstType ? firstType : neverType;
7928
- // if there is a type parameter in the narrowed type,
7929
- // add an intersection with the members of the narrowed type so that the shape of the type is correct
7930
- if (type.flags & TypeFlags.Union &&
7931
- narrowed.flags & TypeFlags.Union &&
7932
- hasTypeParameter &&
7933
- intersectForTypeParameters) {
7934
- return getIntersectionType(types.concat([narrowed]));
7935
- }
7936
- else {
7937
- return narrowed;
7938
- }
7922
+ return types ? getUnionType(types) :
7923
+ firstType ? firstType : neverType;
7939
7924
}
7940
7925
7941
7926
function getTypeWithDefault(type: Type, defaultExpression: Expression) {
@@ -8308,10 +8293,10 @@ namespace ts {
8308
8293
8309
8294
function narrowTypeByTruthiness(type: Type, expr: Expression, assumeTrue: boolean): Type {
8310
8295
if (isMatchingReference(reference, expr)) {
8311
- return getTypeWithFacts(type, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy, assumeTrue );
8296
+ return getTypeWithFacts(type, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy);
8312
8297
}
8313
8298
if (isMatchingPropertyAccess(expr)) {
8314
- return narrowTypeByDiscriminant(type, <PropertyAccessExpression>expr, t => getTypeWithFacts(t, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy, assumeTrue ));
8299
+ return narrowTypeByDiscriminant(type, <PropertyAccessExpression>expr, t => getTypeWithFacts(t, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy));
8315
8300
}
8316
8301
return type;
8317
8302
}
@@ -8369,7 +8354,7 @@ namespace ts {
8369
8354
value.kind === SyntaxKind.NullKeyword ?
8370
8355
assumeTrue ? TypeFacts.EQNull : TypeFacts.NENull :
8371
8356
assumeTrue ? TypeFacts.EQUndefined : TypeFacts.NEUndefined;
8372
- return getTypeWithFacts(type, facts, assumeTrue );
8357
+ return getTypeWithFacts(type, facts);
8373
8358
}
8374
8359
if (type.flags & TypeFlags.NotUnionOrUnit) {
8375
8360
return type;
@@ -8407,7 +8392,7 @@ namespace ts {
8407
8392
const facts = assumeTrue ?
8408
8393
getProperty(typeofEQFacts, literal.text) || TypeFacts.TypeofEQHostObject :
8409
8394
getProperty(typeofNEFacts, literal.text) || TypeFacts.TypeofNEHostObject;
8410
- return getTypeWithFacts(type, facts, assumeTrue );
8395
+ return getTypeWithFacts(type, facts);
8411
8396
}
8412
8397
8413
8398
function narrowTypeBySwitchOnDiscriminant(type: Type, switchStatement: SwitchStatement, clauseStart: number, clauseEnd: number) {
0 commit comments