diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index c509d45f5a6..5836cf0f412 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -3428,7 +3428,6 @@ namespace ts { case SyntaxKind.TypeAliasDeclaration: case SyntaxKind.ThisType: case SyntaxKind.TypeOperator: - case SyntaxKind.BinaryType: case SyntaxKind.IndexedAccessType: case SyntaxKind.MappedType: case SyntaxKind.LiteralType: diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index de3666b0ad5..9c23c97a2a6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -281,7 +281,6 @@ namespace ts { const literalTypes = createMap(); const indexedAccessTypes = createMap(); const conditionalTypes = createMap(); - const extendsTypes = createMap(); const evolvingArrayTypes: EvolvingArrayType[] = []; const undefinedProperties = createMap() as UnderscoreEscapedMap; @@ -2649,11 +2648,6 @@ namespace ts { const falseTypeNode = typeToTypeNodeHelper((type).falseType, context); return createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode); } - if (type.flags & TypeFlags.Extends) { - const leftTypeNode = typeToTypeNodeHelper((type).checkType, context); - const rightTypeNode = typeToTypeNodeHelper((type).extendsType, context); - return createBinaryTypeNode(leftTypeNode, SyntaxKind.ExtendsKeyword, rightTypeNode); - } Debug.fail("Should be unreachable."); @@ -3437,13 +3431,6 @@ namespace ts { writeSpace(writer); writeType((type).falseType, TypeFormatFlags.InElementType); } - else if (type.flags & TypeFlags.Extends) { - writeType((type).checkType, TypeFormatFlags.InElementType); - writeSpace(writer); - writer.writeKeyword("extends"); - writeSpace(writer); - writeType((type).extendsType, TypeFormatFlags.InElementType); - } else { // Should never get here // { ... } @@ -6425,9 +6412,6 @@ namespace ts { else if (type.flags & TypeFlags.Index) { return stringType; } - else if (type.flags & TypeFlags.Extends) { - return booleanType; - } return undefined; } @@ -6496,9 +6480,6 @@ namespace ts { if (t.flags & TypeFlags.Conditional) { return getBaseConstraint(getConstraintOfConditionalType(t)); } - if (t.flags & TypeFlags.Extends) { - return booleanType; - } if (isGenericMappedType(t)) { return emptyObjectType; } @@ -8435,47 +8416,6 @@ namespace ts { return links.resolvedType; } - function createExtendsType(checkType: Type, extendsType: Type) { - const type = createType(TypeFlags.Extends); - type.checkType = checkType; - type.extendsType = extendsType; - return type; - } - - function getExtendsType(checkType: Type, extendsType: Type): Type { - // sys.write(`getExtendsType(${typeToString(checkType)}, ${typeToString(extendsType)})\n`); - if (checkType.flags & TypeFlags.Union) { - return getUnionType(map((checkType).types, t => getExtendsType(t, extendsType))); - } - if (checkType.flags & TypeFlags.Any) { - return booleanType; - } - // Return trueType if type is definitely assignable - if (isTypeAssignableTo(checkType, extendsType)) { - return trueType; - } - // Return falseType is type is definitely not assignable - if (!isTypeAssignableTo(instantiateType(checkType, anyMapper), instantiateType(extendsType, constraintMapper))) { - // Type is definitely not assignable - return falseType; - } - // Type is possibly assignable, defer the check - const id = checkType.id + "," + extendsType.id; - let type = extendsTypes.get(id); - if (!type) { - extendsTypes.set(id, type = createExtendsType(checkType, extendsType)); - } - return type; - } - - function getTypeFromBinaryTypeNode(node: BinaryTypeNode): Type { - const links = getNodeLinks(node); - if (!links.resolvedType) { - links.resolvedType = getExtendsType(getTypeFromTypeNode(node.left), getTypeFromTypeNode(node.right)); - } - return links.resolvedType; - } - function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node: TypeNode): Type { const links = getNodeLinks(node); if (!links.resolvedType) { @@ -8766,8 +8706,6 @@ namespace ts { return getTypeFromMappedTypeNode(node); case SyntaxKind.ConditionalType: return getTypeFromConditionalTypeNode(node); - case SyntaxKind.BinaryType: - return getTypeFromBinaryTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode case SyntaxKind.Identifier: @@ -9096,9 +9034,6 @@ namespace ts { if (type.flags & TypeFlags.Conditional) { return getConditionalTypeInstantiation(type, mapper); } - if (type.flags & TypeFlags.Extends) { - return getExtendsType(instantiateType((type).checkType, mapper), instantiateType((type).extendsType, mapper)); - } } return type; } @@ -11652,10 +11587,6 @@ namespace ts { inferFromTypes((source).trueType, (target).trueType); inferFromTypes((source).falseType, (target).falseType); } - else if (source.flags & TypeFlags.Extends && target.flags & TypeFlags.Extends) { - inferFromTypes((source).checkType, (target).checkType); - inferFromTypes((source).extendsType, (target).extendsType); - } else if (target.flags & TypeFlags.UnionOrIntersection) { const targetTypes = (target).types; let typeVariableCount = 0; @@ -24015,9 +23946,6 @@ namespace ts { return checkTypeOperator(node); case SyntaxKind.ConditionalType: return checkConditionalType(node); - case SyntaxKind.BinaryType: - forEachChild(node, checkSourceElement); - return; case SyntaxKind.JSDocAugmentsTag: return checkJSDocAugmentsTag(node as JSDocAugmentsTag); case SyntaxKind.JSDocTypedefTag: diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 73a910f18d4..75b4ccf9ba8 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -456,8 +456,6 @@ namespace ts { return emitParenType(type); case SyntaxKind.TypeOperator: return emitTypeOperator(type); - case SyntaxKind.BinaryType: - return emitBinaryType(type); case SyntaxKind.IndexedAccessType: return emitIndexedAccessType(type); case SyntaxKind.MappedType: @@ -571,12 +569,6 @@ namespace ts { emitType(type.type); } - function emitBinaryType(node: BinaryTypeNode) { - emitType(node.left); - write(" extends "); - emitType(node.right); - } - function emitIndexedAccessType(node: IndexedAccessTypeNode) { emitType(node.objectType); write("["); diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 05166ee539c..10ecd3c8ffe 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -572,8 +572,6 @@ namespace ts { return emitThisType(); case SyntaxKind.TypeOperator: return emitTypeOperator(node); - case SyntaxKind.BinaryType: - return emitBinaryType(node); case SyntaxKind.IndexedAccessType: return emitIndexedAccessType(node); case SyntaxKind.MappedType: @@ -1159,12 +1157,6 @@ namespace ts { emit(node.type); } - function emitBinaryType(node: BinaryTypeNode) { - emit(node.left); - write(" extends "); - emit(node.right); - } - function emitIndexedAccessType(node: IndexedAccessTypeNode) { emit(node.objectType); write("["); diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 86af989f38c..070715d8ea3 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -767,22 +767,6 @@ namespace ts { return node.type !== type ? updateNode(createTypeOperatorNode(node.operator, type), node) : node; } - export function createBinaryTypeNode(left: TypeNode, operator: SyntaxKind.ExtendsKeyword, right: TypeNode) { - const node = createSynthesizedNode(SyntaxKind.BinaryType) as BinaryTypeNode; - node.left = parenthesizeBinaryTypeMember(left); - node.operator = operator; - node.right = parenthesizeBinaryTypeMember(right); - return node; - } - - export function updateBinaryTypeNode(node: BinaryTypeNode, left: TypeNode, operator: SyntaxKind.ExtendsKeyword, right: TypeNode) { - return node.left !== left - || node.operator !== operator - || node.right !== right - ? updateNode(createBinaryTypeNode(left, operator, right), node) - : node; - } - export function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode) { const node = createSynthesizedNode(SyntaxKind.IndexedAccessType) as IndexedAccessTypeNode; node.objectType = parenthesizeElementTypeMember(objectType); @@ -4119,10 +4103,6 @@ namespace ts { return member.kind === SyntaxKind.ConditionalType ? createParenthesizedType(member) : member; } - export function parenthesizeBinaryTypeMember(member: TypeNode) { - return member.kind === SyntaxKind.BinaryType ? createParenthesizedType(member) : parenthesizeConditionalTypeMember(member); - } - export function parenthesizeElementTypeMember(member: TypeNode) { switch (member.kind) { case SyntaxKind.UnionType: @@ -4131,7 +4111,7 @@ namespace ts { case SyntaxKind.ConstructorType: return createParenthesizedType(member); } - return parenthesizeBinaryTypeMember(member); + return parenthesizeConditionalTypeMember(member); } export function parenthesizeArrayTypeMember(member: TypeNode) { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 4fbf491d266..82b85444bc5 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -183,9 +183,6 @@ namespace ts { case SyntaxKind.ParenthesizedType: case SyntaxKind.TypeOperator: return visitNode(cbNode, (node).type); - case SyntaxKind.BinaryType: - return visitNode(cbNode, (node).left) || - visitNode(cbNode, (node).right); case SyntaxKind.IndexedAccessType: return visitNode(cbNode, (node).objectType) || visitNode(cbNode, (node).indexType); diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index d29cf209339..20bc77c5e17 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -389,7 +389,6 @@ namespace ts { case SyntaxKind.ParenthesizedType: case SyntaxKind.ThisType: case SyntaxKind.TypeOperator: - case SyntaxKind.BinaryType: case SyntaxKind.IndexedAccessType: case SyntaxKind.MappedType: case SyntaxKind.LiteralType: @@ -1887,7 +1886,6 @@ namespace ts { case SyntaxKind.TypeQuery: case SyntaxKind.TypeOperator: - case SyntaxKind.BinaryType: case SyntaxKind.IndexedAccessType: case SyntaxKind.MappedType: case SyntaxKind.TypeLiteral: diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 8861d557294..5acee864e1b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -252,7 +252,6 @@ namespace ts { ParenthesizedType, ThisType, TypeOperator, - BinaryType, IndexedAccessType, MappedType, LiteralType, @@ -1116,13 +1115,6 @@ namespace ts { type: TypeNode; } - export interface BinaryTypeNode extends TypeNode { - kind: SyntaxKind.BinaryType; - left: TypeNode; - operator: SyntaxKind.ExtendsKeyword; - right: TypeNode; - } - /* @internal */ export interface UniqueTypeOperatorNode extends TypeOperatorNode { operator: SyntaxKind.UniqueKeyword; @@ -3409,16 +3401,15 @@ namespace ts { Index = 1 << 19, // keyof T IndexedAccess = 1 << 20, // T[K] Conditional = 1 << 21, // T extends U ? X : Y - Extends = 1 << 22, // T extends U /* @internal */ - FreshLiteral = 1 << 23, // Fresh literal or unique type + FreshLiteral = 1 << 22, // Fresh literal or unique type /* @internal */ - ContainsWideningType = 1 << 24, // Type is or contains undefined or null widening type + ContainsWideningType = 1 << 23, // Type is or contains undefined or null widening type /* @internal */ - ContainsObjectLiteral = 1 << 25, // Type is or contains object literal type + ContainsObjectLiteral = 1 << 24, // Type is or contains object literal type /* @internal */ - ContainsAnyFunctionType = 1 << 26, // Type is or contains the anyFunctionType - NonPrimitive = 1 << 27, // intrinsic object type + ContainsAnyFunctionType = 1 << 25, // Type is or contains the anyFunctionType + NonPrimitive = 1 << 26, // intrinsic object type /* @internal */ GenericMappedType = 1 << 29, // Flag used by maybeTypeOfKind @@ -3438,14 +3429,14 @@ namespace ts { Primitive = String | Number | Boolean | Enum | EnumLiteral | ESSymbol | Void | Undefined | Null | Literal | UniqueESSymbol, StringLike = String | StringLiteral | Index, NumberLike = Number | NumberLiteral | Enum, - BooleanLike = Boolean | BooleanLiteral | Extends, + BooleanLike = Boolean | BooleanLiteral, EnumLike = Enum | EnumLiteral, ESSymbolLike = ESSymbol | UniqueESSymbol, UnionOrIntersection = Union | Intersection, StructuredType = Object | Union | Intersection, TypeVariable = TypeParameter | IndexedAccess, InstantiableNonPrimitive = TypeVariable | Conditional, - InstantiablePrimitive = Index | Extends, + InstantiablePrimitive = Index, Instantiable = InstantiableNonPrimitive | InstantiablePrimitive, StructuredOrInstantiable = StructuredType | Instantiable, @@ -3709,11 +3700,6 @@ namespace ts { falseType: Type; } - export interface ExtendsType extends InstantiableType { - checkType: Type; - extendsType: Type; - } - export const enum SignatureKind { Call, Construct, diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index fb70321e082..a111016dd8f 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4549,10 +4549,6 @@ namespace ts { return node.kind === SyntaxKind.TypeOperator; } - export function isBinaryTypeNode(node: Node): node is BinaryTypeNode { - return node.kind === SyntaxKind.BinaryType; - } - export function isIndexedAccessTypeNode(node: Node): node is IndexedAccessTypeNode { return node.kind === SyntaxKind.IndexedAccessType; } diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index d9d7058cdf4..b047a778015 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -400,12 +400,6 @@ namespace ts { return updateTypeOperatorNode(node, visitNode((node).type, visitor, isTypeNode)); - case SyntaxKind.BinaryType: - return updateBinaryTypeNode(node, - visitNode((node).left, visitor, isTypeNode), - (node).operator, - visitNode((node).right, visitor, isTypeNode)); - case SyntaxKind.IndexedAccessType: return updateIndexedAccessTypeNode((node), visitNode((node).objectType, visitor, isTypeNode),