diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ac0656f6c6b0d..d72e74f748eb6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2234,8 +2234,8 @@ namespace ts { // Use type of the specified property, or otherwise, for a numeric name, the type of the numeric index signature, // or otherwise the type of the string index signature. type = getTypeOfPropertyOfType(parentType, name.text) || - isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) || - getIndexTypeOfType(parentType, IndexKind.String); + isNumericLiteralName(name.text) && getIndexTypeOfType(parentType, IndexKind.Number) || + getIndexTypeOfType(parentType, IndexKind.String); if (!type) { error(name, Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(parentType), declarationNameToString(name)); return unknownType; @@ -2618,7 +2618,7 @@ namespace ts { // Appends the outer type parameters of a node to a set of type parameters and returns the resulting set. The function // allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set in-place and // returns the same array. - function appendOuterTypeParameters(typeParameters: TypeParameter[], node: Node): TypeParameter[]{ + function appendOuterTypeParameters(typeParameters: TypeParameter[], node: Node): TypeParameter[] { while (true) { node = node.parent; if (!node) { @@ -3203,9 +3203,11 @@ namespace ts { return type.flags & TypeFlags.Union ? getPropertiesOfUnionType(type) : getPropertiesOfObjectType(type); } - // For a type parameter, return the base constraint of the type parameter. For the string, number, - // boolean, and symbol primitive types, return the corresponding object types. Otherwise return the - // type itself. Note that the apparent type of a union type is the union type itself. + /** + * For a type parameter, return the base constraint of the type parameter. For the string, number, + * boolean, and symbol primitive types, return the corresponding object types. Otherwise return the + * type itself. Note that the apparent type of a union type is the union type itself. + */ function getApparentType(type: Type): Type { if (type.flags & TypeFlags.Union) { type = getReducedTypeOfUnionType(type); @@ -3839,8 +3841,8 @@ namespace ts { */ function createTypedPropertyDescriptorType(propertyType: Type): Type { let globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyObjectType - ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) + return globalTypedPropertyDescriptorType !== emptyObjectType + ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) : emptyObjectType; } @@ -4337,6 +4339,16 @@ namespace ts { return checkTypeRelatedTo(sourceType, targetType, assignableRelation, /*errorNode*/ undefined); } + /** + * Checks if 'source' is related to 'target' (e.g.: is a assignable to). + * @param source The left-hand-side of the relation. + * @param target The right-hand-side of the relation. + * @param relation The relation considered. One of 'identityRelation', 'assignableRelation', or 'subTypeRelation'. + * Used as both to determine which checks are performed and as a cache of previously computed results. + * @param errorNode The node upon which all errors will be reported, if defined. + * @param headMessage If the error chain should be prepended by a head message, then headMessage will be used. + * @param containingMessageChain A chain of errors to prepend any new errors found. + */ function checkTypeRelatedTo( source: Type, target: Type, @@ -4644,6 +4656,7 @@ namespace ts { let requireOptionalProperties = relation === subtypeRelation && !(source.flags & TypeFlags.ObjectLiteral); for (let targetProp of properties) { let sourceProp = getPropertyOfType(source, targetProp.name); + if (sourceProp !== targetProp) { if (!sourceProp) { if (!(targetProp.flags & SymbolFlags.Optional) || requireOptionalProperties) { @@ -4654,24 +4667,24 @@ namespace ts { } } else if (!(targetProp.flags & SymbolFlags.Prototype)) { - let sourceFlags = getDeclarationFlagsFromSymbol(sourceProp); - let targetFlags = getDeclarationFlagsFromSymbol(targetProp); - if (sourceFlags & NodeFlags.Private || targetFlags & NodeFlags.Private) { + let sourcePropFlags = getDeclarationFlagsFromSymbol(sourceProp); + let targetPropFlags = getDeclarationFlagsFromSymbol(targetProp); + if (sourcePropFlags & NodeFlags.Private || targetPropFlags & NodeFlags.Private) { if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { if (reportErrors) { - if (sourceFlags & NodeFlags.Private && targetFlags & NodeFlags.Private) { + if (sourcePropFlags & NodeFlags.Private && targetPropFlags & NodeFlags.Private) { reportError(Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp)); } else { reportError(Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), - typeToString(sourceFlags & NodeFlags.Private ? source : target), - typeToString(sourceFlags & NodeFlags.Private ? target : source)); + typeToString(sourcePropFlags & NodeFlags.Private ? source : target), + typeToString(sourcePropFlags & NodeFlags.Private ? target : source)); } } return Ternary.False; } } - else if (targetFlags & NodeFlags.Protected) { + else if (targetPropFlags & NodeFlags.Protected) { let sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & SymbolFlags.Class; let sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; let targetClass = getDeclaredTypeOfSymbol(targetProp.parent); @@ -4683,7 +4696,7 @@ namespace ts { return Ternary.False; } } - else if (sourceFlags & NodeFlags.Protected) { + else if (sourcePropFlags & NodeFlags.Protected) { if (reportErrors) { reportError(Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); @@ -4825,7 +4838,7 @@ namespace ts { if (source.typePredicate && target.typePredicate) { let hasDifferentParameterIndex = source.typePredicate.parameterIndex !== target.typePredicate.parameterIndex; let hasDifferentTypes: boolean; - if (hasDifferentParameterIndex || + if (hasDifferentParameterIndex || (hasDifferentTypes = !isTypeIdenticalTo(source.typePredicate.type, target.typePredicate.type))) { if (reportErrors) { @@ -4835,12 +4848,12 @@ namespace ts { let targetTypeText = typeToString(target.typePredicate.type); if (hasDifferentParameterIndex) { - reportError(Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, + reportError(Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, sourceParamText, targetParamText); } else if (hasDifferentTypes) { - reportError(Diagnostics.Type_0_is_not_assignable_to_type_1, + reportError(Diagnostics.Type_0_is_not_assignable_to_type_1, sourceTypeText, targetTypeText); } @@ -5858,7 +5871,7 @@ namespace ts { if (!assumeTrue) { if (type.flags & TypeFlags.Union) { return getUnionType(filter((type).types, t => !isTypeSubtypeOf(t, signature.typePredicate.type))); - } + } return type; } return getNarrowedType(type, signature.typePredicate.type); @@ -6097,20 +6110,20 @@ namespace ts { if (container && isClassLike(container.parent)) { if (container.flags & NodeFlags.Static) { canUseSuperExpression = - container.kind === SyntaxKind.MethodDeclaration || - container.kind === SyntaxKind.MethodSignature || - container.kind === SyntaxKind.GetAccessor || - container.kind === SyntaxKind.SetAccessor; + container.kind === SyntaxKind.MethodDeclaration || + container.kind === SyntaxKind.MethodSignature || + container.kind === SyntaxKind.GetAccessor || + container.kind === SyntaxKind.SetAccessor; } else { canUseSuperExpression = - container.kind === SyntaxKind.MethodDeclaration || - container.kind === SyntaxKind.MethodSignature || - container.kind === SyntaxKind.GetAccessor || - container.kind === SyntaxKind.SetAccessor || - container.kind === SyntaxKind.PropertyDeclaration || - container.kind === SyntaxKind.PropertySignature || - container.kind === SyntaxKind.Constructor; + container.kind === SyntaxKind.MethodDeclaration || + container.kind === SyntaxKind.MethodSignature || + container.kind === SyntaxKind.GetAccessor || + container.kind === SyntaxKind.SetAccessor || + container.kind === SyntaxKind.PropertyDeclaration || + container.kind === SyntaxKind.PropertySignature || + container.kind === SyntaxKind.Constructor; } } } @@ -6799,7 +6812,7 @@ namespace ts { checkJsxOpeningLikeElement(node.openingElement); // Check children - for(let child of node.children) { + for (let child of node.children) { switch (child.kind) { case SyntaxKind.JsxExpression: checkJsxExpression(child); @@ -6850,7 +6863,7 @@ namespace ts { else if (elementAttributesType && !isTypeAny(elementAttributesType)) { let correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); - // If there's no corresponding property with this name, error + // If there's no corresponding property with this name, error if (!correspondingPropType && isUnhyphenatedJsxName(node.name.text)) { error(node.name, Diagnostics.Property_0_does_not_exist_on_type_1, node.name.text, typeToString(elementAttributesType)); return unknownType; @@ -6877,7 +6890,7 @@ namespace ts { function checkJsxSpreadAttribute(node: JsxSpreadAttribute, elementAttributesType: Type, nameTable: Map) { let type = checkExpression(node.expression); let props = getPropertiesOfType(type); - for(let prop of props) { + for (let prop of props) { // Is there a corresponding property in the element attributes type? Skip checking of properties // that have already been assigned to, as these are not actually pushed into the resulting type if (!nameTable[prop.name]) { @@ -6957,7 +6970,7 @@ namespace ts { else { valueSymbol = checkQualifiedName(node.tagName).symbol; } - + if (valueSymbol !== unknownSymbol) { links.jsxFlags |= JsxFlags.ClassElement; } @@ -7214,46 +7227,95 @@ namespace ts { return s.valueDeclaration ? s.valueDeclaration.kind : SyntaxKind.PropertyDeclaration; } - function getDeclarationFlagsFromSymbol(s: Symbol) { + function getDeclarationFlagsFromSymbol(s: Symbol): NodeFlags { return s.valueDeclaration ? getCombinedNodeFlags(s.valueDeclaration) : s.flags & SymbolFlags.Prototype ? NodeFlags.Public | NodeFlags.Static : 0; } - function checkClassPropertyAccess(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, type: Type, prop: Symbol) { + /** + * Check whether the requested property access is valid. + * Returns true if node is a valid property access, and false otherwise. + * @param node The node to be checked. + * @param left The left hand side of the property access (e.g.: the super in `super.foo`). + * @param type The type of left. + * @param prop The symbol for the right hand side of the property access. + */ + function checkClassPropertyAccess(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, type: Type, prop: Symbol): boolean { let flags = getDeclarationFlagsFromSymbol(prop); - // Public properties are always accessible + let declaringClass = getDeclaredTypeOfSymbol(prop.parent);; + + if (left.kind === SyntaxKind.SuperKeyword) { + let errorNode = node.kind === SyntaxKind.PropertyAccessExpression ? + (node).name : + (node).right; + + // TS 1.0 spec (April 2014): 4.8.2 + // - In a constructor, instance member function, instance member accessor, or + // instance member variable initializer where this references a derived class instance, + // a super property access is permitted and must specify a public instance member function of the base class. + // - In a static member function or static member accessor + // where this references the constructor function object of a derived class, + // a super property access is permitted and must specify a public static member function of the base class. + if (getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { + // `prop` refers to a *property* declared in the super class + // rather than a *method*, so it does not satisfy the above criteria. + + error(errorNode, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); + return false; + } + + if (flags & NodeFlags.Abstract) { + // A method cannot be accessed in a super property access if the method is abstract. + // This error could mask a private property access error. But, a member + // cannot simultaneously be private and abstract, so this will trigger an + // additional error elsewhere. + + error(errorNode, Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(declaringClass)); + return false; + } + } + + // Public properties are otherwise accessible. if (!(flags & (NodeFlags.Private | NodeFlags.Protected))) { - return; + return true; } + // Property is known to be private or protected at this point // Get the declaring and enclosing class instance types let enclosingClassDeclaration = getContainingClass(node); + let enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; - let declaringClass = getDeclaredTypeOfSymbol(prop.parent); + // Private property is accessible if declaring and enclosing class are the same if (flags & NodeFlags.Private) { if (declaringClass !== enclosingClass) { error(node, Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(declaringClass)); + return false; } - return; + return true; } + // Property is known to be protected at this point + // All protected properties of a supertype are accessible in a super access if (left.kind === SyntaxKind.SuperKeyword) { - return; + return true; } // A protected property is accessible in the declaring class and classes derived from it if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { error(node, Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(declaringClass)); - return; + return false; } // No further restrictions for static properties if (flags & NodeFlags.Static) { - return; + return true; } // An instance property must be accessed through an instance of the enclosing class + // TODO: why is the first part of this check here? if (!(getTargetType(type).flags & (TypeFlags.Class | TypeFlags.Interface) && hasBaseType(type, enclosingClass))) { error(node, Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); + return false; } + return true; } function checkPropertyAccessExpression(node: PropertyAccessExpression) { @@ -7282,21 +7344,11 @@ namespace ts { } return unknownType; } + getNodeLinks(node).resolvedSymbol = prop; + if (prop.parent && prop.parent.flags & SymbolFlags.Class) { - // TS 1.0 spec (April 2014): 4.8.2 - // - In a constructor, instance member function, instance member accessor, or - // instance member variable initializer where this references a derived class instance, - // a super property access is permitted and must specify a public instance member function of the base class. - // - In a static member function or static member accessor - // where this references the constructor function object of a derived class, - // a super property access is permitted and must specify a public static member function of the base class. - if (left.kind === SyntaxKind.SuperKeyword && getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { - error(right, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); - } - else { - checkClassPropertyAccess(node, left, type, prop); - } + checkClassPropertyAccess(node, left, type, prop); } return getTypeOfSymbol(prop); } @@ -7310,14 +7362,7 @@ namespace ts { if (type !== unknownType && !isTypeAny(type)) { let prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & SymbolFlags.Class) { - if (left.kind === SyntaxKind.SuperKeyword && getDeclarationKindFromSymbol(prop) !== SyntaxKind.MethodDeclaration) { - return false; - } - else { - let modificationCount = diagnostics.getModificationCount(); - checkClassPropertyAccess(node, left, type, prop); - return diagnostics.getModificationCount() === modificationCount; - } + return checkClassPropertyAccess(node, left, type, prop); } } return true; @@ -7564,7 +7609,7 @@ namespace ts { let callIsIncomplete: boolean; // In incomplete call we want to be lenient when we have too few arguments let isDecorator: boolean; let spreadArgIndex = -1; - + if (node.kind === SyntaxKind.TaggedTemplateExpression) { let tagExpression = node; @@ -7745,17 +7790,17 @@ namespace ts { errorInfo = chainDiagnosticMessages(errorInfo, typeArgumentHeadMessage); typeArgumentHeadMessage = headMessage; } - + typeArgumentsAreAssignable = checkTypeAssignableTo( - typeArgument, - constraint, + typeArgument, + constraint, reportErrors ? typeArgNode : undefined, - typeArgumentHeadMessage, + typeArgumentHeadMessage, errorInfo); } } } - + return typeArgumentsAreAssignable; } @@ -7785,7 +7830,7 @@ namespace ts { } } } - + return true; } @@ -7891,7 +7936,7 @@ namespace ts { // "static" or "constructor" side of the class) let classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); - + case SyntaxKind.Parameter: // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. @@ -7901,7 +7946,7 @@ namespace ts { return getTypeOfSymbol(classSymbol); } - // fall-through + // fall-through case SyntaxKind.PropertyDeclaration: case SyntaxKind.MethodDeclaration: @@ -7912,7 +7957,7 @@ namespace ts { // declared "static"; otherwise, it is the "instance"-side type of the // parent of the member. return getParentTypeOfClassElement(node); - + default: Debug.fail("Unsupported decorator target."); return unknownType; @@ -7940,7 +7985,7 @@ namespace ts { case SyntaxKind.ClassDeclaration: Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; - + case SyntaxKind.Parameter: node = node.parent; if (node.kind === SyntaxKind.Constructor) { @@ -7948,10 +7993,10 @@ namespace ts { return anyType; } - // For a non-constructor parameter decorator, the `propertyKey` will be either - // a string or a symbol, based on the name of the parameter's containing method. + // For a non-constructor parameter decorator, the `propertyKey` will be either + // a string or a symbol, based on the name of the parameter's containing method. - // fall-through + // fall-through case SyntaxKind.PropertyDeclaration: case SyntaxKind.MethodDeclaration: @@ -7967,7 +8012,7 @@ namespace ts { case SyntaxKind.NumericLiteral: case SyntaxKind.StringLiteral: return getStringLiteralType(element.name); - + case SyntaxKind.ComputedPropertyName: let nameType = checkComputedPropertyName(element.name); if (allConstituentTypesHaveKind(nameType, TypeFlags.ESSymbol)) { @@ -7976,13 +8021,13 @@ namespace ts { else { return stringType; } - + default: Debug.fail("Unsupported property name."); return unknownType; } - + default: Debug.fail("Unsupported decorator target."); return unknownType; @@ -8019,7 +8064,7 @@ namespace ts { // for the type of the member. let propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); - + default: Debug.fail("Unsupported decorator target."); return unknownType; @@ -8072,7 +8117,7 @@ namespace ts { (argIndex === 0 && node.kind === SyntaxKind.TaggedTemplateExpression)) { return undefined; } - + return args[argIndex]; } @@ -8092,7 +8137,7 @@ namespace ts { return arg; } } - + function resolveCall(node: CallLikeExpression, signatures: Signature[], candidatesOutArray: Signature[], headMessage?: DiagnosticMessage): Signature { let isTaggedTemplate = node.kind === SyntaxKind.TaggedTemplateExpression; let isDecorator = node.kind === SyntaxKind.Decorator; @@ -8220,7 +8265,7 @@ namespace ts { let diagnosticChainHead = chainDiagnosticMessages(/*details*/ undefined, // details will be provided by call to reportNoCommonSupertypeError Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly, typeToString(failedTypeParameter)); - + if (headMessage) { diagnosticChainHead = chainDiagnosticMessages(diagnosticChainHead, headMessage); } @@ -8246,7 +8291,7 @@ namespace ts { } return resolveErrorCall(node); - + function reportError(message: DiagnosticMessage, arg0?: string, arg1?: string, arg2?: string): void { let errorInfo: DiagnosticMessageChain; errorInfo = chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); @@ -8393,7 +8438,7 @@ namespace ts { let expressionType = checkExpression(node.expression); - // If ConstructExpr's apparent type(section 3.8.1) is an object type with one or + // If expressionType's apparent type(section 3.8.1) is an object type with one or // more construct signatures, the expression is processed in the same manner as a // function call, but using the construct signatures as the initial set of candidate // signatures for overload resolution. The result type of the function call becomes @@ -8404,8 +8449,17 @@ namespace ts { return resolveErrorCall(node); } + // If the expression is a class of abstract type, then it cannot be instantiated. + // Note, only class declarations can be declared abstract. + // In the case of a merged class-module or class-interface declaration, + // only the class declaration node will have the Abstract flag set. + let valueDecl = expressionType.symbol && getDeclarationOfKind(expressionType.symbol, SyntaxKind.ClassDeclaration); + if (valueDecl && valueDecl.flags & NodeFlags.Abstract) { + error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(valueDecl.name)); + } + // TS 1.0 spec: 4.11 - // If ConstructExpr is of type Any, Args can be any argument + // If expressionType is of type Any, Args can be any argument // list and the result of the operation is of type Any. if (isTypeAny(expressionType)) { if (node.typeArguments) { @@ -8423,7 +8477,7 @@ namespace ts { return resolveCall(node, constructSignatures, candidatesOutArray); } - // If ConstructExpr's apparent type is an object type with no construct signatures but + // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time // error occurs if the result of the function call is not Void. The type of the result of the // operation is Any. @@ -8471,13 +8525,13 @@ namespace ts { case SyntaxKind.ClassDeclaration: case SyntaxKind.ClassExpression: return Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - + case SyntaxKind.Parameter: return Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - + case SyntaxKind.PropertyDeclaration: return Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - + case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: @@ -8494,12 +8548,12 @@ namespace ts { if (apparentType === unknownType) { return resolveErrorCall(node); } - + let callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call); if (funcType === anyType || (!callSignatures.length && !(funcType.flags & TypeFlags.Union) && isTypeAssignableTo(funcType, globalFunctionType))) { return resolveUntypedCall(node); } - + let headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { let errorInfo: DiagnosticMessageChain; @@ -8508,7 +8562,7 @@ namespace ts { diagnostics.add(createDiagnosticForNodeFromMessageChain(node, errorInfo)); return resolveErrorCall(node); } - + return resolveCall(node, callSignatures, candidatesOutArray, headMessage); } @@ -8542,6 +8596,11 @@ namespace ts { return links.resolvedSignature; } + /** + * Syntactically and semantically checks a call or new expression. + * @param node The call/new expression to be checked. + * @returns On success, the expression's signature's return type. On failure, anyType. + */ function checkCallExpression(node: CallExpression): Type { // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); @@ -8552,6 +8611,7 @@ namespace ts { } if (node.kind === SyntaxKind.NewExpression) { let declaration = signature.declaration; + if (declaration && declaration.kind !== SyntaxKind.Constructor && declaration.kind !== SyntaxKind.ConstructSignature && @@ -8800,6 +8860,7 @@ namespace ts { function checkFunctionExpressionOrObjectLiteralMethod(node: FunctionExpression | MethodDeclaration, contextualMapper?: TypeMapper): Type { Debug.assert(node.kind !== SyntaxKind.MethodDeclaration || isObjectLiteralMethod(node)); + // Grammar checking let hasGrammarError = checkGrammarFunctionLikeDeclaration(node); if (!hasGrammarError && node.kind === SyntaxKind.FunctionExpression) { @@ -9140,8 +9201,8 @@ namespace ts { let type = isTypeAny(sourceType) ? sourceType : getTypeOfPropertyOfType(sourceType, name.text) || - isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) || - getIndexTypeOfType(sourceType, IndexKind.String); + isNumericLiteralName(name.text) && getIndexTypeOfType(sourceType, IndexKind.Number) || + getIndexTypeOfType(sourceType, IndexKind.String); if (type) { checkDestructuringAssignment((p).initializer || name, type); } @@ -9408,7 +9469,7 @@ namespace ts { function isYieldExpressionInClass(node: YieldExpression): boolean { let current: Node = node let parent = node.parent; - while (parent) { + while (parent) { if (isFunctionLike(parent) && current === (parent).body) { return false; } @@ -9783,12 +9844,12 @@ namespace ts { if (hasReportedError) { break; } - if (param.name.kind === SyntaxKind.ObjectBindingPattern || + if (param.name.kind === SyntaxKind.ObjectBindingPattern || param.name.kind === SyntaxKind.ArrayBindingPattern) { (function checkBindingPattern(pattern: BindingPattern) { for (let element of pattern.elements) { - if (element.name.kind === SyntaxKind.Identifier && + if (element.name.kind === SyntaxKind.Identifier && (element.name).text === typePredicate.parameterName) { error(typePredicateNode.parameterName, @@ -9917,6 +9978,12 @@ namespace ts { // Grammar checking for modifiers is done inside the function checkGrammarFunctionLikeDeclaration checkFunctionLikeDeclaration(node); + + // Abstract methods cannot have an implementation. + // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. + if(node.flags & NodeFlags.Abstract && node.body) { + error(node, Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, declarationNameToString(node.name)); + } } function checkConstructorDeclaration(node: ConstructorDeclaration) { @@ -10151,7 +10218,7 @@ namespace ts { error(signatureDeclarationNode, Diagnostics.Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature); } - function getEffectiveDeclarationFlags(n: Node, flagsToCheck: NodeFlags) { + function getEffectiveDeclarationFlags(n: Node, flagsToCheck: NodeFlags): NodeFlags { let flags = getCombinedNodeFlags(n); if (n.parent.kind !== SyntaxKind.InterfaceDeclaration && isInAmbientContext(n)) { if (!(flags & NodeFlags.Ambient)) { @@ -10197,6 +10264,9 @@ namespace ts { else if (deviation & (NodeFlags.Private | NodeFlags.Protected)) { error(o.name, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } + else if (deviation & NodeFlags.Abstract) { + error(o.name, Diagnostics.Overload_signatures_must_all_be_abstract_or_not_abstract); + } }); } } @@ -10213,7 +10283,7 @@ namespace ts { } } - let flagsToCheck: NodeFlags = NodeFlags.Export | NodeFlags.Ambient | NodeFlags.Private | NodeFlags.Protected; + let flagsToCheck: NodeFlags = NodeFlags.Export | NodeFlags.Ambient | NodeFlags.Private | NodeFlags.Protected | NodeFlags.Abstract; let someNodeFlags: NodeFlags = 0; let allNodeFlags = flagsToCheck; let someHaveQuestionToken = false; @@ -10263,7 +10333,14 @@ namespace ts { error(errorNode, Diagnostics.Constructor_implementation_is_missing); } else { - error(errorNode, Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); + // Report different errors regarding non-consecutive blocks of declarations depending on whether + // the node in question is abstract. + if (node.flags & NodeFlags.Abstract) { + error(errorNode, Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive); + } + else { + error(errorNode, Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); + } } } @@ -10335,7 +10412,9 @@ namespace ts { }); } - if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body) { + // Abstract methods can't have an implementation -- in particular, they don't need one. + if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body && + !(lastSeenNonAmbientDeclaration.flags & NodeFlags.Abstract) ) { reportImplementationExpectedError(lastSeenNonAmbientDeclaration); } @@ -10707,8 +10786,8 @@ namespace ts { if (returnType.flags & TypeFlags.Any) { return; } - - let expectedReturnType: Type; + + let expectedReturnType: Type; let headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); let errorInfo: DiagnosticMessageChain; switch (node.parent.kind) { @@ -10725,7 +10804,7 @@ namespace ts { Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - + case SyntaxKind.PropertyDeclaration: expectedReturnType = voidType; errorInfo = chainDiagnosticMessages( @@ -10741,12 +10820,12 @@ namespace ts { expectedReturnType = getUnionType([descriptorType, voidType]); break; } - + checkTypeAssignableTo( - returnType, - expectedReturnType, - node, - headMessage, + returnType, + expectedReturnType, + node, + headMessage, errorInfo); } @@ -10810,7 +10889,7 @@ namespace ts { if (!nodeCanBeDecorated(node)) { return; } - + if (!compilerOptions.experimentalDecorators) { error(node, Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Specify_experimentalDecorators_to_remove_this_warning); } @@ -11263,7 +11342,7 @@ namespace ts { function checkExpressionStatement(node: ExpressionStatement) { // Grammar checking - checkGrammarStatementInAmbientContext(node) + checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); } @@ -11990,6 +12069,7 @@ namespace ts { checkTypeAssignableTo(type, baseType, node.name || node, Diagnostics.Class_0_incorrectly_extends_base_class_1); checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); + if (!(staticBaseType.symbol && staticBaseType.symbol.flags & SymbolFlags.Class)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. We can simply compare the type @@ -12064,45 +12144,67 @@ namespace ts { } let derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); + let baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); + + Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration."); + if (derived) { - let baseDeclarationFlags = getDeclarationFlagsFromSymbol(base); - let derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); - if ((baseDeclarationFlags & NodeFlags.Private) || (derivedDeclarationFlags & NodeFlags.Private)) { - // either base or derived property is private - not override, skip it - continue; - } + // In order to resolve whether the inherited method was overriden in the base class or not, + // we compare the Symbols obtained. Since getTargetSymbol returns the symbol on the *uninstantiated* + // type declaration, derived and base resolve to the same symbol even in the case of generic classes. + if (derived === base) { + // derived class inherits base without override/redeclaration - if ((baseDeclarationFlags & NodeFlags.Static) !== (derivedDeclarationFlags & NodeFlags.Static)) { - // value of 'static' is not the same for properties - not override, skip it - continue; - } + let derivedClassDecl = getDeclarationOfKind(type.symbol, SyntaxKind.ClassDeclaration); - if ((base.flags & derived.flags & SymbolFlags.Method) || ((base.flags & SymbolFlags.PropertyOrAccessor) && (derived.flags & SymbolFlags.PropertyOrAccessor))) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; + // It is an error to inherit an abstract member without implementing it or being declared abstract. + // If there is no declaration for the derived class (as in the case of class expressions), + // then the class cannot be declared abstract. + if ( baseDeclarationFlags & NodeFlags.Abstract && (!derivedClassDecl || !(derivedClassDecl.flags & NodeFlags.Abstract))) { + error(derivedClassDecl, Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, + typeToString(type), symbolToString(baseProperty), typeToString(baseType)); + } } + else { + // derived overrides base. + let derivedDeclarationFlags = getDeclarationFlagsFromSymbol(derived); + if ((baseDeclarationFlags & NodeFlags.Private) || (derivedDeclarationFlags & NodeFlags.Private)) { + // either base or derived property is private - not override, skip it + continue; + } + + if ((baseDeclarationFlags & NodeFlags.Static) !== (derivedDeclarationFlags & NodeFlags.Static)) { + // value of 'static' is not the same for properties - not override, skip it + continue; + } + + if ((base.flags & derived.flags & SymbolFlags.Method) || ((base.flags & SymbolFlags.PropertyOrAccessor) && (derived.flags & SymbolFlags.PropertyOrAccessor))) { + // method is overridden with method or property/accessor is overridden with property/accessor - correct case + continue; + } - let errorMessage: DiagnosticMessage; - if (base.flags & SymbolFlags.Method) { - if (derived.flags & SymbolFlags.Accessor) { - errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + let errorMessage: DiagnosticMessage; + if (base.flags & SymbolFlags.Method) { + if (derived.flags & SymbolFlags.Accessor) { + errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + Debug.assert((derived.flags & SymbolFlags.Property) !== 0); + errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + } + } + else if (base.flags & SymbolFlags.Property) { + Debug.assert((derived.flags & SymbolFlags.Method) !== 0); + errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; } else { - Debug.assert((derived.flags & SymbolFlags.Property) !== 0); - errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + Debug.assert((base.flags & SymbolFlags.Accessor) !== 0); + Debug.assert((derived.flags & SymbolFlags.Method) !== 0); + errorMessage = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } - } - else if (base.flags & SymbolFlags.Property) { - Debug.assert((derived.flags & SymbolFlags.Method) !== 0); - errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; - } - else { - Debug.assert((base.flags & SymbolFlags.Accessor) !== 0); - Debug.assert((derived.flags & SymbolFlags.Method) !== 0); - errorMessage = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; - } - error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + } } } } @@ -13135,7 +13237,7 @@ namespace ts { if ((location).name) { copySymbol(location.symbol, meaning); } - // Fall through + // Fall through case SyntaxKind.ClassDeclaration: case SyntaxKind.InterfaceDeclaration: if (!(memberFlags & NodeFlags.Static)) { @@ -13352,8 +13454,8 @@ namespace ts { (node.parent).moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } + // Fall through - // fall through case SyntaxKind.NumericLiteral: // index access if (node.parent.kind === SyntaxKind.ElementAccessExpression && (node.parent).argumentExpression === node) { @@ -13447,7 +13549,7 @@ namespace ts { */ function getParentTypeOfClassElement(node: ClassElement) { let classSymbol = getSymbolOfNode(node.parent); - return node.flags & NodeFlags.Static + return node.flags & NodeFlags.Static ? getTypeOfSymbol(classSymbol) : getDeclaredTypeOfSymbol(classSymbol); } @@ -13541,7 +13643,7 @@ namespace ts { if (links.isNestedRedeclaration === undefined) { let container = getEnclosingBlockScopeContainer(symbol.valueDeclaration); links.isNestedRedeclaration = isStatementWithLocals(container) && - !!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + !!resolveName(container.parent, symbol.name, SymbolFlags.Value, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); } return links.isNestedRedeclaration; } @@ -14147,6 +14249,14 @@ namespace ts { else if (node.parent.kind === SyntaxKind.ModuleBlock || node.parent.kind === SyntaxKind.SourceFile) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_module_element, text); } + else if (flags & NodeFlags.Abstract) { + if (modifier.kind === SyntaxKind.PrivateKeyword) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); + } + else { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract"); + } + } flags |= modifierToFlag(modifier.kind); break; @@ -14163,6 +14273,9 @@ namespace ts { else if (node.kind === SyntaxKind.Parameter) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } + else if (flags & NodeFlags.Abstract) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } flags |= NodeFlags.Static; lastStatic = modifier; break; @@ -14174,6 +14287,9 @@ namespace ts { else if (flags & NodeFlags.Ambient) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare"); } + else if (flags & NodeFlags.Abstract) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract"); + } else if (flags & NodeFlags.Async) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } @@ -14203,7 +14319,29 @@ namespace ts { return grammarErrorOnNode(modifier, Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= NodeFlags.Ambient; - lastDeclare = modifier + lastDeclare = modifier; + break; + + case SyntaxKind.AbstractKeyword: + if (flags & NodeFlags.Abstract) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_already_seen, "abstract"); + } + if (node.kind !== SyntaxKind.ClassDeclaration) { + if (node.kind !== SyntaxKind.MethodDeclaration) { + return grammarErrorOnNode(modifier, Diagnostics.abstract_modifier_can_only_appear_on_a_class_or_method_declaration); + } + if (!(node.parent.kind === SyntaxKind.ClassDeclaration && node.parent.flags & NodeFlags.Abstract)) { + return grammarErrorOnNode(modifier, Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); + } + if (flags & NodeFlags.Static) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract"); + } + if (flags & NodeFlags.Private) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract"); + } + } + + flags |= NodeFlags.Abstract; break; case SyntaxKind.AsyncKeyword: @@ -14226,6 +14364,9 @@ namespace ts { if (flags & NodeFlags.Static) { return grammarErrorOnNode(lastStatic, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } + if (flags & NodeFlags.Abstract) { + return grammarErrorOnNode(lastStatic, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); + } else if (flags & NodeFlags.Protected) { return grammarErrorOnNode(lastProtected, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 7b35c5e0d6587..ec4c777852b59 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2,17 +2,19 @@ /* @internal */ namespace ts { - // Ternary values are defined such that - // x & y is False if either x or y is False. - // x & y is Maybe if either x or y is Maybe, but neither x or y is False. - // x & y is True if both x and y are True. - // x | y is False if both x and y are False. - // x | y is Maybe if either x or y is Maybe, but neither x or y is True. - // x | y is True if either x or y is True. + /** + * Ternary values are defined such that + * x & y is False if either x or y is False. + * x & y is Maybe if either x or y is Maybe, but neither x or y is False. + * x & y is True if both x and y are True. + * x | y is False if both x and y are False. + * x | y is Maybe if either x or y is Maybe, but neither x or y is True. + * x | y is True if either x or y is True. + */ export const enum Ternary { False = 0, Maybe = 1, - True = -1 + True = -1 } export function createFileMap(getCanonicalFileName: (fileName: string) => string): FileMap { @@ -59,6 +61,11 @@ namespace ts { export interface StringSet extends Map { } + /** + * Iterates through 'array' by index and performs the callback on each element of array until the callback + * returns a truthy value, then returns that value. + * If no such value is found, the callback is applied to each element of array and undefined is returned. + */ export function forEach(array: T[], callback: (element: T, index: number) => U): U { if (array) { for (let i = 0, len = array.length; i < len; i++) { diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 54d0d6ff854dc..af009ce36cf55 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -588,6 +588,9 @@ namespace ts { if (node.flags & NodeFlags.Static) { write("static "); } + if (node.flags & NodeFlags.Abstract) { + write("abstract "); + } } function writeImportEqualsDeclaration(node: ImportEqualsDeclaration) { @@ -912,6 +915,10 @@ namespace ts { emitJsDocComments(node); emitModuleElementDeclarationFlags(node); + if (node.flags & NodeFlags.Abstract) { + write("abstract "); + } + write("class "); writeTextOfNode(currentSourceFile, node.name); let prevEnclosingDeclaration = enclosingDeclaration; diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 61acf271bc5c0..24b182c7134d8 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -200,6 +200,10 @@ namespace ts { Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: { code: 1239, category: DiagnosticCategory.Error, key: "Unable to resolve signature of parameter decorator when called as an expression." }, Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: { code: 1240, category: DiagnosticCategory.Error, key: "Unable to resolve signature of property decorator when called as an expression." }, Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: { code: 1241, category: DiagnosticCategory.Error, key: "Unable to resolve signature of method decorator when called as an expression." }, + abstract_modifier_can_only_appear_on_a_class_or_method_declaration: { code: 1242, category: DiagnosticCategory.Error, key: "'abstract' modifier can only appear on a class or method declaration." }, + _0_modifier_cannot_be_used_with_1_modifier: { code: 1243, category: DiagnosticCategory.Error, key: "'{0}' modifier cannot be used with '{1}' modifier." }, + Abstract_methods_can_only_appear_within_an_abstract_class: { code: 1244, category: DiagnosticCategory.Error, key: "Abstract methods can only appear within an abstract class." }, + Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: { code: 1245, category: DiagnosticCategory.Error, key: "Method '{0}' cannot have an implementation because it is marked abstract." }, Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -235,10 +239,10 @@ namespace ts { this_cannot_be_referenced_in_a_static_property_initializer: { code: 2334, category: DiagnosticCategory.Error, key: "'this' cannot be referenced in a static property initializer." }, super_can_only_be_referenced_in_a_derived_class: { code: 2335, category: DiagnosticCategory.Error, key: "'super' can only be referenced in a derived class." }, super_cannot_be_referenced_in_constructor_arguments: { code: 2336, category: DiagnosticCategory.Error, key: "'super' cannot be referenced in constructor arguments." }, - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors" }, - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class" }, + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: { code: 2337, category: DiagnosticCategory.Error, key: "Super calls are not permitted outside constructors or in nested functions inside constructors." }, + super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: { code: 2338, category: DiagnosticCategory.Error, key: "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class." }, Property_0_does_not_exist_on_type_1: { code: 2339, category: DiagnosticCategory.Error, key: "Property '{0}' does not exist on type '{1}'." }, - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword" }, + Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: DiagnosticCategory.Error, key: "Only public and protected methods of the base class are accessible via the 'super' keyword." }, Property_0_is_private_and_only_accessible_within_class_1: { code: 2341, category: DiagnosticCategory.Error, key: "Property '{0}' is private and only accessible within class '{1}'." }, An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: { code: 2342, category: DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', 'symbol, or 'any'." }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, @@ -397,6 +401,13 @@ namespace ts { No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, + Cannot_create_an_instance_of_the_abstract_class_0: { code: 2511, category: DiagnosticCategory.Error, key: "Cannot create an instance of the abstract class '{0}'." }, + Overload_signatures_must_all_be_abstract_or_not_abstract: { code: 2512, category: DiagnosticCategory.Error, key: "Overload signatures must all be abstract or not abstract." }, + Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression: { code: 2513, category: DiagnosticCategory.Error, key: "Abstract method '{0}' in class '{1}' cannot be accessed via super expression." }, + Classes_containing_abstract_methods_must_be_marked_abstract: { code: 2514, category: DiagnosticCategory.Error, key: "Classes containing abstract methods must be marked abstract." }, + Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2: { code: 2515, category: DiagnosticCategory.Error, key: "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'." }, + All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: DiagnosticCategory.Error, key: "All declarations of an abstract method must be consecutive." }, + Constructor_objects_of_abstract_type_cannot_be_assigned_to_constructor_objects_of_non_abstract_type: { code: 2517, category: DiagnosticCategory.Error, key: "Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract type" }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: DiagnosticCategory.Error, key: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, The_arguments_object_cannot_be_referenced_in_an_async_arrow_function_Consider_using_a_standard_async_function_expression: { code: 2522, category: DiagnosticCategory.Error, key: "The 'arguments' object cannot be referenced in an async arrow function. Consider using a standard async function expression." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 465f66ab9218e..9b58e3143b2ee 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -765,7 +765,6 @@ "category": "Error", "code": 1311 }, - "The return type of a property decorator function must be either 'void' or 'any'.": { "category": "Error", "code": 1236 @@ -790,7 +789,22 @@ "category": "Error", "code": 1241 }, - + "'abstract' modifier can only appear on a class or method declaration.": { + "category": "Error", + "code": 1242 + }, + "'{0}' modifier cannot be used with '{1}' modifier.": { + "category": "Error", + "code": 1243 + }, + "Abstract methods can only appear within an abstract class.": { + "category": "Error", + "code": 1244 + }, + "Method '{0}' cannot have an implementation because it is marked abstract.": { + "category": "Error", + "code": 1245 + }, "Duplicate identifier '{0}'.": { "category": "Error", "code": 2300 @@ -931,11 +945,11 @@ "category": "Error", "code": 2336 }, - "Super calls are not permitted outside constructors or in nested functions inside constructors": { + "Super calls are not permitted outside constructors or in nested functions inside constructors.": { "category": "Error", "code": 2337 }, - "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class": { + "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class.": { "category": "Error", "code": 2338 }, @@ -943,7 +957,7 @@ "category": "Error", "code": 2339 }, - "Only public and protected methods of the base class are accessible via the 'super' keyword": { + "Only public and protected methods of the base class are accessible via the 'super' keyword.": { "category": "Error", "code": 2340 }, @@ -1579,7 +1593,34 @@ "category": "Error", "code": 2510 }, - + "Cannot create an instance of the abstract class '{0}'.": { + "category": "Error", + "code": 2511 + }, + "Overload signatures must all be abstract or not abstract.": { + "category": "Error", + "code": 2512 + }, + "Abstract method '{0}' in class '{1}' cannot be accessed via super expression.": { + "category": "Error", + "code": 2513 + }, + "Classes containing abstract methods must be marked abstract.": { + "category": "Error", + "code": 2514 + }, + "Non-abstract class '{0}' does not implement inherited abstract member '{1}' from class '{2}'.": { + "category": "Error", + "code": 2515 + }, + "All declarations of an abstract method must be consecutive.": { + "category": "Error", + "code": 2516 + }, + "Constructor objects of abstract type cannot be assigned to constructor objects of non-abstract type": { + "category": "Error", + "code":2517 + }, "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions.": { "category": "Error", "code": 2520 @@ -1600,7 +1641,6 @@ "category": "Error", "code": 2524 }, - "JSX element attributes type '{0}' must be an object type.": { "category": "Error", "code": 2600 @@ -1641,7 +1681,6 @@ "category": "Error", "code": 2650 }, - "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index c0118ec198478..c257f6c702e05 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -4141,6 +4141,7 @@ namespace ts { case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.StaticKeyword: + case SyntaxKind.AbstractKeyword: nextToken(); continue; default: @@ -4278,6 +4279,7 @@ namespace ts { case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.PublicKeyword: + case SyntaxKind.AbstractKeyword: case SyntaxKind.StaticKeyword: if (isStartOfDeclaration()) { return parseDeclaration(); diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index bec5dcc284c50..b7cead60381b4 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -45,6 +45,7 @@ namespace ts { } let textToToken: Map = { + "abstract": SyntaxKind.AbstractKeyword, "any": SyntaxKind.AnyKeyword, "as": SyntaxKind.AsKeyword, "boolean": SyntaxKind.BooleanKeyword, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index eed84ed59fd62..7b683f2eeb5d0 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -140,6 +140,7 @@ namespace ts { StaticKeyword, YieldKeyword, // Contextual keywords + AbstractKeyword, AsKeyword, AnyKeyword, AsyncKeyword, @@ -359,18 +360,19 @@ namespace ts { Private = 0x00000020, // Property/Method Protected = 0x00000040, // Property/Method Static = 0x00000080, // Property/Method - Default = 0x00000100, // Function/Class (export default declaration) - MultiLine = 0x00000200, // Multi-line array or object literal - Synthetic = 0x00000400, // Synthetic node (for full fidelity) - DeclarationFile = 0x00000800, // Node is a .d.ts file - Let = 0x00001000, // Variable declaration - Const = 0x00002000, // Variable declaration - OctalLiteral = 0x00004000, // Octal numeric literal - Namespace = 0x00008000, // Namespace declaration - ExportContext = 0x00010000, // Export context (initialized by binding) - Async = 0x00020000, // Property/Method/Function - - Modifier = Export | Ambient | Public | Private | Protected | Static | Default | Async, + Abstract = 0x00000100, // Class/Method/ConstructSignature + Async = 0x00000200, // Property/Method/Function + Default = 0x00000400, // Function/Class (export default declaration) + MultiLine = 0x00000800, // Multi-line array or object literal + Synthetic = 0x00001000, // Synthetic node (for full fidelity) + DeclarationFile = 0x00002000, // Node is a .d.ts file + Let = 0x00004000, // Variable declaration + Const = 0x00008000, // Variable declaration + OctalLiteral = 0x00010000, // Octal numeric literal + Namespace = 0x00020000, // Namespace declaration + ExportContext = 0x00040000, // Export context (initialized by binding) + + Modifier = Export | Ambient | Public | Private | Protected | Static | Abstract | Default | Async, AccessibilityModifier = Public | Private | Protected, BlockScoped = Let | Const } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index af2ac2aa5f84b..f48e5306dcead 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1391,15 +1391,16 @@ namespace ts { export function isModifier(token: SyntaxKind): boolean { switch (token) { + case SyntaxKind.AbstractKeyword: + case SyntaxKind.AsyncKeyword: + case SyntaxKind.ConstKeyword: + case SyntaxKind.DeclareKeyword: + case SyntaxKind.DefaultKeyword: + case SyntaxKind.ExportKeyword: case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.StaticKeyword: - case SyntaxKind.ExportKeyword: - case SyntaxKind.DeclareKeyword: - case SyntaxKind.ConstKeyword: - case SyntaxKind.DefaultKeyword: - case SyntaxKind.AsyncKeyword: return true; } return false; @@ -1900,6 +1901,7 @@ namespace ts { case SyntaxKind.PublicKeyword: return NodeFlags.Public; case SyntaxKind.ProtectedKeyword: return NodeFlags.Protected; case SyntaxKind.PrivateKeyword: return NodeFlags.Private; + case SyntaxKind.AbstractKeyword: return NodeFlags.Abstract; case SyntaxKind.ExportKeyword: return NodeFlags.Export; case SyntaxKind.DeclareKeyword: return NodeFlags.Ambient; case SyntaxKind.ConstKeyword: return NodeFlags.Const; diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index da1327543116a..1a75888635079 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -318,7 +318,7 @@ namespace ts.formatting { this.NoSpaceAfterModuleImport = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.ModuleKeyword, SyntaxKind.RequireKeyword]), SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); // Add a space around certain TypeScript keywords - this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); + this.SpaceAfterCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.ClassKeyword, SyntaxKind.DeclareKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.EnumKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ExtendsKeyword, SyntaxKind.GetKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.ImportKeyword, SyntaxKind.InterfaceKeyword, SyntaxKind.ModuleKeyword, SyntaxKind.NamespaceKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.PublicKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.SetKeyword, SyntaxKind.StaticKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.SpaceBeforeCertainTypeScriptKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.ExtendsKeyword, SyntaxKind.ImplementsKeyword])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { @@ -344,7 +344,7 @@ namespace ts.formatting { // decorators this.SpaceBeforeAt = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.AtToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space)); this.NoSpaceAfterAt = new Rule(RuleDescriptor.create3(SyntaxKind.AtToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete)); - this.SpaceAfterDecorator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.ExportKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.ClassKeyword, SyntaxKind.StaticKeyword, SyntaxKind.PublicKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword, SyntaxKind.OpenBracketToken, SyntaxKind.AsteriskToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), RuleAction.Space)); + this.SpaceAfterDecorator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.AbstractKeyword, SyntaxKind.Identifier, SyntaxKind.ExportKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.ClassKeyword, SyntaxKind.StaticKeyword, SyntaxKind.PublicKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword, SyntaxKind.OpenBracketToken, SyntaxKind.AsteriskToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), RuleAction.Space)); this.NoSpaceBetweenFunctionKeywordAndStar = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.AsteriskToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), RuleAction.Delete)); this.SpaceAfterStarInGeneratorDeclaration = new Rule(RuleDescriptor.create3(SyntaxKind.AsteriskToken, Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), RuleAction.Space)); diff --git a/src/services/services.ts b/src/services/services.ts index 018a11fc4bb3d..e8a3cb5958ac6 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1494,6 +1494,7 @@ namespace ts { export const exportedModifier = "export"; export const ambientModifier = "declare"; export const staticModifier = "static"; + export const abstractModifier = "abstract"; } export class ClassificationTypeNames { @@ -2784,6 +2785,7 @@ namespace ts { case SyntaxKind.ExportKeyword: case SyntaxKind.ConstKeyword: case SyntaxKind.DefaultKeyword: + case SyntaxKind.AbstractKeyword: } } } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 0fd945caa7d3b..517cb24541a17 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -429,6 +429,7 @@ namespace ts { if (flags & NodeFlags.Protected) result.push(ScriptElementKindModifier.protectedMemberModifier); if (flags & NodeFlags.Public) result.push(ScriptElementKindModifier.publicMemberModifier); if (flags & NodeFlags.Static) result.push(ScriptElementKindModifier.staticModifier); + if (flags & NodeFlags.Abstract) result.push(ScriptElementKindModifier.abstractModifier); if (flags & NodeFlags.Export) result.push(ScriptElementKindModifier.exportedModifier); if (isInAmbientContext(node)) result.push(ScriptElementKindModifier.ambientModifier); diff --git a/tests/baselines/reference/APISample_linter.js b/tests/baselines/reference/APISample_linter.js index fd7be9fc2a5ac..b49c2d7596e30 100644 --- a/tests/baselines/reference/APISample_linter.js +++ b/tests/baselines/reference/APISample_linter.js @@ -75,26 +75,26 @@ function delint(sourceFile) { delintNode(sourceFile); function delintNode(node) { switch (node.kind) { - case 194 /* ForStatement */: - case 195 /* ForInStatement */: - case 193 /* WhileStatement */: - case 192 /* DoStatement */: - if (node.statement.kind !== 187 /* Block */) { + case 195 /* ForStatement */: + case 196 /* ForInStatement */: + case 194 /* WhileStatement */: + case 193 /* DoStatement */: + if (node.statement.kind !== 188 /* Block */) { report(node, "A looping statement's contents should be wrapped in a block body."); } break; - case 191 /* IfStatement */: + case 192 /* IfStatement */: var ifStatement = node; - if (ifStatement.thenStatement.kind !== 187 /* Block */) { + if (ifStatement.thenStatement.kind !== 188 /* Block */) { report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body."); } if (ifStatement.elseStatement && - ifStatement.elseStatement.kind !== 187 /* Block */ && - ifStatement.elseStatement.kind !== 191 /* IfStatement */) { + ifStatement.elseStatement.kind !== 188 /* Block */ && + ifStatement.elseStatement.kind !== 192 /* IfStatement */) { report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body."); } break; - case 176 /* BinaryExpression */: + case 177 /* BinaryExpression */: var op = node.operatorToken.kind; if (op === 29 /* EqualsEqualsToken */ || op == 30 /* ExclamationEqualsToken */) { report(node, "Use '===' and '!=='."); diff --git a/tests/baselines/reference/abstractIdentifierNameStrict.js b/tests/baselines/reference/abstractIdentifierNameStrict.js new file mode 100644 index 0000000000000..92d159766d7e8 --- /dev/null +++ b/tests/baselines/reference/abstractIdentifierNameStrict.js @@ -0,0 +1,14 @@ +//// [abstractIdentifierNameStrict.ts] +var abstract = true; + +function foo() { + "use strict"; + var abstract = true; +} + +//// [abstractIdentifierNameStrict.js] +var abstract = true; +function foo() { + "use strict"; + var abstract = true; +} diff --git a/tests/baselines/reference/abstractIdentifierNameStrict.symbols b/tests/baselines/reference/abstractIdentifierNameStrict.symbols new file mode 100644 index 0000000000000..c6a374e9bcdf0 --- /dev/null +++ b/tests/baselines/reference/abstractIdentifierNameStrict.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/abstractIdentifierNameStrict.ts === +var abstract = true; +>abstract : Symbol(abstract, Decl(abstractIdentifierNameStrict.ts, 0, 3)) + +function foo() { +>foo : Symbol(foo, Decl(abstractIdentifierNameStrict.ts, 0, 20)) + + "use strict"; + var abstract = true; +>abstract : Symbol(abstract, Decl(abstractIdentifierNameStrict.ts, 4, 7)) +} diff --git a/tests/baselines/reference/abstractIdentifierNameStrict.types b/tests/baselines/reference/abstractIdentifierNameStrict.types new file mode 100644 index 0000000000000..7c79ce58a372e --- /dev/null +++ b/tests/baselines/reference/abstractIdentifierNameStrict.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/abstractIdentifierNameStrict.ts === +var abstract = true; +>abstract : boolean +>true : boolean + +function foo() { +>foo : () => void + + "use strict"; +>"use strict" : string + + var abstract = true; +>abstract : boolean +>true : boolean +} diff --git a/tests/baselines/reference/abstractInterfaceIdentifierName.js b/tests/baselines/reference/abstractInterfaceIdentifierName.js new file mode 100644 index 0000000000000..67058bfc6194a --- /dev/null +++ b/tests/baselines/reference/abstractInterfaceIdentifierName.js @@ -0,0 +1,8 @@ +//// [abstractInterfaceIdentifierName.ts] + +interface abstract { + abstract(): void; +} + + +//// [abstractInterfaceIdentifierName.js] diff --git a/tests/baselines/reference/abstractInterfaceIdentifierName.symbols b/tests/baselines/reference/abstractInterfaceIdentifierName.symbols new file mode 100644 index 0000000000000..c70cdec8ac957 --- /dev/null +++ b/tests/baselines/reference/abstractInterfaceIdentifierName.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/abstractInterfaceIdentifierName.ts === + +interface abstract { +>abstract : Symbol(abstract, Decl(abstractInterfaceIdentifierName.ts, 0, 0)) + + abstract(): void; +>abstract : Symbol(abstract, Decl(abstractInterfaceIdentifierName.ts, 1, 20)) +} + diff --git a/tests/baselines/reference/abstractInterfaceIdentifierName.types b/tests/baselines/reference/abstractInterfaceIdentifierName.types new file mode 100644 index 0000000000000..c6d30ca38a0c3 --- /dev/null +++ b/tests/baselines/reference/abstractInterfaceIdentifierName.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/abstractInterfaceIdentifierName.ts === + +interface abstract { +>abstract : abstract + + abstract(): void; +>abstract : () => void +} + diff --git a/tests/baselines/reference/classAbstractAsIdentifier.js b/tests/baselines/reference/classAbstractAsIdentifier.js new file mode 100644 index 0000000000000..6adadd346b599 --- /dev/null +++ b/tests/baselines/reference/classAbstractAsIdentifier.js @@ -0,0 +1,15 @@ +//// [classAbstractAsIdentifier.ts] +class abstract { + foo() { return 1; } +} + +new abstract; + +//// [classAbstractAsIdentifier.js] +var abstract = (function () { + function abstract() { + } + abstract.prototype.foo = function () { return 1; }; + return abstract; +})(); +new abstract; diff --git a/tests/baselines/reference/classAbstractAsIdentifier.symbols b/tests/baselines/reference/classAbstractAsIdentifier.symbols new file mode 100644 index 0000000000000..f2ce2ebcab517 --- /dev/null +++ b/tests/baselines/reference/classAbstractAsIdentifier.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts === +class abstract { +>abstract : Symbol(abstract, Decl(classAbstractAsIdentifier.ts, 0, 0)) + + foo() { return 1; } +>foo : Symbol(foo, Decl(classAbstractAsIdentifier.ts, 0, 16)) +} + +new abstract; +>abstract : Symbol(abstract, Decl(classAbstractAsIdentifier.ts, 0, 0)) + diff --git a/tests/baselines/reference/classAbstractAsIdentifier.types b/tests/baselines/reference/classAbstractAsIdentifier.types new file mode 100644 index 0000000000000..e2894af804d23 --- /dev/null +++ b/tests/baselines/reference/classAbstractAsIdentifier.types @@ -0,0 +1,13 @@ +=== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts === +class abstract { +>abstract : abstract + + foo() { return 1; } +>foo : () => number +>1 : number +} + +new abstract; +>new abstract : abstract +>abstract : typeof abstract + diff --git a/tests/baselines/reference/classAbstractConstructor.errors.txt b/tests/baselines/reference/classAbstractConstructor.errors.txt new file mode 100644 index 0000000000000..fee9f4cefee0d --- /dev/null +++ b/tests/baselines/reference/classAbstractConstructor.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts(2,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts (1 errors) ==== + abstract class A { + abstract constructor() {} + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractConstructor.js b/tests/baselines/reference/classAbstractConstructor.js new file mode 100644 index 0000000000000..fa88b0c7d3796 --- /dev/null +++ b/tests/baselines/reference/classAbstractConstructor.js @@ -0,0 +1,11 @@ +//// [classAbstractConstructor.ts] +abstract class A { + abstract constructor() {} +} + +//// [classAbstractConstructor.js] +var A = (function () { + function A() { + } + return A; +})(); diff --git a/tests/baselines/reference/classAbstractCrashedOnce.errors.txt b/tests/baselines/reference/classAbstractCrashedOnce.errors.txt new file mode 100644 index 0000000000000..c2e38a6cf4472 --- /dev/null +++ b/tests/baselines/reference/classAbstractCrashedOnce.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts(8,5): error TS1003: Identifier expected. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts (1 errors) ==== + abstract class foo { + protected abstract test(); + } + + class bar extends foo { + test() { + this. + } + ~ +!!! error TS1003: Identifier expected. + } + var x = new bar(); \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractCrashedOnce.js b/tests/baselines/reference/classAbstractCrashedOnce.js new file mode 100644 index 0000000000000..f4268a4a13c9f --- /dev/null +++ b/tests/baselines/reference/classAbstractCrashedOnce.js @@ -0,0 +1,35 @@ +//// [classAbstractCrashedOnce.ts] +abstract class foo { + protected abstract test(); +} + +class bar extends foo { + test() { + this. + } +} +var x = new bar(); + +//// [classAbstractCrashedOnce.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var foo = (function () { + function foo() { + } + return foo; +})(); +var bar = (function (_super) { + __extends(bar, _super); + function bar() { + _super.apply(this, arguments); + } + bar.prototype.test = function () { + this. + ; + }; + return bar; +})(foo); +var x = new bar(); diff --git a/tests/baselines/reference/classAbstractDeclarations.d.errors.txt b/tests/baselines/reference/classAbstractDeclarations.d.errors.txt new file mode 100644 index 0000000000000..20d5ca46933e2 --- /dev/null +++ b/tests/baselines/reference/classAbstractDeclarations.d.errors.txt @@ -0,0 +1,43 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(2,28): error TS1184: An implementation cannot be declared in ambient contexts. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(11,15): error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'AA'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(13,15): error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'foo' from class 'BB'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts(17,15): error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'foo' from class 'CC'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts (5 errors) ==== + declare abstract class A { + abstract constructor() {} + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + ~ +!!! error TS1184: An implementation cannot be declared in ambient contexts. + } + + declare abstract class AA { + abstract foo(); + } + + declare abstract class BB extends AA {} + + declare class CC extends AA {} + ~~ +!!! error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'AA'. + + declare class DD extends BB {} + ~~ +!!! error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'foo' from class 'BB'. + + declare abstract class EE extends BB {} + + declare class FF extends CC {} + ~~ +!!! error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'foo' from class 'CC'. + + declare abstract class GG extends CC {} + + declare abstract class AAA {} + + declare abstract class BBB extends AAA {} + + declare class CCC extends AAA {} \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractGeneric.errors.txt b/tests/baselines/reference/classAbstractGeneric.errors.txt new file mode 100644 index 0000000000000..fb5a4c32a39d1 --- /dev/null +++ b/tests/baselines/reference/classAbstractGeneric.errors.txt @@ -0,0 +1,46 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(10,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(10,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'foo' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(12,7): error TS2515: Non-abstract class 'D' does not implement inherited abstract member 'bar' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(12,7): error TS2515: Non-abstract class 'D' does not implement inherited abstract member 'foo' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(14,7): error TS2515: Non-abstract class 'E' does not implement inherited abstract member 'bar' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts(18,7): error TS2515: Non-abstract class 'F' does not implement inherited abstract member 'foo' from class 'A'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts (6 errors) ==== + abstract class A { + t: T; + + abstract foo(): T; + abstract bar(t: T); + } + + abstract class B extends A {} + + class C extends A {} // error -- inherits abstract methods + ~ +!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'A'. + ~ +!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'foo' from class 'A'. + + class D extends A {} // error -- inherits abstract methods + ~ +!!! error TS2515: Non-abstract class 'D' does not implement inherited abstract member 'bar' from class 'A'. + ~ +!!! error TS2515: Non-abstract class 'D' does not implement inherited abstract member 'foo' from class 'A'. + + class E extends A { // error -- doesn't implement bar + ~ +!!! error TS2515: Non-abstract class 'E' does not implement inherited abstract member 'bar' from class 'A'. + foo() { return this.t; } + } + + class F extends A { // error -- doesn't implement foo + ~ +!!! error TS2515: Non-abstract class 'F' does not implement inherited abstract member 'foo' from class 'A'. + bar(t : T) {} + } + + class G extends A { + foo() { return this.t; } + bar(t: T) { } + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractGeneric.js b/tests/baselines/reference/classAbstractGeneric.js new file mode 100644 index 0000000000000..5af7da1601a99 --- /dev/null +++ b/tests/baselines/reference/classAbstractGeneric.js @@ -0,0 +1,84 @@ +//// [classAbstractGeneric.ts] +abstract class A { + t: T; + + abstract foo(): T; + abstract bar(t: T); +} + +abstract class B extends A {} + +class C extends A {} // error -- inherits abstract methods + +class D extends A {} // error -- inherits abstract methods + +class E extends A { // error -- doesn't implement bar + foo() { return this.t; } +} + +class F extends A { // error -- doesn't implement foo + bar(t : T) {} +} + +class G extends A { + foo() { return this.t; } + bar(t: T) { } +} + +//// [classAbstractGeneric.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); // error -- inherits abstract methods +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + return D; +})(A); // error -- inherits abstract methods +var E = (function (_super) { + __extends(E, _super); + function E() { + _super.apply(this, arguments); + } + E.prototype.foo = function () { return this.t; }; + return E; +})(A); +var F = (function (_super) { + __extends(F, _super); + function F() { + _super.apply(this, arguments); + } + F.prototype.bar = function (t) { }; + return F; +})(A); +var G = (function (_super) { + __extends(G, _super); + function G() { + _super.apply(this, arguments); + } + G.prototype.foo = function () { return this.t; }; + G.prototype.bar = function (t) { }; + return G; +})(A); diff --git a/tests/baselines/reference/classAbstractImportInstantiation.errors.txt b/tests/baselines/reference/classAbstractImportInstantiation.errors.txt new file mode 100644 index 0000000000000..76110afa4ff4f --- /dev/null +++ b/tests/baselines/reference/classAbstractImportInstantiation.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts(4,5): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts(9,1): error TS2511: Cannot create an instance of the abstract class 'A'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts (2 errors) ==== + module M { + export abstract class A {} + + new A; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + } + + import myA = M.A; + + new myA; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractImportInstantiation.js b/tests/baselines/reference/classAbstractImportInstantiation.js new file mode 100644 index 0000000000000..bb25181f20d8f --- /dev/null +++ b/tests/baselines/reference/classAbstractImportInstantiation.js @@ -0,0 +1,25 @@ +//// [classAbstractImportInstantiation.ts] +module M { + export abstract class A {} + + new A; +} + +import myA = M.A; + +new myA; + + +//// [classAbstractImportInstantiation.js] +var M; +(function (M) { + var A = (function () { + function A() { + } + return A; + })(); + M.A = A; + new A; +})(M || (M = {})); +var myA = M.A; +new myA; diff --git a/tests/baselines/reference/classAbstractInAModule.errors.txt b/tests/baselines/reference/classAbstractInAModule.errors.txt new file mode 100644 index 0000000000000..426da866087f5 --- /dev/null +++ b/tests/baselines/reference/classAbstractInAModule.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts(6,1): error TS2511: Cannot create an instance of the abstract class 'A'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts (1 errors) ==== + module M { + export abstract class A {} + export class B extends A {} + } + + new M.A; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + new M.B; \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractInAModule.js b/tests/baselines/reference/classAbstractInAModule.js new file mode 100644 index 0000000000000..e7ecd66b5bd04 --- /dev/null +++ b/tests/baselines/reference/classAbstractInAModule.js @@ -0,0 +1,34 @@ +//// [classAbstractInAModule.ts] +module M { + export abstract class A {} + export class B extends A {} +} + +new M.A; +new M.B; + +//// [classAbstractInAModule.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var M; +(function (M) { + var A = (function () { + function A() { + } + return A; + })(); + M.A = A; + var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; + })(A); + M.B = B; +})(M || (M = {})); +new M.A; +new M.B; diff --git a/tests/baselines/reference/classAbstractInheritance.errors.txt b/tests/baselines/reference/classAbstractInheritance.errors.txt new file mode 100644 index 0000000000000..3e1062044150d --- /dev/null +++ b/tests/baselines/reference/classAbstractInheritance.errors.txt @@ -0,0 +1,33 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts(13,7): error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'AA'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts(15,7): error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'foo' from class 'BB'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts(19,7): error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'foo' from class 'CC'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts (3 errors) ==== + abstract class A {} + + abstract class B extends A {} + + class C extends A {} + + abstract class AA { + abstract foo(); + } + + abstract class BB extends AA {} + + class CC extends AA {} + ~~ +!!! error TS2515: Non-abstract class 'CC' does not implement inherited abstract member 'foo' from class 'AA'. + + class DD extends BB {} + ~~ +!!! error TS2515: Non-abstract class 'DD' does not implement inherited abstract member 'foo' from class 'BB'. + + abstract class EE extends BB {} + + class FF extends CC {} + ~~ +!!! error TS2515: Non-abstract class 'FF' does not implement inherited abstract member 'foo' from class 'CC'. + + abstract class GG extends CC {} \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractInheritance.js b/tests/baselines/reference/classAbstractInheritance.js new file mode 100644 index 0000000000000..6656e4687d239 --- /dev/null +++ b/tests/baselines/reference/classAbstractInheritance.js @@ -0,0 +1,95 @@ +//// [classAbstractInheritance.ts] +abstract class A {} + +abstract class B extends A {} + +class C extends A {} + +abstract class AA { + abstract foo(); +} + +abstract class BB extends AA {} + +class CC extends AA {} + +class DD extends BB {} + +abstract class EE extends BB {} + +class FF extends CC {} + +abstract class GG extends CC {} + +//// [classAbstractInheritance.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); +var AA = (function () { + function AA() { + } + return AA; +})(); +var BB = (function (_super) { + __extends(BB, _super); + function BB() { + _super.apply(this, arguments); + } + return BB; +})(AA); +var CC = (function (_super) { + __extends(CC, _super); + function CC() { + _super.apply(this, arguments); + } + return CC; +})(AA); +var DD = (function (_super) { + __extends(DD, _super); + function DD() { + _super.apply(this, arguments); + } + return DD; +})(BB); +var EE = (function (_super) { + __extends(EE, _super); + function EE() { + _super.apply(this, arguments); + } + return EE; +})(BB); +var FF = (function (_super) { + __extends(FF, _super); + function FF() { + _super.apply(this, arguments); + } + return FF; +})(CC); +var GG = (function (_super) { + __extends(GG, _super); + function GG() { + _super.apply(this, arguments); + } + return GG; +})(CC); diff --git a/tests/baselines/reference/classAbstractInstantiations1.errors.txt b/tests/baselines/reference/classAbstractInstantiations1.errors.txt new file mode 100644 index 0000000000000..0221ce07f959a --- /dev/null +++ b/tests/baselines/reference/classAbstractInstantiations1.errors.txt @@ -0,0 +1,28 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(8,1): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'C'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts (2 errors) ==== + + abstract class A {} + + class B extends A {} + + abstract class C extends B {} + + new A; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + new B; + new C; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'C'. + + var a : A; + var b : B; + var c : C; + + a = new B; + b = new B; + c = new B; + \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractInstantiations1.js b/tests/baselines/reference/classAbstractInstantiations1.js new file mode 100644 index 0000000000000..39e6754292641 --- /dev/null +++ b/tests/baselines/reference/classAbstractInstantiations1.js @@ -0,0 +1,55 @@ +//// [classAbstractInstantiations1.ts] + +abstract class A {} + +class B extends A {} + +abstract class C extends B {} + +new A; +new B; +new C; + +var a : A; +var b : B; +var c : C; + +a = new B; +b = new B; +c = new B; + + +//// [classAbstractInstantiations1.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(B); +new A; +new B; +new C; +var a; +var b; +var c; +a = new B; +b = new B; +c = new B; diff --git a/tests/baselines/reference/classAbstractInstantiations2.errors.txt b/tests/baselines/reference/classAbstractInstantiations2.errors.txt new file mode 100644 index 0000000000000..b3b01fd656d9d --- /dev/null +++ b/tests/baselines/reference/classAbstractInstantiations2.errors.txt @@ -0,0 +1,75 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(17,5): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(21,1): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(26,7): error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2391: Function implementation is missing or not immediately following the declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(46,5): error TS2512: Overload signatures must all be abstract or not abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts(50,5): error TS1244: Abstract methods can only appear within an abstract class. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts (7 errors) ==== + class A { + // ... + } + + abstract class B { + foo(): number { return this.bar(); } + abstract bar() : number; + } + + new B; // error + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + + var BB: typeof B = B; + var AA: typeof A = BB; // error, AA is not of abstract type. + new AA; + + function constructB(Factory : typeof B) { + new Factory; // error -- Factory is of type typeof B. + ~~~~~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + } + + var BB = B; + new BB; // error -- BB is of type typeof B. + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + + var x : any = C; + new x; // okay -- undefined behavior at runtime + + class C extends B { } // error -- not declared abstract + ~ +!!! error TS2515: Non-abstract class 'C' does not implement inherited abstract member 'bar' from class 'B'. + + abstract class D extends B { } // okay + + class E extends B { // okay -- implements abstract method + bar() { return 1; } + } + + abstract class F extends B { + abstract foo() : number; + bar() { return 2; } + } + + abstract class G { + abstract qux(x : number) : string; + abstract qux() : number; + y : number; + abstract quz(x : number, y : string) : boolean; // error -- declarations must be adjacent + + abstract nom(): boolean; + nom(x : number): boolean; // error -- use of modifier abstract must match on all overloads. + ~~~ +!!! error TS2391: Function implementation is missing or not immediately following the declaration. + ~~~ +!!! error TS2512: Overload signatures must all be abstract or not abstract. + } + + class H { // error -- not declared abstract + abstract baz() : number; + ~~~~~~~~ +!!! error TS1244: Abstract methods can only appear within an abstract class. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractInstantiations2.js b/tests/baselines/reference/classAbstractInstantiations2.js new file mode 100644 index 0000000000000..1f45f02da0bb0 --- /dev/null +++ b/tests/baselines/reference/classAbstractInstantiations2.js @@ -0,0 +1,121 @@ +//// [classAbstractInstantiations2.ts] +class A { + // ... +} + +abstract class B { + foo(): number { return this.bar(); } + abstract bar() : number; +} + +new B; // error + +var BB: typeof B = B; +var AA: typeof A = BB; // error, AA is not of abstract type. +new AA; + +function constructB(Factory : typeof B) { + new Factory; // error -- Factory is of type typeof B. +} + +var BB = B; +new BB; // error -- BB is of type typeof B. + +var x : any = C; +new x; // okay -- undefined behavior at runtime + +class C extends B { } // error -- not declared abstract + +abstract class D extends B { } // okay + +class E extends B { // okay -- implements abstract method + bar() { return 1; } +} + +abstract class F extends B { + abstract foo() : number; + bar() { return 2; } +} + +abstract class G { + abstract qux(x : number) : string; + abstract qux() : number; + y : number; + abstract quz(x : number, y : string) : boolean; // error -- declarations must be adjacent + + abstract nom(): boolean; + nom(x : number): boolean; // error -- use of modifier abstract must match on all overloads. +} + +class H { // error -- not declared abstract + abstract baz() : number; +} + +//// [classAbstractInstantiations2.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + B.prototype.foo = function () { return this.bar(); }; + return B; +})(); +new B; // error +var BB = B; +var AA = BB; // error, AA is not of abstract type. +new AA; +function constructB(Factory) { + new Factory; // error -- Factory is of type typeof B. +} +var BB = B; +new BB; // error -- BB is of type typeof B. +var x = C; +new x; // okay -- undefined behavior at runtime +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(B); // error -- not declared abstract +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + return D; +})(B); // okay +var E = (function (_super) { + __extends(E, _super); + function E() { + _super.apply(this, arguments); + } + E.prototype.bar = function () { return 1; }; + return E; +})(B); +var F = (function (_super) { + __extends(F, _super); + function F() { + _super.apply(this, arguments); + } + F.prototype.bar = function () { return 2; }; + return F; +})(B); +var G = (function () { + function G() { + } + return G; +})(); +var H = (function () { + function H() { + } + return H; +})(); diff --git a/tests/baselines/reference/classAbstractManyKeywords.errors.txt b/tests/baselines/reference/classAbstractManyKeywords.errors.txt new file mode 100644 index 0000000000000..b200404eaf01a --- /dev/null +++ b/tests/baselines/reference/classAbstractManyKeywords.errors.txt @@ -0,0 +1,19 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(1,1): error TS1148: Cannot compile modules unless the '--module' flag is provided. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(1,25): error TS1005: ';' expected. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(3,1): error TS1128: Declaration or statement expected. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts(4,17): error TS1005: '=' expected. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts (4 errors) ==== + export default abstract class A {} + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1148: Cannot compile modules unless the '--module' flag is provided. + ~~~~~ +!!! error TS1005: ';' expected. + export abstract class B {} + default abstract class C {} + ~~~~~~~ +!!! error TS1128: Declaration or statement expected. + import abstract class D {} + ~~~~~ +!!! error TS1005: '=' expected. \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractManyKeywords.js b/tests/baselines/reference/classAbstractManyKeywords.js new file mode 100644 index 0000000000000..79191c029e1b9 --- /dev/null +++ b/tests/baselines/reference/classAbstractManyKeywords.js @@ -0,0 +1,28 @@ +//// [classAbstractManyKeywords.ts] +export default abstract class A {} +export abstract class B {} +default abstract class C {} +import abstract class D {} + +//// [classAbstractManyKeywords.js] +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); +exports.B = B; +var C = (function () { + function C() { + } + return C; +})(); +var D = (function () { + function D() { + } + return D; +})(); diff --git a/tests/baselines/reference/classAbstractMergedDeclaration.errors.txt b/tests/baselines/reference/classAbstractMergedDeclaration.errors.txt new file mode 100644 index 0000000000000..ca2cc3b8c2d08 --- /dev/null +++ b/tests/baselines/reference/classAbstractMergedDeclaration.errors.txt @@ -0,0 +1,66 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(7,16): error TS2300: Duplicate identifier 'CI'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(8,11): error TS2300: Duplicate identifier 'CI'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(10,11): error TS2300: Duplicate identifier 'IC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(11,16): error TS2300: Duplicate identifier 'IC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(13,16): error TS2300: Duplicate identifier 'CC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(14,7): error TS2300: Duplicate identifier 'CC1'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(16,7): error TS2300: Duplicate identifier 'CC2'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(17,16): error TS2300: Duplicate identifier 'CC2'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(19,1): error TS2511: Cannot create an instance of the abstract class 'CM'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(20,1): error TS2511: Cannot create an instance of the abstract class 'MC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(21,1): error TS2511: Cannot create an instance of the abstract class 'CI'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(22,5): error TS2304: Cannot find name 'IC'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts(23,1): error TS2511: Cannot create an instance of the abstract class 'CC1'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts (13 errors) ==== + abstract class CM {} + module CM {} + + module MC {} + abstract class MC {} + + abstract class CI {} + ~~ +!!! error TS2300: Duplicate identifier 'CI'. + interface CI {} + ~~ +!!! error TS2300: Duplicate identifier 'CI'. + + interface IC {} + ~~ +!!! error TS2300: Duplicate identifier 'IC'. + abstract class IC {} + ~~ +!!! error TS2300: Duplicate identifier 'IC'. + + abstract class CC1 {} + ~~~ +!!! error TS2300: Duplicate identifier 'CC1'. + class CC1 {} + ~~~ +!!! error TS2300: Duplicate identifier 'CC1'. + + class CC2 {} + ~~~ +!!! error TS2300: Duplicate identifier 'CC2'. + abstract class CC2 {} + ~~~ +!!! error TS2300: Duplicate identifier 'CC2'. + + new CM; + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'CM'. + new MC; + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'MC'. + new CI; + ~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'CI'. + new IC; + ~~ +!!! error TS2304: Cannot find name 'IC'. + new CC1; + ~~~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'CC1'. + new CC2; \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMergedDeclaration.js b/tests/baselines/reference/classAbstractMergedDeclaration.js new file mode 100644 index 0000000000000..1b4d6fea342f0 --- /dev/null +++ b/tests/baselines/reference/classAbstractMergedDeclaration.js @@ -0,0 +1,73 @@ +//// [classAbstractMergedDeclaration.ts] +abstract class CM {} +module CM {} + +module MC {} +abstract class MC {} + +abstract class CI {} +interface CI {} + +interface IC {} +abstract class IC {} + +abstract class CC1 {} +class CC1 {} + +class CC2 {} +abstract class CC2 {} + +new CM; +new MC; +new CI; +new IC; +new CC1; +new CC2; + +//// [classAbstractMergedDeclaration.js] +var CM = (function () { + function CM() { + } + return CM; +})(); +var MC = (function () { + function MC() { + } + return MC; +})(); +var CI = (function () { + function CI() { + } + return CI; +})(); +var IC = (function () { + function IC() { + } + return IC; +})(); +var CC1 = (function () { + function CC1() { + } + return CC1; +})(); +var CC1 = (function () { + function CC1() { + } + return CC1; +})(); +var CC2 = (function () { + function CC2() { + } + return CC2; +})(); +var CC2 = (function () { + function CC2() { + } + return CC2; +})(); +new CM; +new MC; +new CI; +new IC; +new CC1; +new CC2; diff --git a/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt b/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt new file mode 100644 index 0000000000000..412378e267d1a --- /dev/null +++ b/tests/baselines/reference/classAbstractMethodWithImplementation.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts(2,5): error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts (1 errors) ==== + abstract class A { + abstract foo() {} + ~~~~~~~~~~~~~~~~~ +!!! error TS1245: Method 'foo' cannot have an implementation because it is marked abstract. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMethodWithImplementation.js b/tests/baselines/reference/classAbstractMethodWithImplementation.js new file mode 100644 index 0000000000000..d931901271230 --- /dev/null +++ b/tests/baselines/reference/classAbstractMethodWithImplementation.js @@ -0,0 +1,12 @@ +//// [classAbstractMethodWithImplementation.ts] +abstract class A { + abstract foo() {} +} + +//// [classAbstractMethodWithImplementation.js] +var A = (function () { + function A() { + } + A.prototype.foo = function () { }; + return A; +})(); diff --git a/tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt b/tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt new file mode 100644 index 0000000000000..121c173963253 --- /dev/null +++ b/tests/baselines/reference/classAbstractMixedWithModifiers.errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(6,13): error TS1243: 'private' modifier cannot be used with 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(8,14): error TS1029: 'public' modifier must precede 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(9,14): error TS1029: 'protected' modifier must precede 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(10,14): error TS1243: 'private' modifier cannot be used with 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(12,14): error TS1243: 'static' modifier cannot be used with 'abstract' modifier. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts(14,12): error TS1243: 'static' modifier cannot be used with 'abstract' modifier. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts (6 errors) ==== + abstract class A { + abstract foo_a(); + + public abstract foo_b(); + protected abstract foo_c(); + private abstract foo_d(); + ~~~~~~~~ +!!! error TS1243: 'private' modifier cannot be used with 'abstract' modifier. + + abstract public foo_bb(); + ~~~~~~ +!!! error TS1029: 'public' modifier must precede 'abstract' modifier. + abstract protected foo_cc(); + ~~~~~~~~~ +!!! error TS1029: 'protected' modifier must precede 'abstract' modifier. + abstract private foo_dd(); + ~~~~~~~ +!!! error TS1243: 'private' modifier cannot be used with 'abstract' modifier. + + abstract static foo_d(); + ~~~~~~ +!!! error TS1243: 'static' modifier cannot be used with 'abstract' modifier. + + static abstract foo_e(); + ~~~~~~~~ +!!! error TS1243: 'static' modifier cannot be used with 'abstract' modifier. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMixedWithModifiers.js b/tests/baselines/reference/classAbstractMixedWithModifiers.js new file mode 100644 index 0000000000000..71eb4c61c048e --- /dev/null +++ b/tests/baselines/reference/classAbstractMixedWithModifiers.js @@ -0,0 +1,23 @@ +//// [classAbstractMixedWithModifiers.ts] +abstract class A { + abstract foo_a(); + + public abstract foo_b(); + protected abstract foo_c(); + private abstract foo_d(); + + abstract public foo_bb(); + abstract protected foo_cc(); + abstract private foo_dd(); + + abstract static foo_d(); + + static abstract foo_e(); +} + +//// [classAbstractMixedWithModifiers.js] +var A = (function () { + function A() { + } + return A; +})(); diff --git a/tests/baselines/reference/classAbstractMultiLineDecl.errors.txt b/tests/baselines/reference/classAbstractMultiLineDecl.errors.txt new file mode 100644 index 0000000000000..5af440ed4df9e --- /dev/null +++ b/tests/baselines/reference/classAbstractMultiLineDecl.errors.txt @@ -0,0 +1,24 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts(10,1): error TS2511: Cannot create an instance of the abstract class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts(11,1): error TS2511: Cannot create an instance of the abstract class 'B'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts(12,1): error TS2511: Cannot create an instance of the abstract class 'C'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts (3 errors) ==== + abstract class A {} + + abstract + class B {} + + abstract + + class C {} + + new A; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'A'. + new B; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'B'. + new C; + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'C'. \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractMultiLineDecl.js b/tests/baselines/reference/classAbstractMultiLineDecl.js new file mode 100644 index 0000000000000..3a92e2aa1e5dc --- /dev/null +++ b/tests/baselines/reference/classAbstractMultiLineDecl.js @@ -0,0 +1,33 @@ +//// [classAbstractMultiLineDecl.ts] +abstract class A {} + +abstract +class B {} + +abstract + +class C {} + +new A; +new B; +new C; + +//// [classAbstractMultiLineDecl.js] +var A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); +var C = (function () { + function C() { + } + return C; +})(); +new A; +new B; +new C; diff --git a/tests/baselines/reference/classAbstractOverloads.errors.txt b/tests/baselines/reference/classAbstractOverloads.errors.txt new file mode 100644 index 0000000000000..0a1c96bd30a5d --- /dev/null +++ b/tests/baselines/reference/classAbstractOverloads.errors.txt @@ -0,0 +1,42 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(7,5): error TS2512: Overload signatures must all be abstract or not abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(10,14): error TS2512: Overload signatures must all be abstract or not abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(12,14): error TS2512: Overload signatures must all be abstract or not abstract. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(15,5): error TS2391: Function implementation is missing or not immediately following the declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts(20,14): error TS2516: All declarations of an abstract method must be consecutive. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts (5 errors) ==== + abstract class A { + abstract foo(); + abstract foo() : number; + abstract foo(); + + abstract bar(); + bar(); + ~~~ +!!! error TS2512: Overload signatures must all be abstract or not abstract. + abstract bar(); + + abstract baz(); + ~~~ +!!! error TS2512: Overload signatures must all be abstract or not abstract. + baz(); + abstract baz(); + ~~~ +!!! error TS2512: Overload signatures must all be abstract or not abstract. + baz() {} + + qux(); + ~~~ +!!! error TS2391: Function implementation is missing or not immediately following the declaration. + } + + abstract class B { + abstract foo() : number; + abstract foo(); + ~~~ +!!! error TS2516: All declarations of an abstract method must be consecutive. + x : number; + abstract foo(); + abstract foo(); + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractOverloads.js b/tests/baselines/reference/classAbstractOverloads.js new file mode 100644 index 0000000000000..1bdff73d5b781 --- /dev/null +++ b/tests/baselines/reference/classAbstractOverloads.js @@ -0,0 +1,38 @@ +//// [classAbstractOverloads.ts] +abstract class A { + abstract foo(); + abstract foo() : number; + abstract foo(); + + abstract bar(); + bar(); + abstract bar(); + + abstract baz(); + baz(); + abstract baz(); + baz() {} + + qux(); +} + +abstract class B { + abstract foo() : number; + abstract foo(); + x : number; + abstract foo(); + abstract foo(); +} + +//// [classAbstractOverloads.js] +var A = (function () { + function A() { + } + A.prototype.baz = function () { }; + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); diff --git a/tests/baselines/reference/classAbstractProperties.errors.txt b/tests/baselines/reference/classAbstractProperties.errors.txt new file mode 100644 index 0000000000000..223a3049825b8 --- /dev/null +++ b/tests/baselines/reference/classAbstractProperties.errors.txt @@ -0,0 +1,34 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(2,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(3,12): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(4,15): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(5,13): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(7,5): error TS1242: 'abstract' modifier can only appear on a class or method declaration. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts(12,13): error TS1243: 'private' modifier cannot be used with 'abstract' modifier. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts (6 errors) ==== + abstract class A { + abstract x : number; + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + public abstract y : number; + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + protected abstract z : number; + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + private abstract w : number; + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + + abstract m: () => void; + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. + + abstract foo_x() : number; + public abstract foo_y() : number; + protected abstract foo_z() : number; + private abstract foo_w() : number; + ~~~~~~~~ +!!! error TS1243: 'private' modifier cannot be used with 'abstract' modifier. + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractProperties.js b/tests/baselines/reference/classAbstractProperties.js new file mode 100644 index 0000000000000..0cbebcf0de0e5 --- /dev/null +++ b/tests/baselines/reference/classAbstractProperties.js @@ -0,0 +1,21 @@ +//// [classAbstractProperties.ts] +abstract class A { + abstract x : number; + public abstract y : number; + protected abstract z : number; + private abstract w : number; + + abstract m: () => void; + + abstract foo_x() : number; + public abstract foo_y() : number; + protected abstract foo_z() : number; + private abstract foo_w() : number; +} + +//// [classAbstractProperties.js] +var A = (function () { + function A() { + } + return A; +})(); diff --git a/tests/baselines/reference/classAbstractSuperCalls.errors.txt b/tests/baselines/reference/classAbstractSuperCalls.errors.txt new file mode 100644 index 0000000000000..a9dbf0f7ba8ce --- /dev/null +++ b/tests/baselines/reference/classAbstractSuperCalls.errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts(14,26): error TS2513: Abstract method 'foo' in class 'B' cannot be accessed via super expression. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts(14,41): error TS2513: Abstract method 'foo' in class 'B' cannot be accessed via super expression. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts (2 errors) ==== + + class A { + foo() { return 1; } + } + + abstract class B extends A { + abstract foo(); + bar() { super.foo(); } + baz() { return this.foo; } + } + + class C extends B { + foo() { return 2; } + qux() { return super.foo() || super.foo; } // 2 errors, foo is abstract + ~~~ +!!! error TS2513: Abstract method 'foo' in class 'B' cannot be accessed via super expression. + ~~~ +!!! error TS2513: Abstract method 'foo' in class 'B' cannot be accessed via super expression. + norf() { return super.bar(); } + } + + class AA { + foo() { return 1; } + bar() { return this.foo(); } + } + + abstract class BB extends AA { + abstract foo(); + // inherits bar. But BB is abstract, so this is OK. + } + \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractSuperCalls.js b/tests/baselines/reference/classAbstractSuperCalls.js new file mode 100644 index 0000000000000..deccaa50ccf27 --- /dev/null +++ b/tests/baselines/reference/classAbstractSuperCalls.js @@ -0,0 +1,74 @@ +//// [classAbstractSuperCalls.ts] + +class A { + foo() { return 1; } +} + +abstract class B extends A { + abstract foo(); + bar() { super.foo(); } + baz() { return this.foo; } +} + +class C extends B { + foo() { return 2; } + qux() { return super.foo() || super.foo; } // 2 errors, foo is abstract + norf() { return super.bar(); } +} + +class AA { + foo() { return 1; } + bar() { return this.foo(); } +} + +abstract class BB extends AA { + abstract foo(); + // inherits bar. But BB is abstract, so this is OK. +} + + +//// [classAbstractSuperCalls.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + A.prototype.foo = function () { return 1; }; + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + B.prototype.bar = function () { _super.prototype.foo.call(this); }; + B.prototype.baz = function () { return this.foo; }; + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + C.prototype.foo = function () { return 2; }; + C.prototype.qux = function () { return _super.prototype.foo.call(this) || _super.prototype.foo; }; // 2 errors, foo is abstract + C.prototype.norf = function () { return _super.prototype.bar.call(this); }; + return C; +})(B); +var AA = (function () { + function AA() { + } + AA.prototype.foo = function () { return 1; }; + AA.prototype.bar = function () { return this.foo(); }; + return AA; +})(); +var BB = (function (_super) { + __extends(BB, _super); + function BB() { + _super.apply(this, arguments); + } + return BB; +})(AA); diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethod1.errors.txt b/tests/baselines/reference/classAbstractUsingAbstractMethod1.errors.txt new file mode 100644 index 0000000000000..df3682a36afb3 --- /dev/null +++ b/tests/baselines/reference/classAbstractUsingAbstractMethod1.errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts(16,5): error TS2511: Cannot create an instance of the abstract class 'C'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts (1 errors) ==== + abstract class A { + abstract foo() : number; + } + + class B extends A { + foo() { return 1; } + } + + abstract class C extends A { + abstract foo() : number; + } + + var a = new B; + a.foo(); + + a = new C; // error, cannot instantiate abstract class. + ~~~~~ +!!! error TS2511: Cannot create an instance of the abstract class 'C'. + a.foo(); \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethod1.js b/tests/baselines/reference/classAbstractUsingAbstractMethod1.js new file mode 100644 index 0000000000000..18d22803a7d73 --- /dev/null +++ b/tests/baselines/reference/classAbstractUsingAbstractMethod1.js @@ -0,0 +1,49 @@ +//// [classAbstractUsingAbstractMethod1.ts] +abstract class A { + abstract foo() : number; +} + +class B extends A { + foo() { return 1; } +} + +abstract class C extends A { + abstract foo() : number; +} + +var a = new B; +a.foo(); + +a = new C; // error, cannot instantiate abstract class. +a.foo(); + +//// [classAbstractUsingAbstractMethod1.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + B.prototype.foo = function () { return 1; }; + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); +var a = new B; +a.foo(); +a = new C; // error, cannot instantiate abstract class. +a.foo(); diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethods2.errors.txt b/tests/baselines/reference/classAbstractUsingAbstractMethods2.errors.txt new file mode 100644 index 0000000000000..e01b233a4c1c0 --- /dev/null +++ b/tests/baselines/reference/classAbstractUsingAbstractMethods2.errors.txt @@ -0,0 +1,39 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts(2,5): error TS1244: Abstract methods can only appear within an abstract class. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts(5,7): error TS2515: Non-abstract class 'B' does not implement inherited abstract member 'foo' from class 'A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts(21,7): error TS2515: Non-abstract class 'BB' does not implement inherited abstract member 'foo' from class 'AA'. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts (3 errors) ==== + class A { + abstract foo(); + ~~~~~~~~ +!!! error TS1244: Abstract methods can only appear within an abstract class. + } + + class B extends A {} + ~ +!!! error TS2515: Non-abstract class 'B' does not implement inherited abstract member 'foo' from class 'A'. + + abstract class C extends A {} + + class D extends A { + foo() {} + } + + abstract class E extends A { + foo() {} + } + + abstract class AA { + abstract foo(); + } + + class BB extends AA {} + ~~ +!!! error TS2515: Non-abstract class 'BB' does not implement inherited abstract member 'foo' from class 'AA'. + + abstract class CC extends AA {} + + class DD extends AA { + foo() {} + } \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractUsingAbstractMethods2.js b/tests/baselines/reference/classAbstractUsingAbstractMethods2.js new file mode 100644 index 0000000000000..d579723292990 --- /dev/null +++ b/tests/baselines/reference/classAbstractUsingAbstractMethods2.js @@ -0,0 +1,97 @@ +//// [classAbstractUsingAbstractMethods2.ts] +class A { + abstract foo(); +} + +class B extends A {} + +abstract class C extends A {} + +class D extends A { + foo() {} +} + +abstract class E extends A { + foo() {} +} + +abstract class AA { + abstract foo(); +} + +class BB extends AA {} + +abstract class CC extends AA {} + +class DD extends AA { + foo() {} +} + +//// [classAbstractUsingAbstractMethods2.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + D.prototype.foo = function () { }; + return D; +})(A); +var E = (function (_super) { + __extends(E, _super); + function E() { + _super.apply(this, arguments); + } + E.prototype.foo = function () { }; + return E; +})(A); +var AA = (function () { + function AA() { + } + return AA; +})(); +var BB = (function (_super) { + __extends(BB, _super); + function BB() { + _super.apply(this, arguments); + } + return BB; +})(AA); +var CC = (function (_super) { + __extends(CC, _super); + function CC() { + _super.apply(this, arguments); + } + return CC; +})(AA); +var DD = (function (_super) { + __extends(DD, _super); + function DD() { + _super.apply(this, arguments); + } + DD.prototype.foo = function () { }; + return DD; +})(AA); diff --git a/tests/baselines/reference/classAbstractWithInterface.errors.txt b/tests/baselines/reference/classAbstractWithInterface.errors.txt new file mode 100644 index 0000000000000..fa0a3d089573d --- /dev/null +++ b/tests/baselines/reference/classAbstractWithInterface.errors.txt @@ -0,0 +1,7 @@ +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts(1,1): error TS1242: 'abstract' modifier can only appear on a class or method declaration. + + +==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts (1 errors) ==== + abstract interface I {} + ~~~~~~~~ +!!! error TS1242: 'abstract' modifier can only appear on a class or method declaration. \ No newline at end of file diff --git a/tests/baselines/reference/classAbstractWithInterface.js b/tests/baselines/reference/classAbstractWithInterface.js new file mode 100644 index 0000000000000..317e393a2f578 --- /dev/null +++ b/tests/baselines/reference/classAbstractWithInterface.js @@ -0,0 +1,4 @@ +//// [classAbstractWithInterface.ts] +abstract interface I {} + +//// [classAbstractWithInterface.js] diff --git a/tests/baselines/reference/computedPropertyNames30_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames30_ES5.errors.txt index 1dfb605db33db..deb80dbcca896 100644 --- a/tests/baselines/reference/computedPropertyNames30_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames30_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts (1 errors) ==== @@ -14,7 +14,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES5.ts(11 //treatment of other similar violations. [(super(), "prop")]() { } ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. }; } } diff --git a/tests/baselines/reference/computedPropertyNames30_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames30_ES6.errors.txt index dc8892fd32628..b10d184f7990e 100644 --- a/tests/baselines/reference/computedPropertyNames30_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames30_ES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11,19): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts (1 errors) ==== @@ -14,7 +14,7 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames30_ES6.ts(11 //treatment of other similar violations. [(super(), "prop")]() { } ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. }; } } diff --git a/tests/baselines/reference/decoratorOnClassMethod12.errors.txt b/tests/baselines/reference/decoratorOnClassMethod12.errors.txt index 14845839089c2..3ad3cabebe20d 100644 --- a/tests/baselines/reference/decoratorOnClassMethod12.errors.txt +++ b/tests/baselines/reference/decoratorOnClassMethod12.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts(6,10): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts(6,10): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts (1 errors) ==== @@ -9,7 +9,7 @@ tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts(6,10 class C extends S { @super.decorator ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. method() { } } } \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.errors.txt b/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.errors.txt index 40610b5b83819..c67bc2479ecd0 100644 --- a/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.errors.txt +++ b/tests/baselines/reference/derivedClassConstructorWithoutSuperCall.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(8,5): error TS2377: Constructors for derived classes must contain a 'super' call. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(17,5): error TS2377: Constructors for derived classes must contain a 'super' call. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(18,24): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(18,24): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(23,5): error TS2377: Constructors for derived classes must contain a 'super' call. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(24,31): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts(24,31): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassConstructorWithoutSuperCall.ts (5 errors) ==== @@ -30,7 +30,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassC var r2 = () => super(); // error for misplaced super call (nested function) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } ~~~~~ !!! error TS2377: Constructors for derived classes must contain a 'super' call. @@ -42,7 +42,7 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassC var r = function () { super() } // error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } ~~~~~ !!! error TS2377: Constructors for derived classes must contain a 'super' call. diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt index f465afbccadc5..ab79f8d3e2354 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt @@ -1,13 +1,13 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,8): error TS1110: Type expected. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,8): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(10,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(13,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(17,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,8): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(10,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(13,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(17,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,15): error TS1110: Type expected. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,15): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(22,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(25,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(29,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,15): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(22,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(25,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(29,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts (10 errors) ==== @@ -22,43 +22,43 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassS ~~~~~ !!! error TS1110: Type expected. ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. b() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } get C() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return 1; } set C(v) { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } static a: super(); ~~~~~ !!! error TS1110: Type expected. ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. static b() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } static get C() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return 1; } static set C(v) { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } } \ No newline at end of file diff --git a/tests/baselines/reference/emitThisInSuperMethodCall.errors.txt b/tests/baselines/reference/emitThisInSuperMethodCall.errors.txt index 7fe090395e375..06211ef771ff0 100644 --- a/tests/baselines/reference/emitThisInSuperMethodCall.errors.txt +++ b/tests/baselines/reference/emitThisInSuperMethodCall.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/emitThisInSuperMethodCall.ts(10,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/compiler/emitThisInSuperMethodCall.ts(17,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/compiler/emitThisInSuperMethodCall.ts(10,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/compiler/emitThisInSuperMethodCall.ts(17,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ==== tests/cases/compiler/emitThisInSuperMethodCall.ts (3 errors) ==== @@ -15,7 +15,7 @@ tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' function inner() { super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } }; } @@ -24,7 +24,7 @@ tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' () => { super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } } } @@ -32,7 +32,7 @@ tests/cases/compiler/emitThisInSuperMethodCall.ts(23,13): error TS2338: 'super' function inner() { super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } } } diff --git a/tests/baselines/reference/errorSuperCalls.errors.txt b/tests/baselines/reference/errorSuperCalls.errors.txt index cd1aa23f14df9..9ecc7a1565eb5 100644 --- a/tests/baselines/reference/errorSuperCalls.errors.txt +++ b/tests/baselines/reference/errorSuperCalls.errors.txt @@ -8,10 +8,10 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(30,16): error tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(34,9): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(38,9): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(46,14): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(58,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(62,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(67,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(58,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(62,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(67,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts (14 errors) ==== @@ -94,26 +94,26 @@ tests/cases/conformance/expressions/superCalls/errorSuperCalls.ts(71,9): error T //super call in class member initializer of derived type t = super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. fn() { //super call in class member function of derived type super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } //super call in class accessor (get and set) of derived type get foo() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return null; } set foo(n) { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } } \ No newline at end of file diff --git a/tests/baselines/reference/errorSuperPropertyAccess.errors.txt b/tests/baselines/reference/errorSuperPropertyAccess.errors.txt index b273b1b6f45c8..c34ed9120463e 100644 --- a/tests/baselines/reference/errorSuperPropertyAccess.errors.txt +++ b/tests/baselines/reference/errorSuperPropertyAccess.errors.txt @@ -9,30 +9,30 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(25,9): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(29,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(30,9): error TS2335: 'super' can only be referenced in a derived class. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(57,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(61,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(57,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(61,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(64,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(65,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(65,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(68,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(69,19): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(73,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(76,40): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(87,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(91,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(69,19): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(73,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(76,40): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(87,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(91,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(94,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(95,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(95,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(98,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(99,19): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(109,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(110,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(99,19): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(109,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(110,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(111,9): error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(113,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(114,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(115,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(114,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(115,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(116,9): error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(119,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(120,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(121,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(120,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(121,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(122,9): error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(127,16): error TS2335: 'super' can only be referenced in a derived class. tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(127,30): error TS2335: 'super' can only be referenced in a derived class. @@ -119,13 +119,13 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess super(); super.publicMember = 1; ~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } fn() { var x = super.publicMember; ~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } get a() { @@ -133,7 +133,7 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. var x = super.publicMember; ~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. return undefined; } set a(n) { @@ -141,18 +141,18 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. n = super.publicMember; ~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } fn2() { function inner() { super.publicFunc(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } var x = { test: function () { return super.publicFunc(); } ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } } } @@ -165,13 +165,13 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess super(); super.privateMember = 1; ~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } fn() { var x = super.privateMember; ~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } get a() { @@ -179,7 +179,7 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. var x = super.privateMember; ~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. return undefined; } set a(n) { @@ -187,7 +187,7 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. n = super.privateMember; ~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } @@ -199,10 +199,10 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess static fn() { super.publicStaticMember = 3; ~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticMember = 3; ~~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticFunc(); ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. @@ -212,10 +212,10 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. super.publicStaticMember = 3; ~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticMember = 3; ~~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticFunc(); ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. @@ -226,10 +226,10 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. super.publicStaticMember = 3; ~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticMember = 3; ~~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.privateStaticFunc(); ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. diff --git a/tests/baselines/reference/illegalSuperCallsInConstructor.errors.txt b/tests/baselines/reference/illegalSuperCallsInConstructor.errors.txt index a07fbea75d851..1d3d2e7c2754c 100644 --- a/tests/baselines/reference/illegalSuperCallsInConstructor.errors.txt +++ b/tests/baselines/reference/illegalSuperCallsInConstructor.errors.txt @@ -1,11 +1,11 @@ tests/cases/compiler/illegalSuperCallsInConstructor.ts(6,5): error TS2377: Constructors for derived classes must contain a 'super' call. -tests/cases/compiler/illegalSuperCallsInConstructor.ts(7,24): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/compiler/illegalSuperCallsInConstructor.ts(8,26): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/compiler/illegalSuperCallsInConstructor.ts(9,32): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/compiler/illegalSuperCallsInConstructor.ts(7,24): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/compiler/illegalSuperCallsInConstructor.ts(8,26): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/compiler/illegalSuperCallsInConstructor.ts(9,32): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/compiler/illegalSuperCallsInConstructor.ts(11,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/illegalSuperCallsInConstructor.ts(12,17): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/compiler/illegalSuperCallsInConstructor.ts(12,17): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. tests/cases/compiler/illegalSuperCallsInConstructor.ts(15,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/compiler/illegalSuperCallsInConstructor.ts (8 errors) ==== @@ -19,15 +19,15 @@ tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Sup var r2 = () => super(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. var r3 = () => { super(); } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. var r4 = function () { super(); } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. var r5 = { ~~~~~~~~~~~~~~~~~~ get foo() { @@ -37,7 +37,7 @@ tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Sup super(); ~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return 1; ~~~~~~~~~~~~~~~~~~~~~~~~~ }, @@ -49,7 +49,7 @@ tests/cases/compiler/illegalSuperCallsInConstructor.ts(16,17): error TS2337: Sup super(); ~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } ~~~~~~~~~~~~~ } diff --git a/tests/baselines/reference/parserAstSpans1.errors.txt b/tests/baselines/reference/parserAstSpans1.errors.txt index 9697dcbc1282b..648929e974e3e 100644 --- a/tests/baselines/reference/parserAstSpans1.errors.txt +++ b/tests/baselines/reference/parserAstSpans1.errors.txt @@ -2,10 +2,10 @@ tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(79,16): error TS10 tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(85,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(94,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(100,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(111,25): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(111,25): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(119,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(125,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts (8 errors) ==== @@ -129,7 +129,7 @@ tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2 super(10); this.p1 = super.c2_p1; ~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } /** c3 p1*/ public p1: number; @@ -241,6 +241,6 @@ tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2 super(); this.d = super.b; ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } \ No newline at end of file diff --git a/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt b/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt index f29ee917ea7f4..7893100b5a589 100644 --- a/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt +++ b/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(6,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(8,22): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(6,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(8,22): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(10,15): error TS1003: Identifier expected. -tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(10,21): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(10,21): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(12,8): error TS1110: Type expected. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(12,8): error TS2341: Property 'foo' is private and only accessible within class 'Base'. @@ -14,17 +14,17 @@ tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAcces class Derived extends Base { x = super.foo; // error ~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. y() { return super.foo; // error ~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } z: typeof super.foo; // error ~~~~~ !!! error TS1003: Identifier expected. ~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. a: this.foo; // error ~~~~ diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.errors.txt b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.errors.txt index f2b19d043c27a..897636b6d90c1 100644 --- a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.errors.txt +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass3.ts(11,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass3.ts(11,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass3.ts (1 errors) ==== @@ -14,6 +14,6 @@ tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAcce this.x; // OK, accessed within a subclass of the declaring class super.x; // Error, x is not public ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } \ No newline at end of file diff --git a/tests/baselines/reference/protectedInstanceMemberAccessibility.errors.txt b/tests/baselines/reference/protectedInstanceMemberAccessibility.errors.txt index 03671925febc1..4b950c70019b0 100644 --- a/tests/baselines/reference/protectedInstanceMemberAccessibility.errors.txt +++ b/tests/baselines/reference/protectedInstanceMemberAccessibility.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(14,23): error TS2339: Property 'z' does not exist on type 'B'. -tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(16,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(16,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(18,24): error TS2339: Property 'y' does not exist on type 'A'. tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(19,24): error TS2339: Property 'z' does not exist on type 'A'. tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(22,18): error TS2446: Property 'x' is protected and only accessible through an instance of class 'B'. @@ -33,7 +33,7 @@ tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAcc var s1 = super.x; // error ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. var s2 = super.f(); var s3 = super.y; // error ~ diff --git a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.errors.txt b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.errors.txt index 1f1bd72617c12..b6fa239f2910f 100644 --- a/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.errors.txt +++ b/tests/baselines/reference/protectedStaticClassPropertyAccessibleWithinSubclass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass2.ts(11,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass2.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass2.ts(11,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass2.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/conformance/classes/members/accessibility/protectedStaticClassPropertyAccessibleWithinSubclass2.ts (2 errors) ==== @@ -15,7 +15,7 @@ tests/cases/conformance/classes/members/accessibility/protectedStaticClassProper this.x; // OK, accessed within a class derived from their declaring class super.x; // Error, x is not public ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } @@ -25,6 +25,6 @@ tests/cases/conformance/classes/members/accessibility/protectedStaticClassProper this.x; // OK, accessed within a class derived from their declaring class super.x; // Error, x is not public ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } \ No newline at end of file diff --git a/tests/baselines/reference/superAccess.errors.txt b/tests/baselines/reference/superAccess.errors.txt index 64c921e0e7f99..f506bb9f13648 100644 --- a/tests/baselines/reference/superAccess.errors.txt +++ b/tests/baselines/reference/superAccess.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/superAccess.ts(9,24): error TS2339: Property 'S1' does not exist on type 'MyBase'. -tests/cases/compiler/superAccess.ts(10,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superAccess.ts(11,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superAccess.ts(10,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superAccess.ts(11,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/compiler/superAccess.ts (3 errors) ==== @@ -17,9 +17,9 @@ tests/cases/compiler/superAccess.ts(11,24): error TS2340: Only public and protec !!! error TS2339: Property 'S1' does not exist on type 'MyBase'. var l4 = super.S2; // Expected => Error: Only public instance methods of the base class are accessible via the 'super' keyword ~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. var l5 = super.f(); // Expected => Error: Only public instance methods of the base class are accessible via the 'super' keyword ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } \ No newline at end of file diff --git a/tests/baselines/reference/superAccess2.errors.txt b/tests/baselines/reference/superAccess2.errors.txt index eda3e29bb0a88..d8b39284f6567 100644 --- a/tests/baselines/reference/superAccess2.errors.txt +++ b/tests/baselines/reference/superAccess2.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/superAccess2.ts(7,15): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/compiler/superAccess2.ts(8,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/compiler/superAccess2.ts(8,17): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. tests/cases/compiler/superAccess2.ts(8,22): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superAccess2.ts(11,28): error TS2336: 'super' cannot be referenced in constructor arguments. tests/cases/compiler/superAccess2.ts(11,33): error TS1034: 'super' must be followed by an argument list or member access. @@ -25,7 +25,7 @@ tests/cases/compiler/superAccess2.ts(21,15): error TS2339: Property 'x' does not !!! error TS1034: 'super' must be followed by an argument list or member access. static yy = super; // error for static initializer accessing super ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. diff --git a/tests/baselines/reference/superCallOutsideConstructor.errors.txt b/tests/baselines/reference/superCallOutsideConstructor.errors.txt index 2cdcaad189163..c22c4d33b5db9 100644 --- a/tests/baselines/reference/superCallOutsideConstructor.errors.txt +++ b/tests/baselines/reference/superCallOutsideConstructor.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/superCallOutsideConstructor.ts(6,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/compiler/superCallOutsideConstructor.ts(12,13): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors -tests/cases/compiler/superCallOutsideConstructor.ts(16,13): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +tests/cases/compiler/superCallOutsideConstructor.ts(6,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/compiler/superCallOutsideConstructor.ts(12,13): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/compiler/superCallOutsideConstructor.ts(16,13): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. ==== tests/cases/compiler/superCallOutsideConstructor.ts (3 errors) ==== @@ -11,7 +11,7 @@ tests/cases/compiler/superCallOutsideConstructor.ts(16,13): error TS2337: Super class D extends C { x = super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. constructor() { super(); @@ -19,13 +19,13 @@ tests/cases/compiler/superCallOutsideConstructor.ts(16,13): error TS2337: Super var y = () => { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } var y2 = function() { super(); ~~~~~ -!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } } } diff --git a/tests/baselines/reference/superErrors.errors.txt b/tests/baselines/reference/superErrors.errors.txt index fad592b490cc7..26e0ba3a6c410 100644 --- a/tests/baselines/reference/superErrors.errors.txt +++ b/tests/baselines/reference/superErrors.errors.txt @@ -4,12 +4,12 @@ tests/cases/compiler/superErrors.ts(4,19): error TS2335: 'super' can only be ref tests/cases/compiler/superErrors.ts(4,24): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superErrors.ts(5,31): error TS2335: 'super' can only be referenced in a derived class. tests/cases/compiler/superErrors.ts(5,36): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/compiler/superErrors.ts(22,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/compiler/superErrors.ts(27,27): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/compiler/superErrors.ts(31,36): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/compiler/superErrors.ts(22,13): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/compiler/superErrors.ts(27,27): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/compiler/superErrors.ts(31,36): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. tests/cases/compiler/superErrors.ts(31,41): error TS1034: 'super' must be followed by an argument list or member access. -tests/cases/compiler/superErrors.ts(39,27): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class -tests/cases/compiler/superErrors.ts(43,36): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/compiler/superErrors.ts(39,27): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. +tests/cases/compiler/superErrors.ts(43,36): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. tests/cases/compiler/superErrors.ts(43,41): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superErrors.ts(47,22): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superErrors.ts(48,28): error TS1034: 'super' must be followed by an argument list or member access. @@ -52,20 +52,20 @@ tests/cases/compiler/superErrors.ts(49,40): error TS1034: 'super' must be follow function inner() { super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } // super call in a lambda in an inner function in a constructor function inner2() { var x = () => super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } // super call in a lambda in a function expression in a constructor (function() { return () => super; })(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. } @@ -77,13 +77,13 @@ tests/cases/compiler/superErrors.ts(49,40): error TS1034: 'super' must be follow function inner() { var x = () => super.sayHello(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } // super call in a lambda in a function expression in a constructor (function() { return () => super; })(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ~ !!! error TS1034: 'super' must be followed by an argument list or member access. } diff --git a/tests/baselines/reference/superInLambdas.errors.txt b/tests/baselines/reference/superInLambdas.errors.txt index 7587ed82ef11e..a3863d00c02b9 100644 --- a/tests/baselines/reference/superInLambdas.errors.txt +++ b/tests/baselines/reference/superInLambdas.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/superInLambdas.ts(47,49): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superInLambdas.ts(51,49): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superInLambdas.ts(47,49): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superInLambdas.ts(51,49): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/compiler/superInLambdas.ts(61,34): error TS1034: 'super' must be followed by an argument list or member access. tests/cases/compiler/superInLambdas.ts(65,34): error TS1034: 'super' must be followed by an argument list or member access. @@ -53,13 +53,13 @@ tests/cases/compiler/superInLambdas.ts(65,34): error TS1034: 'super' must be fol // super property in a nested lambda in a constructor var superName = () => () => () => super.name; ~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } sayHello(): void { // super property in a nested lambda in a method var superName = () => () => () => super.name; ~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } diff --git a/tests/baselines/reference/superPropertyAccess.errors.txt b/tests/baselines/reference/superPropertyAccess.errors.txt index 4880bf66f17c4..41e0a0adac53a 100644 --- a/tests/baselines/reference/superPropertyAccess.errors.txt +++ b/tests/baselines/reference/superPropertyAccess.errors.txt @@ -1,11 +1,11 @@ tests/cases/compiler/superPropertyAccess.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/superPropertyAccess.ts(9,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/superPropertyAccess.ts(22,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess.ts(22,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/compiler/superPropertyAccess.ts(24,9): error TS2341: Property 'p1' is private and only accessible within class 'MyBase'. -tests/cases/compiler/superPropertyAccess.ts(26,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess.ts(28,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess.ts(32,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess.ts(34,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess.ts(26,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superPropertyAccess.ts(28,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superPropertyAccess.ts(32,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superPropertyAccess.ts(34,23): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/compiler/superPropertyAccess.ts (8 errors) ==== @@ -36,7 +36,7 @@ tests/cases/compiler/superPropertyAccess.ts(34,23): error TS2340: Only public an super.m2.bind(this); // Should error, instance property, not a public instance member function ~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.p1(); // Should error, private not public instance member function ~~~~~~~~ @@ -44,20 +44,20 @@ tests/cases/compiler/superPropertyAccess.ts(34,23): error TS2340: Only public an var l1 = super.d1; // Should error, instance data property not a public instance member function ~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. var l1 = super.d2; // Should error, instance data property not a public instance member function ~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. super.m1 = function (a: string) { return ""; }; // Should be allowed, we will not restrict assignment super.value = 0; // Should error, instance data property not a public instance member function ~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. var z = super.value; // Should error, instance data property not a public instance member function ~~~~~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } } \ No newline at end of file diff --git a/tests/baselines/reference/superPropertyAccess1.errors.txt b/tests/baselines/reference/superPropertyAccess1.errors.txt index b256860ec72e3..aed25fd6a92c8 100644 --- a/tests/baselines/reference/superPropertyAccess1.errors.txt +++ b/tests/baselines/reference/superPropertyAccess1.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/superPropertyAccess1.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/superPropertyAccess1.ts(13,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess1.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess1.ts(13,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. +tests/cases/compiler/superPropertyAccess1.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/compiler/superPropertyAccess1.ts(22,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. ==== tests/cases/compiler/superPropertyAccess1.ts (5 errors) ==== @@ -22,7 +22,7 @@ tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public a super.bar(); super.x; // error ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } constructor() { @@ -30,7 +30,7 @@ tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public a super.bar(); super.x; // error ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } public get y() { @@ -39,7 +39,7 @@ tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public a super.bar(); super.x; // error ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. return 1; } } \ No newline at end of file diff --git a/tests/baselines/reference/superPropertyAccess2.errors.txt b/tests/baselines/reference/superPropertyAccess2.errors.txt index 475705f150610..2512ad91faec1 100644 --- a/tests/baselines/reference/superPropertyAccess2.errors.txt +++ b/tests/baselines/reference/superPropertyAccess2.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/superPropertyAccess2.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/superPropertyAccess2.ts(13,15): error TS2339: Property 'x' does not exist on type 'typeof C'. tests/cases/compiler/superPropertyAccess2.ts(18,15): error TS2339: Property 'bar' does not exist on type 'C'. -tests/cases/compiler/superPropertyAccess2.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +tests/cases/compiler/superPropertyAccess2.ts(19,15): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. tests/cases/compiler/superPropertyAccess2.ts(22,23): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/superPropertyAccess2.ts(24,15): error TS2339: Property 'x' does not exist on type 'typeof C'. @@ -33,7 +33,7 @@ tests/cases/compiler/superPropertyAccess2.ts(24,15): error TS2339: Property 'x' !!! error TS2339: Property 'bar' does not exist on type 'C'. super.x; // error ~ -!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword +!!! error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword. } public static get y() { diff --git a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt index 44332e6e56725..4f1faf78a7823 100644 --- a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt +++ b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(7,13): e tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(8,13): error TS2335: 'super' can only be referenced in a derived class. tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(11,20): error TS2335: 'super' can only be referenced in a derived class. tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(20,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. ==== tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts (7 errors) ==== @@ -42,7 +42,7 @@ tests/cases/compiler/super_inside-object-literal-getters-and-setters.ts(21,24): !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. return super.test(); ~~~~~ -!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class +!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class. } }; } diff --git a/tests/cases/compiler/abstractIdentifierNameStrict.ts b/tests/cases/compiler/abstractIdentifierNameStrict.ts new file mode 100644 index 0000000000000..c75fbf4304324 --- /dev/null +++ b/tests/cases/compiler/abstractIdentifierNameStrict.ts @@ -0,0 +1,6 @@ +var abstract = true; + +function foo() { + "use strict"; + var abstract = true; +} \ No newline at end of file diff --git a/tests/cases/compiler/abstractInterfaceIdentifierName.ts b/tests/cases/compiler/abstractInterfaceIdentifierName.ts new file mode 100644 index 0000000000000..c7bdc100ccfb6 --- /dev/null +++ b/tests/cases/compiler/abstractInterfaceIdentifierName.ts @@ -0,0 +1,4 @@ + +interface abstract { + abstract(): void; +} diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts new file mode 100644 index 0000000000000..4c251a03c366d --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAsIdentifier.ts @@ -0,0 +1,5 @@ +class abstract { + foo() { return 1; } +} + +new abstract; \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts new file mode 100644 index 0000000000000..f53b1a3a93760 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractConstructor.ts @@ -0,0 +1,3 @@ +abstract class A { + abstract constructor() {} +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts new file mode 100644 index 0000000000000..747b8dafe6ec3 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractCrashedOnce.ts @@ -0,0 +1,10 @@ +abstract class foo { + protected abstract test(); +} + +class bar extends foo { + test() { + this. + } +} +var x = new bar(); \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts new file mode 100644 index 0000000000000..14dfd1d86d840 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractDeclarations.d.ts @@ -0,0 +1,25 @@ +declare abstract class A { + abstract constructor() {} +} + +declare abstract class AA { + abstract foo(); +} + +declare abstract class BB extends AA {} + +declare class CC extends AA {} + +declare class DD extends BB {} + +declare abstract class EE extends BB {} + +declare class FF extends CC {} + +declare abstract class GG extends CC {} + +declare abstract class AAA {} + +declare abstract class BBB extends AAA {} + +declare class CCC extends AAA {} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts new file mode 100644 index 0000000000000..f69ea30d0d69d --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractGeneric.ts @@ -0,0 +1,25 @@ +abstract class A { + t: T; + + abstract foo(): T; + abstract bar(t: T); +} + +abstract class B extends A {} + +class C extends A {} // error -- inherits abstract methods + +class D extends A {} // error -- inherits abstract methods + +class E extends A { // error -- doesn't implement bar + foo() { return this.t; } +} + +class F extends A { // error -- doesn't implement foo + bar(t : T) {} +} + +class G extends A { + foo() { return this.t; } + bar(t: T) { } +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts new file mode 100644 index 0000000000000..165a3d7a2e6ce --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractImportInstantiation.ts @@ -0,0 +1,9 @@ +module M { + export abstract class A {} + + new A; +} + +import myA = M.A; + +new myA; diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts new file mode 100644 index 0000000000000..f31dd41436ebb --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInAModule.ts @@ -0,0 +1,7 @@ +module M { + export abstract class A {} + export class B extends A {} +} + +new M.A; +new M.B; \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts new file mode 100644 index 0000000000000..ced15607f84f9 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInheritance.ts @@ -0,0 +1,21 @@ +abstract class A {} + +abstract class B extends A {} + +class C extends A {} + +abstract class AA { + abstract foo(); +} + +abstract class BB extends AA {} + +class CC extends AA {} + +class DD extends BB {} + +abstract class EE extends BB {} + +class FF extends CC {} + +abstract class GG extends CC {} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts new file mode 100644 index 0000000000000..c9ca4afb18d88 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations1.ts @@ -0,0 +1,18 @@ + +abstract class A {} + +class B extends A {} + +abstract class C extends B {} + +new A; +new B; +new C; + +var a : A; +var b : B; +var c : C; + +a = new B; +b = new B; +c = new B; diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts new file mode 100644 index 0000000000000..3b68b898b94d6 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractInstantiations2.ts @@ -0,0 +1,51 @@ +class A { + // ... +} + +abstract class B { + foo(): number { return this.bar(); } + abstract bar() : number; +} + +new B; // error + +var BB: typeof B = B; +var AA: typeof A = BB; // error, AA is not of abstract type. +new AA; + +function constructB(Factory : typeof B) { + new Factory; // error -- Factory is of type typeof B. +} + +var BB = B; +new BB; // error -- BB is of type typeof B. + +var x : any = C; +new x; // okay -- undefined behavior at runtime + +class C extends B { } // error -- not declared abstract + +abstract class D extends B { } // okay + +class E extends B { // okay -- implements abstract method + bar() { return 1; } +} + +abstract class F extends B { + abstract foo() : number; + bar() { return 2; } +} + +abstract class G { + abstract qux(x : number) : string; + abstract qux() : number; + y : number; + abstract quz(x : number, y : string) : boolean; // error -- declarations must be adjacent + + abstract nom(): boolean; + nom(x : number): boolean; // error -- use of modifier abstract must match on all overloads. +} + +class H { // error -- not declared abstract + abstract baz() : number; +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts new file mode 100644 index 0000000000000..2a6fd46a08d01 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractManyKeywords.ts @@ -0,0 +1,4 @@ +export default abstract class A {} +export abstract class B {} +default abstract class C {} +import abstract class D {} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts new file mode 100644 index 0000000000000..160c0de298bb3 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMergedDeclaration.ts @@ -0,0 +1,24 @@ +abstract class CM {} +module CM {} + +module MC {} +abstract class MC {} + +abstract class CI {} +interface CI {} + +interface IC {} +abstract class IC {} + +abstract class CC1 {} +class CC1 {} + +class CC2 {} +abstract class CC2 {} + +new CM; +new MC; +new CI; +new IC; +new CC1; +new CC2; \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts new file mode 100644 index 0000000000000..432613ca04bab --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts @@ -0,0 +1,3 @@ +abstract class A { + abstract foo() {} +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts new file mode 100644 index 0000000000000..d3c2546ac9054 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMixedWithModifiers.ts @@ -0,0 +1,15 @@ +abstract class A { + abstract foo_a(); + + public abstract foo_b(); + protected abstract foo_c(); + private abstract foo_d(); + + abstract public foo_bb(); + abstract protected foo_cc(); + abstract private foo_dd(); + + abstract static foo_d(); + + static abstract foo_e(); +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts new file mode 100644 index 0000000000000..374a3c089ef79 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMultiLineDecl.ts @@ -0,0 +1,12 @@ +abstract class A {} + +abstract +class B {} + +abstract + +class C {} + +new A; +new B; +new C; \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts new file mode 100644 index 0000000000000..c30a03f8217a8 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractOverloads.ts @@ -0,0 +1,24 @@ +abstract class A { + abstract foo(); + abstract foo() : number; + abstract foo(); + + abstract bar(); + bar(); + abstract bar(); + + abstract baz(); + baz(); + abstract baz(); + baz() {} + + qux(); +} + +abstract class B { + abstract foo() : number; + abstract foo(); + x : number; + abstract foo(); + abstract foo(); +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts new file mode 100644 index 0000000000000..e6dc355adb97e --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractProperties.ts @@ -0,0 +1,13 @@ +abstract class A { + abstract x : number; + public abstract y : number; + protected abstract z : number; + private abstract w : number; + + abstract m: () => void; + + abstract foo_x() : number; + public abstract foo_y() : number; + protected abstract foo_z() : number; + private abstract foo_w() : number; +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts new file mode 100644 index 0000000000000..e93a670b55fac --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractSuperCalls.ts @@ -0,0 +1,26 @@ + +class A { + foo() { return 1; } +} + +abstract class B extends A { + abstract foo(); + bar() { super.foo(); } + baz() { return this.foo; } +} + +class C extends B { + foo() { return 2; } + qux() { return super.foo() || super.foo; } // 2 errors, foo is abstract + norf() { return super.bar(); } +} + +class AA { + foo() { return 1; } + bar() { return this.foo(); } +} + +abstract class BB extends AA { + abstract foo(); + // inherits bar. But BB is abstract, so this is OK. +} diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts new file mode 100644 index 0000000000000..8561fa2ce15e7 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethod1.ts @@ -0,0 +1,17 @@ +abstract class A { + abstract foo() : number; +} + +class B extends A { + foo() { return 1; } +} + +abstract class C extends A { + abstract foo() : number; +} + +var a = new B; +a.foo(); + +a = new C; // error, cannot instantiate abstract class. +a.foo(); \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts new file mode 100644 index 0000000000000..e333811c67f1e --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractUsingAbstractMethods2.ts @@ -0,0 +1,27 @@ +class A { + abstract foo(); +} + +class B extends A {} + +abstract class C extends A {} + +class D extends A { + foo() {} +} + +abstract class E extends A { + foo() {} +} + +abstract class AA { + abstract foo(); +} + +class BB extends AA {} + +abstract class CC extends AA {} + +class DD extends AA { + foo() {} +} \ No newline at end of file diff --git a/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts new file mode 100644 index 0000000000000..17b8986894320 --- /dev/null +++ b/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractWithInterface.ts @@ -0,0 +1 @@ +abstract interface I {} \ No newline at end of file