@@ -122,7 +122,7 @@ namespace ts {
122
122
const unknownType = createIntrinsicType(TypeFlags.Any, "unknown");
123
123
124
124
const emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
125
- const nothingType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
125
+ const neverType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
126
126
const emptyGenericType = <GenericType><ObjectType>createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
127
127
emptyGenericType.instantiations = {};
128
128
@@ -2029,8 +2029,8 @@ namespace ts {
2029
2029
writeUnionOrIntersectionType(<UnionOrIntersectionType>type, flags);
2030
2030
}
2031
2031
else if (type.flags & TypeFlags.Anonymous) {
2032
- if (type === nothingType ) {
2033
- writer.writeKeyword("nothing ");
2032
+ if (type === neverType ) {
2033
+ writer.writeKeyword("never ");
2034
2034
}
2035
2035
else {
2036
2036
writeAnonymousType(<ObjectType>type, flags);
@@ -3670,6 +3670,7 @@ namespace ts {
3670
3670
case SyntaxKind.VoidKeyword:
3671
3671
case SyntaxKind.UndefinedKeyword:
3672
3672
case SyntaxKind.NullKeyword:
3673
+ case SyntaxKind.NeverKeyword:
3673
3674
case SyntaxKind.StringLiteralType:
3674
3675
return true;
3675
3676
case SyntaxKind.ArrayType:
@@ -5005,7 +5006,7 @@ namespace ts {
5005
5006
if (type.flags & TypeFlags.Undefined) typeSet.containsUndefined = true;
5006
5007
if (type.flags & TypeFlags.Null) typeSet.containsNull = true;
5007
5008
}
5008
- else if (type !== nothingType && !contains(typeSet, type)) {
5009
+ else if (type !== neverType && !contains(typeSet, type)) {
5009
5010
typeSet.push(type);
5010
5011
}
5011
5012
}
@@ -5046,7 +5047,7 @@ namespace ts {
5046
5047
// a named type that circularly references itself.
5047
5048
function getUnionType(types: Type[], noSubtypeReduction?: boolean): Type {
5048
5049
if (types.length === 0) {
5049
- return nothingType ;
5050
+ return neverType ;
5050
5051
}
5051
5052
if (types.length === 1) {
5052
5053
return types[0];
@@ -5066,7 +5067,7 @@ namespace ts {
5066
5067
if (typeSet.length === 0) {
5067
5068
return typeSet.containsNull ? nullType :
5068
5069
typeSet.containsUndefined ? undefinedType :
5069
- nothingType ;
5070
+ neverType ;
5070
5071
}
5071
5072
else if (typeSet.length === 1) {
5072
5073
return typeSet[0];
@@ -5214,6 +5215,8 @@ namespace ts {
5214
5215
return undefinedType;
5215
5216
case SyntaxKind.NullKeyword:
5216
5217
return nullType;
5218
+ case SyntaxKind.NeverKeyword:
5219
+ return neverType;
5217
5220
case SyntaxKind.ThisType:
5218
5221
case SyntaxKind.ThisKeyword:
5219
5222
return getTypeFromThisTypeNode(node);
@@ -7485,7 +7488,7 @@ namespace ts {
7485
7488
7486
7489
function getTypeWithFacts(type: Type, include: TypeFacts) {
7487
7490
if (!(type.flags & TypeFlags.Union)) {
7488
- return getTypeFacts(type) & include ? type : nothingType ;
7491
+ return getTypeFacts(type) & include ? type : neverType ;
7489
7492
}
7490
7493
let firstType: Type;
7491
7494
let types: Type[];
@@ -7502,7 +7505,7 @@ namespace ts {
7502
7505
}
7503
7506
}
7504
7507
}
7505
- return firstType ? types ? getUnionType(types, /*noSubtypeReduction*/ true) : firstType : nothingType ;
7508
+ return firstType ? types ? getUnionType(types, /*noSubtypeReduction*/ true) : firstType : neverType ;
7506
7509
}
7507
7510
7508
7511
function getTypeWithDefault(type: Type, defaultExpression: Expression) {
@@ -7622,7 +7625,7 @@ namespace ts {
7622
7625
const visitedFlowStart = visitedFlowCount;
7623
7626
const result = getTypeAtFlowNode(reference.flowNode);
7624
7627
visitedFlowCount = visitedFlowStart;
7625
- if (reference.parent.kind === SyntaxKind.NonNullExpression && getTypeWithFacts(result, TypeFacts.NEUndefinedOrNull) === nothingType ) {
7628
+ if (reference.parent.kind === SyntaxKind.NonNullExpression && getTypeWithFacts(result, TypeFacts.NEUndefinedOrNull) === neverType ) {
7626
7629
return declaredType;
7627
7630
}
7628
7631
return result;
@@ -7710,7 +7713,7 @@ namespace ts {
7710
7713
7711
7714
function getTypeAtFlowCondition(flow: FlowCondition) {
7712
7715
let type = getTypeAtFlowNode(flow.antecedent);
7713
- if (type !== nothingType ) {
7716
+ if (type !== neverType ) {
7714
7717
// If we have an antecedent type (meaning we're reachable in some way), we first
7715
7718
// attempt to narrow the antecedent type. If that produces the nothing type, then
7716
7719
// we take the type guard as an indication that control could reach here in a
@@ -7720,7 +7723,7 @@ namespace ts {
7720
7723
// narrow that.
7721
7724
const assumeTrue = (flow.flags & FlowFlags.TrueCondition) !== 0;
7722
7725
type = narrowType(type, flow.expression, assumeTrue);
7723
- if (type === nothingType ) {
7726
+ if (type === neverType ) {
7724
7727
type = narrowType(declaredType, flow.expression, assumeTrue);
7725
7728
}
7726
7729
}
@@ -7942,7 +7945,7 @@ namespace ts {
7942
7945
const targetType = type.flags & TypeFlags.TypeParameter ? getApparentType(type) : type;
7943
7946
return isTypeAssignableTo(candidate, targetType) ? candidate :
7944
7947
isTypeAssignableTo(type, candidate) ? type :
7945
- nothingType ;
7948
+ neverType ;
7946
7949
}
7947
7950
7948
7951
function narrowTypeByTypePredicate(type: Type, callExpression: CallExpression, assumeTrue: boolean): Type {
@@ -11559,7 +11562,7 @@ namespace ts {
11559
11562
return promiseType;
11560
11563
}
11561
11564
else {
11562
- return voidType;
11565
+ return hasImplicitReturn ? voidType : neverType ;
11563
11566
}
11564
11567
}
11565
11568
}
@@ -14747,7 +14750,7 @@ namespace ts {
14747
14750
arrayType = getUnionType(filter((arrayOrStringType as UnionType).types, t => !(t.flags & TypeFlags.StringLike)));
14748
14751
}
14749
14752
else if (arrayOrStringType.flags & TypeFlags.StringLike) {
14750
- arrayType = nothingType ;
14753
+ arrayType = neverType ;
14751
14754
}
14752
14755
const hasStringConstituent = arrayOrStringType !== arrayType;
14753
14756
let reportedError = false;
@@ -14759,7 +14762,7 @@ namespace ts {
14759
14762
14760
14763
// Now that we've removed all the StringLike types, if no constituents remain, then the entire
14761
14764
// arrayOrStringType was a string.
14762
- if (arrayType === nothingType ) {
14765
+ if (arrayType === neverType ) {
14763
14766
return stringType;
14764
14767
}
14765
14768
}
0 commit comments