@@ -281,6 +281,7 @@ namespace ts {
281
281
const voidType = createIntrinsicType(TypeFlags.Void, "void");
282
282
const neverType = createIntrinsicType(TypeFlags.Never, "never");
283
283
const silentNeverType = createIntrinsicType(TypeFlags.Never, "never");
284
+ const implicitNeverType = createIntrinsicType(TypeFlags.Never, "never");
284
285
const nonPrimitiveType = createIntrinsicType(TypeFlags.NonPrimitive, "object");
285
286
286
287
const emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
@@ -7684,7 +7685,7 @@ namespace ts {
7684
7685
7685
7686
function getIndexTypeOrString(type: Type): Type {
7686
7687
const indexType = getIndexType(type);
7687
- return indexType !== neverType ? indexType : stringType ;
7688
+ return indexType.flags & TypeFlags.Never ? stringType : indexType ;
7688
7689
}
7689
7690
7690
7691
function getTypeFromTypeOperatorNode(node: TypeOperatorNode) {
@@ -8861,8 +8862,8 @@ namespace ts {
8861
8862
function isSimpleTypeRelatedTo(source: Type, target: Type, relation: Map<RelationComparisonResult>, errorReporter?: ErrorReporter) {
8862
8863
const s = source.flags;
8863
8864
const t = target.flags;
8864
- if (t & TypeFlags.Never) return false;
8865
8865
if (t & TypeFlags.Any || s & TypeFlags.Never) return true;
8866
+ if (t & TypeFlags.Never) return false;
8866
8867
if (s & TypeFlags.StringLike && t & TypeFlags.String) return true;
8867
8868
if (s & TypeFlags.StringLiteral && s & TypeFlags.EnumLiteral &&
8868
8869
t & TypeFlags.StringLiteral && !(t & TypeFlags.EnumLiteral) &&
@@ -10323,7 +10324,7 @@ namespace ts {
10323
10324
10324
10325
function isEmptyArrayLiteralType(type: Type): boolean {
10325
10326
const elementType = isArrayType(type) ? (<TypeReference>type).typeArguments[0] : undefined;
10326
- return elementType === undefinedWideningType || elementType === neverType ;
10327
+ return elementType === undefinedWideningType || elementType === implicitNeverType ;
10327
10328
}
10328
10329
10329
10330
function isTupleLikeType(type: Type): boolean {
@@ -10880,9 +10881,10 @@ namespace ts {
10880
10881
// Because the anyFunctionType is internal, it should not be exposed to the user by adding
10881
10882
// it as an inference candidate. Hopefully, a better candidate will come along that does
10882
10883
// not contain anyFunctionType when we come back to this argument for its second round
10883
- // of inference. Also, we exclude inferences for silentNeverType which is used as a wildcard
10884
- // when constructing types from type parameters that had no inference candidates.
10885
- if (source.flags & TypeFlags.ContainsAnyFunctionType || source === silentNeverType) {
10884
+ // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard
10885
+ // when constructing types from type parameters that had no inference candidates) and
10886
+ // implicitNeverType (which is used as the element type for empty array literals).
10887
+ if (source.flags & TypeFlags.ContainsAnyFunctionType || source === silentNeverType || source === implicitNeverType) {
10886
10888
return;
10887
10889
}
10888
10890
const inference = getInferenceInfoForType(target);
@@ -13923,7 +13925,7 @@ namespace ts {
13923
13925
}
13924
13926
return createArrayType(elementTypes.length ?
13925
13927
getUnionType(elementTypes, /*subtypeReduction*/ true) :
13926
- strictNullChecks ? neverType : undefinedWideningType);
13928
+ strictNullChecks ? implicitNeverType : undefinedWideningType);
13927
13929
}
13928
13930
13929
13931
function isNumericName(name: DeclarationName): boolean {
0 commit comments