diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index bae4b6abb3c61..3959335542c68 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -226,7 +226,7 @@ module ts { function bindConstructorDeclaration(node: ConstructorDeclaration) { bindDeclaration(node, SymbolFlags.Constructor, 0); forEach(node.parameters, p => { - if (p.flags & (NodeFlags.Public | NodeFlags.Private)) { + if (p.flags & (NodeFlags.Public | NodeFlags.Private | NodeFlags.Protected)) { bindDeclaration(p, SymbolFlags.Property, SymbolFlags.PropertyExcludes); } }); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f1458091df536..cc02323b291ae 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1282,8 +1282,8 @@ module ts { case SyntaxKind.Property: case SyntaxKind.Method: - if (node.flags & NodeFlags.Private) { - // Private properties/methods are not visible + if (node.flags & (NodeFlags.Private | NodeFlags.Protected)) { + // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so let it fall into next case statement @@ -2708,22 +2708,19 @@ module ts { } function isPropertyIdenticalToRecursive(sourceProp: Symbol, targetProp: Symbol, reportErrors: boolean, relate: (source: Type, target: Type, reportErrors: boolean) => boolean): boolean { - Debug.assert(sourceProp); - if (!targetProp) { - return false; - } - // Two members are considered identical when // - they are public properties with identical names, optionality, and types, - // - they are private properties originating in the same declaration and having identical types - var sourcePropIsPrivate = getDeclarationFlagsFromSymbol(sourceProp) & NodeFlags.Private; - var targetPropIsPrivate = getDeclarationFlagsFromSymbol(targetProp) & NodeFlags.Private; - if (sourcePropIsPrivate !== targetPropIsPrivate) { + // - they are private or protected properties originating in the same declaration and having identical types + if (sourceProp === targetProp) { + return true; + } + var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (NodeFlags.Private | NodeFlags.Protected); + var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (NodeFlags.Private | NodeFlags.Protected); + if (sourcePropAccessibility !== targetPropAccessibility) { return false; } - - if (sourcePropIsPrivate) { - return (getTargetSymbol(sourceProp).parent === getTargetSymbol(targetProp).parent) && relate(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors); + if (sourcePropAccessibility) { + return getTargetSymbol(sourceProp) === getTargetSymbol(targetProp) && relate(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors); } else { return isOptionalProperty(sourceProp) === isOptionalProperty(targetProp) && relate(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors); @@ -2749,8 +2746,8 @@ module ts { } return result; - function reportError(message: DiagnosticMessage, arg0?: string, arg1?: string): void { - errorInfo = chainDiagnosticMessages(errorInfo, message, arg0, arg1); + function reportError(message: DiagnosticMessage, arg0?: string, arg1?: string, arg2?: string): void { + errorInfo = chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } function isRelatedTo(source: Type, target: Type, reportErrors: boolean): boolean { @@ -2922,25 +2919,18 @@ module ts { } function propertiesAreIdenticalTo(source: ObjectType, target: ObjectType, reportErrors: boolean): boolean { - if (source === target) { - return true; - } - var sourceProperties = getPropertiesOfType(source); var targetProperties = getPropertiesOfType(target); if (sourceProperties.length !== targetProperties.length) { return false; } - for (var i = 0, len = sourceProperties.length; i < len; ++i) { var sourceProp = sourceProperties[i]; var targetProp = getPropertyOfType(target, sourceProp.name); - - if (!isPropertyIdenticalToRecursive(sourceProp, targetProp, reportErrors, isRelatedTo)) { + if (!targetProp || !isPropertyIdenticalToRecursive(sourceProp, targetProp, reportErrors, isRelatedTo)) { return false; } } - return true; } @@ -2949,50 +2939,72 @@ module ts { for (var i = 0; i < properties.length; i++) { var targetProp = properties[i]; var sourceProp = getPropertyOfApparentType(source, targetProp.name); - if (sourceProp === targetProp) { - continue; - } - - var targetPropIsOptional = isOptionalProperty(targetProp); - if (!sourceProp) { - if (!targetPropIsOptional) { - if (reportErrors) { - reportError(Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); + if (sourceProp !== targetProp) { + if (!sourceProp) { + if (!isOptionalProperty(targetProp)) { + if (reportErrors) { + reportError(Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); + } + return false; } - return false; } - } - else if (sourceProp !== targetProp) { - if (targetProp.flags & SymbolFlags.Prototype) { - continue; - } - - if (getDeclarationFlagsFromSymbol(sourceProp) & NodeFlags.Private || getDeclarationFlagsFromSymbol(targetProp) & NodeFlags.Private) { - if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { + else if (!(targetProp.flags & SymbolFlags.Prototype)) { + var sourceFlags = getDeclarationFlagsFromSymbol(sourceProp); + var targetFlags = getDeclarationFlagsFromSymbol(targetProp); + if (sourceFlags & NodeFlags.Private || targetFlags & NodeFlags.Private) { + if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) { + if (reportErrors) { + if (sourceFlags & NodeFlags.Private && targetFlags & 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)); + } + } + return false; + } + } + else if (targetFlags & NodeFlags.Protected) { + var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & SymbolFlags.Class; + var sourceClass = sourceDeclaredInClass ? getDeclaredTypeOfSymbol(sourceProp.parent) : undefined; + var targetClass = getDeclaredTypeOfSymbol(targetProp.parent); + if (!sourceClass || !hasBaseType(sourceClass, targetClass)) { + if (reportErrors) { + reportError(Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, + symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); + } + return false; + } + } + else if (sourceFlags & NodeFlags.Protected) { if (reportErrors) { - reportError(Diagnostics.Private_property_0_cannot_be_reimplemented, symbolToString(targetProp)); + reportError(Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, + symbolToString(targetProp), typeToString(source), typeToString(target)); } return false; } - } - if (!isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors)) { - if (reportErrors) { - reportError(Diagnostics.Types_of_property_0_are_incompatible_Colon, symbolToString(targetProp)); + if (!isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors)) { + if (reportErrors) { + reportError(Diagnostics.Types_of_property_0_are_incompatible_Colon, symbolToString(targetProp)); + } + return false; } - return false; - } - else if (isOptionalProperty(sourceProp) && !targetPropIsOptional) { - // TypeScript 1.0 spec (April 2014): 3.8.3 - // S is a subtype of a type T, and T is a supertype of S if ... - // S' and T are object types and, for each member M in T.. - // M is a property and S' contains a property N where - // if M is a required property, N is also a required property - // (M - property in T) - // (N - property in S) - if (reportErrors) { - reportError(Diagnostics.Required_property_0_cannot_be_reimplemented_with_optional_property_in_1, targetProp.name, typeToString(source)); + if (isOptionalProperty(sourceProp) && !isOptionalProperty(targetProp)) { + // TypeScript 1.0 spec (April 2014): 3.8.3 + // S is a subtype of a type T, and T is a supertype of S if ... + // S' and T are object types and, for each member M in T.. + // M is a property and S' contains a property N where + // if M is a required property, N is also a required property + // (M - property in T) + // (N - property in S) + if (reportErrors) { + reportError(Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, + symbolToString(targetProp), typeToString(source), typeToString(target)); + } + return false; } - return false; } } } @@ -4000,6 +4012,44 @@ module ts { return s.valueDeclaration ? s.valueDeclaration.flags : s.flags & SymbolFlags.Prototype ? NodeFlags.Public | NodeFlags.Static : 0; } + function checkClassPropertyAccess(node: PropertyAccess, type: Type, prop: Symbol) { + var flags = getDeclarationFlagsFromSymbol(prop); + // Public properties are always accessible + if (!(flags & (NodeFlags.Private | NodeFlags.Protected))) { + return; + } + // Property is known to be private or protected at this point + // Get the declaring and enclosing class instance types + var enclosingClassDeclaration = getAncestor(node, SyntaxKind.ClassDeclaration); + var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; + var 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; + } + // Property is known to be protected at this point + // All protected properties of a supertype are accessible in a super access + if (node.left.kind === SyntaxKind.SuperKeyword) { + return; + } + // 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; + } + // No further restrictions for static properties + if (flags & NodeFlags.Static) { + return; + } + // An instance property must be accessed through an instance of the enclosing class + 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)); + } + } + function checkPropertyAccess(node: PropertyAccess) { var type = checkExpression(node.left); if (type === unknownType) return type; @@ -4018,7 +4068,6 @@ module ts { } 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, @@ -4027,13 +4076,10 @@ module ts { // 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 (node.left.kind === SyntaxKind.SuperKeyword && getDeclarationKindFromSymbol(prop) !== SyntaxKind.Method) { - error(node.right, Diagnostics.Only_public_methods_of_the_base_class_are_accessible_via_the_super_keyword); + error(node.right, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } - else if (getDeclarationFlagsFromSymbol(prop) & NodeFlags.Private) { - var classDeclaration = getAncestor(node, SyntaxKind.ClassDeclaration); - if (!classDeclaration || !contains(prop.parent.declarations, classDeclaration)) { - error(node, Diagnostics.Property_0_is_inaccessible, getFullyQualifiedName(prop)); - } + else { + checkClassPropertyAccess(node, type, prop); } } return getTypeOfSymbol(prop); @@ -4989,7 +5035,8 @@ module ts { if (fullTypeCheck) { checkCollisionWithIndexVariableInGeneratedCode(parameterDeclaration, parameterDeclaration.name); - if (parameterDeclaration.flags & (NodeFlags.Public | NodeFlags.Private) && !(parameterDeclaration.parent.kind === SyntaxKind.Constructor && (parameterDeclaration.parent).body)) { + if (parameterDeclaration.flags & (NodeFlags.Public | NodeFlags.Private | NodeFlags.Protected) && + !(parameterDeclaration.parent.kind === SyntaxKind.Constructor && (parameterDeclaration.parent).body)) { error(parameterDeclaration, Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } if (parameterDeclaration.flags & NodeFlags.Rest) { @@ -5182,7 +5229,7 @@ module ts { // or the containing class declares instance member variables with initializers. var superCallShouldBeFirst = forEach((node.parent).members, isInstancePropertyWithInitializer) || - forEach(node.parameters, p => p.flags & (NodeFlags.Public | NodeFlags.Private)); + forEach(node.parameters, p => p.flags & (NodeFlags.Public | NodeFlags.Private | NodeFlags.Protected)); if (superCallShouldBeFirst) { var statements = (node.body).statements; @@ -5359,8 +5406,8 @@ module ts { else if (deviation & NodeFlags.Ambient) { error(o.name, Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } - else if (deviation & NodeFlags.Private) { - error(o.name, Diagnostics.Overload_signatures_must_all_be_public_or_private); + else if (deviation & (NodeFlags.Private | NodeFlags.Protected)) { + error(o.name, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } else if (deviation & NodeFlags.QuestionMark) { error(o.name, Diagnostics.Overload_signatures_must_all_be_optional_or_required); @@ -5369,7 +5416,7 @@ module ts { } } - var flagsToCheck: NodeFlags = NodeFlags.Export | NodeFlags.Ambient | NodeFlags.Private | NodeFlags.QuestionMark; + var flagsToCheck: NodeFlags = NodeFlags.Export | NodeFlags.Ambient | NodeFlags.Private | NodeFlags.Protected | NodeFlags.QuestionMark; var someNodeFlags: NodeFlags = 0; var allNodeFlags = flagsToCheck; var hasOverloads = false; @@ -6149,7 +6196,7 @@ module ts { } function getTargetSymbol(s: Symbol) { - // if symbol is instantiated it's flags are not copied from the 'target' + // if symbol is instantiated its flags are not copied from the 'target' // so we'll need to get back original 'target' symbol to work with correct set of flags return s.flags & SymbolFlags.Instantiated ? getSymbolLinks(s).target : s; } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 04dbafc254e84..ba6f742c4c14c 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -138,9 +138,9 @@ module ts { Type_0_is_not_assignable_to_type_1_Colon: { code: 2322, category: DiagnosticCategory.Error, key: "Type '{0}' is not assignable to type '{1}':" }, Type_0_is_not_assignable_to_type_1: { code: 2323, category: DiagnosticCategory.Error, key: "Type '{0}' is not assignable to type '{1}'." }, Property_0_is_missing_in_type_1: { code: 2324, category: DiagnosticCategory.Error, key: "Property '{0}' is missing in type '{1}'." }, - Private_property_0_cannot_be_reimplemented: { code: 2325, category: DiagnosticCategory.Error, key: "Private property '{0}' cannot be reimplemented." }, + Property_0_is_private_in_type_1_but_not_in_type_2: { code: 2325, category: DiagnosticCategory.Error, key: "Property '{0}' is private in type '{1}' but not in type '{2}'." }, Types_of_property_0_are_incompatible_Colon: { code: 2326, category: DiagnosticCategory.Error, key: "Types of property '{0}' are incompatible:" }, - Required_property_0_cannot_be_reimplemented_with_optional_property_in_1: { code: 2327, category: DiagnosticCategory.Error, key: "Required property '{0}' cannot be reimplemented with optional property in '{1}'." }, + Property_0_is_optional_in_type_1_but_required_in_type_2: { code: 2327, category: DiagnosticCategory.Error, key: "Property '{0}' is optional in type '{1}' but required in type '{2}'." }, Types_of_parameters_0_and_1_are_incompatible_Colon: { code: 2328, category: DiagnosticCategory.Error, key: "Types of parameters '{0}' and '{1}' are incompatible:" }, Index_signature_is_missing_in_type_0: { code: 2329, category: DiagnosticCategory.Error, key: "Index signature is missing in type '{0}'." }, Index_signatures_are_incompatible_Colon: { code: 2330, category: DiagnosticCategory.Error, key: "Index signatures are incompatible:" }, @@ -153,8 +153,8 @@ module ts { 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_methods_of_the_base_class_are_accessible_via_the_super_keyword: { code: 2340, category: DiagnosticCategory.Error, key: "Only public methods of the base class are accessible via the 'super' keyword" }, - Property_0_is_inaccessible: { code: 2341, category: DiagnosticCategory.Error, key: "Property '{0}' is inaccessible." }, + 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_or_any: { code: 2342, category: DiagnosticCategory.Error, key: "An index expression argument must be of type 'string', 'number', or 'any'." }, Type_0_does_not_satisfy_the_constraint_1_Colon: { code: 2343, category: DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}':" }, Type_0_does_not_satisfy_the_constraint_1: { code: 2344, category: DiagnosticCategory.Error, key: "Type '{0}' does not satisfy the constraint '{1}'." }, @@ -198,7 +198,7 @@ module ts { Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: { code: 2382, category: DiagnosticCategory.Error, key: "Specialized overload signature is not assignable to any non-specialized signature." }, Overload_signatures_must_all_be_exported_or_not_exported: { code: 2383, category: DiagnosticCategory.Error, key: "Overload signatures must all be exported or not exported." }, Overload_signatures_must_all_be_ambient_or_non_ambient: { code: 2384, category: DiagnosticCategory.Error, key: "Overload signatures must all be ambient or non-ambient." }, - Overload_signatures_must_all_be_public_or_private: { code: 2385, category: DiagnosticCategory.Error, key: "Overload signatures must all be public or private." }, + Overload_signatures_must_all_be_public_private_or_protected: { code: 2385, category: DiagnosticCategory.Error, key: "Overload signatures must all be public, private or protected." }, Overload_signatures_must_all_be_optional_or_required: { code: 2386, category: DiagnosticCategory.Error, key: "Overload signatures must all be optional or required." }, Function_overload_must_be_static: { code: 2387, category: DiagnosticCategory.Error, key: "Function overload must be static." }, Function_overload_must_not_be_static: { code: 2388, category: DiagnosticCategory.Error, key: "Function overload must not be static." }, @@ -255,6 +255,11 @@ module ts { Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name: { code: 2439, category: DiagnosticCategory.Error, key: "Import declaration in an ambient external module declaration cannot reference external module through relative external module name." }, Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: DiagnosticCategory.Error, key: "Import declaration conflicts with local declaration of '{0}'" }, Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module: { code: 2441, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of an external module." }, + Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: DiagnosticCategory.Error, key: "Types have separate declarations of a private property '{0}'." }, + Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: DiagnosticCategory.Error, key: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, + Property_0_is_protected_in_type_1_but_public_in_type_2: { code: 2444, category: DiagnosticCategory.Error, key: "Property '{0}' is protected in type '{1}' but public in type '{2}'." }, + Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses: { code: 2445, category: DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible within class '{1}' and its subclasses." }, + Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1: { code: 2446, category: DiagnosticCategory.Error, key: "Property '{0}' is protected and only accessible through an instance of class '{1}'." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4001, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 6c78ec6bd5db9..0480cd3000c26 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -544,7 +544,7 @@ "category": "Error", "code": 2324 }, - "Private property '{0}' cannot be reimplemented.": { + "Property '{0}' is private in type '{1}' but not in type '{2}'.": { "category": "Error", "code": 2325 }, @@ -552,7 +552,7 @@ "category": "Error", "code": 2326 }, - "Required property '{0}' cannot be reimplemented with optional property in '{1}'.": { + "Property '{0}' is optional in type '{1}' but required in type '{2}'.": { "category": "Error", "code": 2327 }, @@ -604,11 +604,11 @@ "category": "Error", "code": 2339 }, - "Only public 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 }, - "Property '{0}' is inaccessible.": { + "Property '{0}' is private and only accessible within class '{1}'.": { "category": "Error", "code": 2341 }, @@ -784,7 +784,7 @@ "category": "Error", "code": 2384 }, - "Overload signatures must all be public or private.": { + "Overload signatures must all be public, private or protected.": { "category": "Error", "code": 2385 }, @@ -1012,7 +1012,26 @@ "category": "Error", "code": 2441 }, - + "Types have separate declarations of a private property '{0}'.": { + "category": "Error", + "code": 2442 + }, + "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'.": { + "category": "Error", + "code": 2443 + }, + "Property '{0}' is protected in type '{1}' but public in type '{2}'.": { + "category": "Error", + "code": 2444 + }, + "Property '{0}' is protected and only accessible within class '{1}' and its subclasses.": { + "category": "Error", + "code": 2445 + }, + "Property '{0}' is protected and only accessible through an instance of class '{1}'.": { + "category": "Error", + "code": 2446 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 73064eda695fd..2b4e70a000c96 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2371,12 +2371,18 @@ module ts { if (node.flags & NodeFlags.Private) { write("private "); } + else if (node.flags & NodeFlags.Protected) { + write("protected "); + } write("static "); } else { if (node.flags & NodeFlags.Private) { write("private "); } + else if (node.flags & NodeFlags.Protected) { + write("protected "); + } // If the node is parented in the current source file we need to emit export declare or just export else if (node.parent === currentSourceFile) { // If the node is exported diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 7d24a133b8dcd..4c2d84de12149 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -623,6 +623,7 @@ module ts { switch (token) { case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: + case SyntaxKind.ProtectedKeyword: case SyntaxKind.StaticKeyword: case SyntaxKind.ExportKeyword: case SyntaxKind.DeclareKeyword: @@ -2920,6 +2921,7 @@ module ts { } case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: + case SyntaxKind.ProtectedKeyword: case SyntaxKind.StaticKeyword: // When followed by an identifier or keyword, these do not start a statement but // might instead be following type members @@ -3238,6 +3240,8 @@ module ts { var lastDeclareModifierLength: number; var lastPrivateModifierStart: number; var lastPrivateModifierLength: number; + var lastProtectedModifierStart: number; + var lastProtectedModifierLength: number; while (true) { var modifierStart = scanner.getTokenPos(); @@ -3277,6 +3281,21 @@ module ts { flags |= NodeFlags.Private; break; + case SyntaxKind.ProtectedKeyword: + if (flags & NodeFlags.Public || flags & NodeFlags.Private || flags & NodeFlags.Protected) { + grammarErrorAtPos(modifierStart, modifierLength, Diagnostics.Accessibility_modifier_already_seen); + } + else if (flags & NodeFlags.Static) { + grammarErrorAtPos(modifierStart, modifierLength, Diagnostics._0_modifier_must_precede_1_modifier, "protected", "static"); + } + else if (context === ModifierContext.ModuleElements || context === ModifierContext.SourceElements) { + grammarErrorAtPos(modifierStart, modifierLength, Diagnostics._0_modifier_cannot_appear_on_a_module_element, "protected"); + } + lastProtectedModifierStart = modifierStart; + lastProtectedModifierLength = modifierLength; + flags |= NodeFlags.Protected; + break; + case SyntaxKind.StaticKeyword: if (flags & NodeFlags.Static) { grammarErrorAtPos(modifierStart, modifierLength, Diagnostics._0_modifier_already_seen, "static"); @@ -3334,6 +3353,9 @@ module ts { else if (token === SyntaxKind.ConstructorKeyword && flags & NodeFlags.Private) { grammarErrorAtPos(lastPrivateModifierStart, lastPrivateModifierLength, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } + else if (token === SyntaxKind.ConstructorKeyword && flags & NodeFlags.Protected) { + grammarErrorAtPos(lastProtectedModifierStart, lastProtectedModifierLength, Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); + } else if (token === SyntaxKind.ImportKeyword) { if (flags & NodeFlags.Ambient) { grammarErrorAtPos(lastDeclareModifierStart, lastDeclareModifierLength, Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); @@ -3610,6 +3632,7 @@ module ts { case SyntaxKind.DeclareKeyword: case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: + case SyntaxKind.ProtectedKeyword: case SyntaxKind.StaticKeyword: // Check for modifier on source element return lookAhead(() => { nextToken(); return isDeclaration(); }); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 82fac6b891322..5c3b5cbc49884 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -234,13 +234,14 @@ module ts { Rest = 0x00000008, // Parameter Public = 0x00000010, // Property/Method Private = 0x00000020, // Property/Method - Static = 0x00000040, // Property/Method - MultiLine = 0x00000080, // Multi-line array or object literal - Synthetic = 0x00000100, // Synthetic node (for full fidelity) - DeclarationFile = 0x00000200, // Node is a .d.ts file - - Modifier = Export | Ambient | Public | Private | Static, - AccessibilityModifier = Public | Private + Protected = 0x00000040, // Property/Method + Static = 0x00000080, // Property/Method + MultiLine = 0x00000100, // Multi-line array or object literal + Synthetic = 0x00000200, // Synthetic node (for full fidelity) + DeclarationFile = 0x00000400, // Node is a .d.ts file + + Modifier = Export | Ambient | Public | Private | Protected | Static, + AccessibilityModifier = Public | Private | Protected } export interface Node extends TextRange { diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.errors.txt b/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.errors.txt index 6121bba66fb23..3feee7069d000 100644 --- a/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.errors.txt +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts(11,16): error TS2341: Property 'clodule.sfn' is inaccessible. +tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts(11,16): error TS2341: Property 'sfn' is private and only accessible within class 'clodule'. ==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts (1 errors) ==== @@ -14,7 +14,7 @@ tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMer export function fn(x: T, y: T): number { return clodule.sfn('a'); ~~~~~~~~~~~ -!!! error TS2341: Property 'clodule.sfn' is inaccessible. +!!! error TS2341: Property 'sfn' is private and only accessible within class 'clodule'. } } diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersAccessibility.errors.txt b/tests/baselines/reference/assignmentCompatWithObjectMembersAccessibility.errors.txt index 75f36240e0347..ab9ddb553d378 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersAccessibility.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersAccessibility.errors.txt @@ -1,51 +1,51 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(31,5): error TS2322: Type 'E' is not assignable to type '{ foo: string; }': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'E' but not in type '{ foo: string; }'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(36,5): error TS2322: Type 'E' is not assignable to type 'Base': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'E' but not in type 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(41,5): error TS2322: Type 'E' is not assignable to type 'I': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'E' but not in type 'I'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(46,5): error TS2322: Type 'E' is not assignable to type 'D': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'E' but not in type 'D'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(48,5): error TS2322: Type '{ foo: string; }' is not assignable to type 'E': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'E' but not in type '{ foo: string; }'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(49,5): error TS2322: Type 'Base' is not assignable to type 'E': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'E' but not in type 'Base'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(50,5): error TS2322: Type 'I' is not assignable to type 'E': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'E' but not in type 'I'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(51,5): error TS2322: Type 'D' is not assignable to type 'E': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'E' but not in type 'D'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(81,5): error TS2322: Type 'Base' is not assignable to type '{ foo: string; }': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'Base' but not in type '{ foo: string; }'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(82,5): error TS2322: Type 'I' is not assignable to type '{ foo: string; }': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'I' but not in type '{ foo: string; }'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(84,5): error TS2322: Type 'E' is not assignable to type '{ foo: string; }': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'E' but not in type '{ foo: string; }'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(86,5): error TS2322: Type '{ foo: string; }' is not assignable to type 'Base': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'Base' but not in type '{ foo: string; }'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(88,5): error TS2322: Type 'D' is not assignable to type 'Base': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'Base' but not in type 'D'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(89,5): error TS2322: Type 'E' is not assignable to type 'Base': - Private property 'foo' cannot be reimplemented. + Types have separate declarations of a private property 'foo'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(92,5): error TS2322: Type '{ foo: string; }' is not assignable to type 'I': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'I' but not in type '{ foo: string; }'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(94,5): error TS2322: Type 'D' is not assignable to type 'I': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'I' but not in type 'D'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(95,5): error TS2322: Type 'E' is not assignable to type 'I': - Private property 'foo' cannot be reimplemented. + Types have separate declarations of a private property 'foo'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(99,5): error TS2322: Type 'Base' is not assignable to type 'D': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'Base' but not in type 'D'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(100,5): error TS2322: Type 'I' is not assignable to type 'D': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'I' but not in type 'D'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(101,5): error TS2322: Type 'E' is not assignable to type 'D': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'E' but not in type 'D'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(103,5): error TS2322: Type '{ foo: string; }' is not assignable to type 'E': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'E' but not in type '{ foo: string; }'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(104,5): error TS2322: Type 'Base' is not assignable to type 'E': - Private property 'foo' cannot be reimplemented. + Types have separate declarations of a private property 'foo'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(105,5): error TS2322: Type 'I' is not assignable to type 'E': - Private property 'foo' cannot be reimplemented. + Types have separate declarations of a private property 'foo'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts(106,5): error TS2322: Type 'D' is not assignable to type 'E': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'E' but not in type 'D'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts (24 errors) ==== @@ -82,7 +82,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a = e; // error ~ !!! error TS2322: Type 'E' is not assignable to type '{ foo: string; }': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Property 'foo' is private in type 'E' but not in type '{ foo: string; }'. b = a; b = i; @@ -90,7 +90,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme b = e; // error ~ !!! error TS2322: Type 'E' is not assignable to type 'Base': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Property 'foo' is private in type 'E' but not in type 'Base'. i = a; i = b; @@ -98,7 +98,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme i = e; // error ~ !!! error TS2322: Type 'E' is not assignable to type 'I': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Property 'foo' is private in type 'E' but not in type 'I'. d = a; d = b; @@ -106,24 +106,24 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme d = e; // error ~ !!! error TS2322: Type 'E' is not assignable to type 'D': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Property 'foo' is private in type 'E' but not in type 'D'. e = a; // errror ~ !!! error TS2322: Type '{ foo: string; }' is not assignable to type 'E': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Property 'foo' is private in type 'E' but not in type '{ foo: string; }'. e = b; // errror ~ !!! error TS2322: Type 'Base' is not assignable to type 'E': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Property 'foo' is private in type 'E' but not in type 'Base'. e = i; // errror ~ !!! error TS2322: Type 'I' is not assignable to type 'E': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Property 'foo' is private in type 'E' but not in type 'I'. e = d; // errror ~ !!! error TS2322: Type 'D' is not assignable to type 'E': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Property 'foo' is private in type 'E' but not in type 'D'. e = e; } @@ -156,77 +156,77 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a = b; // error ~ !!! error TS2322: Type 'Base' is not assignable to type '{ foo: string; }': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Property 'foo' is private in type 'Base' but not in type '{ foo: string; }'. a = i; // error ~ !!! error TS2322: Type 'I' is not assignable to type '{ foo: string; }': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Property 'foo' is private in type 'I' but not in type '{ foo: string; }'. a = d; a = e; // error ~ !!! error TS2322: Type 'E' is not assignable to type '{ foo: string; }': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Property 'foo' is private in type 'E' but not in type '{ foo: string; }'. b = a; // error ~ !!! error TS2322: Type '{ foo: string; }' is not assignable to type 'Base': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Property 'foo' is private in type 'Base' but not in type '{ foo: string; }'. b = i; b = d; // error ~ !!! error TS2322: Type 'D' is not assignable to type 'Base': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Property 'foo' is private in type 'Base' but not in type 'D'. b = e; // error ~ !!! error TS2322: Type 'E' is not assignable to type 'Base': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Types have separate declarations of a private property 'foo'. b = b; i = a; // error ~ !!! error TS2322: Type '{ foo: string; }' is not assignable to type 'I': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Property 'foo' is private in type 'I' but not in type '{ foo: string; }'. i = b; i = d; // error ~ !!! error TS2322: Type 'D' is not assignable to type 'I': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Property 'foo' is private in type 'I' but not in type 'D'. i = e; // error ~ !!! error TS2322: Type 'E' is not assignable to type 'I': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Types have separate declarations of a private property 'foo'. i = i; d = a; d = b; // error ~ !!! error TS2322: Type 'Base' is not assignable to type 'D': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Property 'foo' is private in type 'Base' but not in type 'D'. d = i; // error ~ !!! error TS2322: Type 'I' is not assignable to type 'D': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Property 'foo' is private in type 'I' but not in type 'D'. d = e; // error ~ !!! error TS2322: Type 'E' is not assignable to type 'D': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Property 'foo' is private in type 'E' but not in type 'D'. e = a; // errror ~ !!! error TS2322: Type '{ foo: string; }' is not assignable to type 'E': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Property 'foo' is private in type 'E' but not in type '{ foo: string; }'. e = b; // errror ~ !!! error TS2322: Type 'Base' is not assignable to type 'E': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Types have separate declarations of a private property 'foo'. e = i; // errror ~ !!! error TS2322: Type 'I' is not assignable to type 'E': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Types have separate declarations of a private property 'foo'. e = d; // errror ~ !!! error TS2322: Type 'D' is not assignable to type 'E': -!!! error TS2322: Private property 'foo' cannot be reimplemented. +!!! error TS2322: Property 'foo' is private in type 'E' but not in type 'D'. e = e; } \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.errors.txt b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.errors.txt index 0731e5746bc48..44577bf1c8d80 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.errors.txt @@ -1,15 +1,15 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality.ts(73,5): error TS2322: Type 'D' is not assignable to type 'C': - Required property 'opt' cannot be reimplemented with optional property in 'D'. + Property 'opt' is optional in type 'D' but required in type 'C'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality.ts(74,5): error TS2322: Type 'E' is not assignable to type 'C': - Required property 'opt' cannot be reimplemented with optional property in 'E'. + Property 'opt' is optional in type 'E' but required in type 'C'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality.ts(78,5): error TS2322: Type 'D' is not assignable to type '{ opt: Base; }': - Required property 'opt' cannot be reimplemented with optional property in 'D'. + Property 'opt' is optional in type 'D' but required in type '{ opt: Base; }'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality.ts(79,5): error TS2322: Type 'E' is not assignable to type '{ opt: Base; }': - Required property 'opt' cannot be reimplemented with optional property in 'E'. + Property 'opt' is optional in type 'E' but required in type '{ opt: Base; }'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality.ts(83,5): error TS2322: Type 'D' is not assignable to type '{ opt: Base; }': - Required property 'opt' cannot be reimplemented with optional property in 'D'. + Property 'opt' is optional in type 'D' but required in type '{ opt: Base; }'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality.ts(84,5): error TS2322: Type 'E' is not assignable to type '{ opt: Base; }': - Required property 'opt' cannot be reimplemented with optional property in 'E'. + Property 'opt' is optional in type 'E' but required in type '{ opt: Base; }'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality.ts (6 errors) ==== @@ -88,33 +88,33 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme c = d; // error ~ !!! error TS2322: Type 'D' is not assignable to type 'C': -!!! error TS2322: Required property 'opt' cannot be reimplemented with optional property in 'D'. +!!! error TS2322: Property 'opt' is optional in type 'D' but required in type 'C'. c = e; // error ~ !!! error TS2322: Type 'E' is not assignable to type 'C': -!!! error TS2322: Required property 'opt' cannot be reimplemented with optional property in 'E'. +!!! error TS2322: Property 'opt' is optional in type 'E' but required in type 'C'. c = f; // ok c = a; // ok a = d; // error ~ !!! error TS2322: Type 'D' is not assignable to type '{ opt: Base; }': -!!! error TS2322: Required property 'opt' cannot be reimplemented with optional property in 'D'. +!!! error TS2322: Property 'opt' is optional in type 'D' but required in type '{ opt: Base; }'. a = e; // error ~ !!! error TS2322: Type 'E' is not assignable to type '{ opt: Base; }': -!!! error TS2322: Required property 'opt' cannot be reimplemented with optional property in 'E'. +!!! error TS2322: Property 'opt' is optional in type 'E' but required in type '{ opt: Base; }'. a = f; // ok a = c; // ok b = d; // error ~ !!! error TS2322: Type 'D' is not assignable to type '{ opt: Base; }': -!!! error TS2322: Required property 'opt' cannot be reimplemented with optional property in 'D'. +!!! error TS2322: Property 'opt' is optional in type 'D' but required in type '{ opt: Base; }'. b = e; // error ~ !!! error TS2322: Type 'E' is not assignable to type '{ opt: Base; }': -!!! error TS2322: Required property 'opt' cannot be reimplemented with optional property in 'E'. +!!! error TS2322: Property 'opt' is optional in type 'E' but required in type '{ opt: Base; }'. b = f; // ok b = a; // ok b = c; // ok diff --git a/tests/baselines/reference/assignmentCompatability10.errors.txt b/tests/baselines/reference/assignmentCompatability10.errors.txt index 26ffd267ae0c7..f1fe353c9067c 100644 --- a/tests/baselines/reference/assignmentCompatability10.errors.txt +++ b/tests/baselines/reference/assignmentCompatability10.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/assignmentCompatability10.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type 'classWithPublicAndOptional': - Required property 'two' cannot be reimplemented with optional property in 'interfaceWithPublicAndOptional'. + Property 'two' is optional in type 'interfaceWithPublicAndOptional' but required in type 'classWithPublicAndOptional'. ==== tests/cases/compiler/assignmentCompatability10.ts (1 errors) ==== @@ -14,4 +14,4 @@ tests/cases/compiler/assignmentCompatability10.ts(9,1): error TS2322: Type 'inte __test2__.__val__x4 = __test1__.__val__obj4 ~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type 'classWithPublicAndOptional': -!!! error TS2322: Required property 'two' cannot be reimplemented with optional property in 'interfaceWithPublicAndOptional'. \ No newline at end of file +!!! error TS2322: Property 'two' is optional in type 'interfaceWithPublicAndOptional' but required in type 'classWithPublicAndOptional'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability13.errors.txt b/tests/baselines/reference/assignmentCompatability13.errors.txt index bb87c72431497..909193c620246 100644 --- a/tests/baselines/reference/assignmentCompatability13.errors.txt +++ b/tests/baselines/reference/assignmentCompatability13.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/assignmentCompatability13.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ two: string; }': - Required property 'two' cannot be reimplemented with optional property in 'interfaceWithPublicAndOptional'. + Property 'two' is optional in type 'interfaceWithPublicAndOptional' but required in type '{ two: string; }'. ==== tests/cases/compiler/assignmentCompatability13.ts (1 errors) ==== @@ -14,4 +14,4 @@ tests/cases/compiler/assignmentCompatability13.ts(9,1): error TS2322: Type 'inte __test2__.__val__obj = __test1__.__val__obj4 ~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ two: string; }': -!!! error TS2322: Required property 'two' cannot be reimplemented with optional property in 'interfaceWithPublicAndOptional'. \ No newline at end of file +!!! error TS2322: Property 'two' is optional in type 'interfaceWithPublicAndOptional' but required in type '{ two: string; }'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability27.errors.txt b/tests/baselines/reference/assignmentCompatability27.errors.txt index 16870b191b3fe..3c033c8d98d4e 100644 --- a/tests/baselines/reference/assignmentCompatability27.errors.txt +++ b/tests/baselines/reference/assignmentCompatability27.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/assignmentCompatability27.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ two: string; }': - Required property 'two' cannot be reimplemented with optional property in 'interfaceWithPublicAndOptional'. + Property 'two' is optional in type 'interfaceWithPublicAndOptional' but required in type '{ two: string; }'. ==== tests/cases/compiler/assignmentCompatability27.ts (1 errors) ==== @@ -14,4 +14,4 @@ tests/cases/compiler/assignmentCompatability27.ts(9,1): error TS2322: Type 'inte __test2__.__val__aa = __test1__.__val__obj4 ~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type '{ two: string; }': -!!! error TS2322: Required property 'two' cannot be reimplemented with optional property in 'interfaceWithPublicAndOptional'. \ No newline at end of file +!!! error TS2322: Property 'two' is optional in type 'interfaceWithPublicAndOptional' but required in type '{ two: string; }'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability39.errors.txt b/tests/baselines/reference/assignmentCompatability39.errors.txt index c89b63405d105..3ab5cee78871f 100644 --- a/tests/baselines/reference/assignmentCompatability39.errors.txt +++ b/tests/baselines/reference/assignmentCompatability39.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/assignmentCompatability39.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type 'classWithTwoPublic': - Required property 'two' cannot be reimplemented with optional property in 'interfaceWithPublicAndOptional'. + Property 'two' is optional in type 'interfaceWithPublicAndOptional' but required in type 'classWithTwoPublic'. ==== tests/cases/compiler/assignmentCompatability39.ts (1 errors) ==== @@ -14,4 +14,4 @@ tests/cases/compiler/assignmentCompatability39.ts(9,1): error TS2322: Type 'inte __test2__.__val__x2 = __test1__.__val__obj4 ~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type 'classWithTwoPublic': -!!! error TS2322: Required property 'two' cannot be reimplemented with optional property in 'interfaceWithPublicAndOptional'. \ No newline at end of file +!!! error TS2322: Property 'two' is optional in type 'interfaceWithPublicAndOptional' but required in type 'classWithTwoPublic'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability40.errors.txt b/tests/baselines/reference/assignmentCompatability40.errors.txt index b6e47c23b941e..4be86ebc805f7 100644 --- a/tests/baselines/reference/assignmentCompatability40.errors.txt +++ b/tests/baselines/reference/assignmentCompatability40.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/assignmentCompatability40.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type 'classWithPrivate': - Private property 'one' cannot be reimplemented. + Property 'one' is private in type 'classWithPrivate' but not in type 'interfaceWithPublicAndOptional'. ==== tests/cases/compiler/assignmentCompatability40.ts (1 errors) ==== @@ -14,4 +14,4 @@ tests/cases/compiler/assignmentCompatability40.ts(9,1): error TS2322: Type 'inte __test2__.__val__x5 = __test1__.__val__obj4 ~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type 'classWithPrivate': -!!! error TS2322: Private property 'one' cannot be reimplemented. \ No newline at end of file +!!! error TS2322: Property 'one' is private in type 'classWithPrivate' but not in type 'interfaceWithPublicAndOptional'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability41.errors.txt b/tests/baselines/reference/assignmentCompatability41.errors.txt index 535b52fe62c32..018beb233588b 100644 --- a/tests/baselines/reference/assignmentCompatability41.errors.txt +++ b/tests/baselines/reference/assignmentCompatability41.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/assignmentCompatability41.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type 'classWithTwoPrivate': - Private property 'one' cannot be reimplemented. + Property 'one' is private in type 'classWithTwoPrivate' but not in type 'interfaceWithPublicAndOptional'. ==== tests/cases/compiler/assignmentCompatability41.ts (1 errors) ==== @@ -14,4 +14,4 @@ tests/cases/compiler/assignmentCompatability41.ts(9,1): error TS2322: Type 'inte __test2__.__val__x6 = __test1__.__val__obj4 ~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type 'classWithTwoPrivate': -!!! error TS2322: Private property 'one' cannot be reimplemented. \ No newline at end of file +!!! error TS2322: Property 'one' is private in type 'classWithTwoPrivate' but not in type 'interfaceWithPublicAndOptional'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability42.errors.txt b/tests/baselines/reference/assignmentCompatability42.errors.txt index 2fe4689bac20e..de6fd79041e82 100644 --- a/tests/baselines/reference/assignmentCompatability42.errors.txt +++ b/tests/baselines/reference/assignmentCompatability42.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/assignmentCompatability42.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type 'classWithPublicPrivate': - Private property 'two' cannot be reimplemented. + Property 'two' is private in type 'classWithPublicPrivate' but not in type 'interfaceWithPublicAndOptional'. ==== tests/cases/compiler/assignmentCompatability42.ts (1 errors) ==== @@ -14,4 +14,4 @@ tests/cases/compiler/assignmentCompatability42.ts(9,1): error TS2322: Type 'inte __test2__.__val__x7 = __test1__.__val__obj4 ~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type 'classWithPublicPrivate': -!!! error TS2322: Private property 'two' cannot be reimplemented. \ No newline at end of file +!!! error TS2322: Property 'two' is private in type 'classWithPublicPrivate' but not in type 'interfaceWithPublicAndOptional'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatability43.errors.txt b/tests/baselines/reference/assignmentCompatability43.errors.txt index 6be9f267ac4de..3f5fc9789b9c5 100644 --- a/tests/baselines/reference/assignmentCompatability43.errors.txt +++ b/tests/baselines/reference/assignmentCompatability43.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/assignmentCompatability43.ts(9,1): error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type 'interfaceTwo': - Required property 'two' cannot be reimplemented with optional property in 'interfaceWithPublicAndOptional'. + Property 'two' is optional in type 'interfaceWithPublicAndOptional' but required in type 'interfaceTwo'. ==== tests/cases/compiler/assignmentCompatability43.ts (1 errors) ==== @@ -14,4 +14,4 @@ tests/cases/compiler/assignmentCompatability43.ts(9,1): error TS2322: Type 'inte __test2__.__val__obj2 = __test1__.__val__obj4 ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'interfaceWithPublicAndOptional' is not assignable to type 'interfaceTwo': -!!! error TS2322: Required property 'two' cannot be reimplemented with optional property in 'interfaceWithPublicAndOptional'. \ No newline at end of file +!!! error TS2322: Property 'two' is optional in type 'interfaceWithPublicAndOptional' but required in type 'interfaceTwo'. \ No newline at end of file diff --git a/tests/baselines/reference/classConstructorAccessibility.errors.txt b/tests/baselines/reference/classConstructorAccessibility.errors.txt index 783d8a3ea1c4a..c22f3593bc57f 100644 --- a/tests/baselines/reference/classConstructorAccessibility.errors.txt +++ b/tests/baselines/reference/classConstructorAccessibility.errors.txt @@ -1,8 +1,10 @@ tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts(6,5): error TS1089: 'private' modifier cannot appear on a constructor declaration. -tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts(18,9): error TS1089: 'private' modifier cannot appear on a constructor declaration. +tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts(10,5): error TS1089: 'protected' modifier cannot appear on a constructor declaration. +tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts(23,9): error TS1089: 'private' modifier cannot appear on a constructor declaration. +tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts(27,9): error TS1089: 'protected' modifier cannot appear on a constructor declaration. -==== tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts (2 errors) ==== +==== tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts (4 errors) ==== class C { public constructor(public x: number) { } } @@ -13,8 +15,15 @@ tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessib !!! error TS1089: 'private' modifier cannot appear on a constructor declaration. } + class E { + protected constructor(public x: number) { } // error + ~~~~~~~~~ +!!! error TS1089: 'protected' modifier cannot appear on a constructor declaration. + } + var c = new C(1); var d = new D(1); + var e = new E(1); module Generic { class C { @@ -27,7 +36,14 @@ tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessib !!! error TS1089: 'private' modifier cannot appear on a constructor declaration. } + class E { + protected constructor(public x: T) { } // error + ~~~~~~~~~ +!!! error TS1089: 'protected' modifier cannot appear on a constructor declaration. + } + var c = new C(1); var d = new D(1); + var e = new E(1); } \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsInterfaceThatExtendsClassWithPrivates1.errors.txt b/tests/baselines/reference/classExtendsInterfaceThatExtendsClassWithPrivates1.errors.txt index 07bd35d1b76af..cff696696b751 100644 --- a/tests/baselines/reference/classExtendsInterfaceThatExtendsClassWithPrivates1.errors.txt +++ b/tests/baselines/reference/classExtendsInterfaceThatExtendsClassWithPrivates1.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/classExtendsInterfaceThatExtendsClassWithPrivates1.ts(10,7): error TS2421: Class 'D2' incorrectly implements interface 'I': - Private property 'x' cannot be reimplemented. + Types have separate declarations of a private property 'x'. ==== tests/cases/compiler/classExtendsInterfaceThatExtendsClassWithPrivates1.ts (1 errors) ==== @@ -15,7 +15,7 @@ tests/cases/compiler/classExtendsInterfaceThatExtendsClassWithPrivates1.ts(10,7) class D2 implements I { ~~ !!! error TS2421: Class 'D2' incorrectly implements interface 'I': -!!! error TS2421: Private property 'x' cannot be reimplemented. +!!! error TS2421: Types have separate declarations of a private property 'x'. public foo(x: any) { return x } private x = 3; other(x: any) { return x } diff --git a/tests/baselines/reference/classImplementsClass5.errors.txt b/tests/baselines/reference/classImplementsClass5.errors.txt index ba0616f5723ea..6328e595e13e8 100644 --- a/tests/baselines/reference/classImplementsClass5.errors.txt +++ b/tests/baselines/reference/classImplementsClass5.errors.txt @@ -1,9 +1,9 @@ tests/cases/compiler/classImplementsClass5.ts(5,7): error TS2421: Class 'C' incorrectly implements interface 'A': - Private property 'x' cannot be reimplemented. + Types have separate declarations of a private property 'x'. tests/cases/compiler/classImplementsClass5.ts(16,1): error TS2322: Type 'C2' is not assignable to type 'C': - Private property 'x' cannot be reimplemented. + Types have separate declarations of a private property 'x'. tests/cases/compiler/classImplementsClass5.ts(17,1): error TS2322: Type 'C' is not assignable to type 'C2': - Private property 'x' cannot be reimplemented. + Types have separate declarations of a private property 'x'. ==== tests/cases/compiler/classImplementsClass5.ts (3 errors) ==== @@ -14,7 +14,7 @@ tests/cases/compiler/classImplementsClass5.ts(17,1): error TS2322: Type 'C' is n class C implements A { ~ !!! error TS2421: Class 'C' incorrectly implements interface 'A': -!!! error TS2421: Private property 'x' cannot be reimplemented. +!!! error TS2421: Types have separate declarations of a private property 'x'. private x = 1; foo() { return 1; @@ -28,8 +28,8 @@ tests/cases/compiler/classImplementsClass5.ts(17,1): error TS2322: Type 'C' is n c = c2; ~ !!! error TS2322: Type 'C2' is not assignable to type 'C': -!!! error TS2322: Private property 'x' cannot be reimplemented. +!!! error TS2322: Types have separate declarations of a private property 'x'. c2 = c; ~~ !!! error TS2322: Type 'C' is not assignable to type 'C2': -!!! error TS2322: Private property 'x' cannot be reimplemented. \ No newline at end of file +!!! error TS2322: Types have separate declarations of a private property 'x'. \ No newline at end of file diff --git a/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt b/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt index e2c85ab46b0b5..7ba816475fb2e 100644 --- a/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt +++ b/tests/baselines/reference/classIsSubtypeOfBaseType.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts(11,7): error TS2416: Class 'Derived2' incorrectly extends base class 'Base<{ bar: string; }>': Types of property 'foo' are incompatible: Type '{ bar?: string; }' is not assignable to type '{ bar: string; }': - Required property 'bar' cannot be reimplemented with optional property in '{ bar?: string; }'. + Property 'bar' is optional in type '{ bar?: string; }' but required in type '{ bar: string; }'. ==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts (1 errors) ==== @@ -20,7 +20,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla !!! error TS2416: Class 'Derived2' incorrectly extends base class 'Base<{ bar: string; }>': !!! error TS2416: Types of property 'foo' are incompatible: !!! error TS2416: Type '{ bar?: string; }' is not assignable to type '{ bar: string; }': -!!! error TS2416: Required property 'bar' cannot be reimplemented with optional property in '{ bar?: string; }'. +!!! error TS2416: Property 'bar' is optional in type '{ bar?: string; }' but required in type '{ bar: string; }'. foo: { bar?: string; // error } diff --git a/tests/baselines/reference/classPropertyAsPrivate.errors.txt b/tests/baselines/reference/classPropertyAsPrivate.errors.txt index 1ba10c61bd684..a5fdffe091a43 100644 --- a/tests/baselines/reference/classPropertyAsPrivate.errors.txt +++ b/tests/baselines/reference/classPropertyAsPrivate.errors.txt @@ -2,14 +2,14 @@ tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts( tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(4,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(8,24): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(9,24): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(15,1): error TS2341: Property 'C.x' is inaccessible. -tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(16,1): error TS2341: Property 'C.y' is inaccessible. -tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(17,1): error TS2341: Property 'C.y' is inaccessible. -tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(18,1): error TS2341: Property 'C.foo' is inaccessible. -tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(20,1): error TS2341: Property 'C.a' is inaccessible. -tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(21,1): error TS2341: Property 'C.b' is inaccessible. -tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(22,1): error TS2341: Property 'C.b' is inaccessible. -tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(23,1): error TS2341: Property 'C.foo' is inaccessible. +tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(15,1): error TS2341: Property 'x' is private and only accessible within class 'C'. +tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(16,1): error TS2341: Property 'y' is private and only accessible within class 'C'. +tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(17,1): error TS2341: Property 'y' is private and only accessible within class 'C'. +tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(18,1): error TS2341: Property 'foo' is private and only accessible within class 'C'. +tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(20,1): error TS2341: Property 'a' is private and only accessible within class 'C'. +tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(21,1): error TS2341: Property 'b' is private and only accessible within class 'C'. +tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(22,1): error TS2341: Property 'b' is private and only accessible within class 'C'. +tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts(23,1): error TS2341: Property 'foo' is private and only accessible within class 'C'. ==== tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts (12 errors) ==== @@ -37,26 +37,26 @@ tests/cases/conformance/classes/members/accessibility/classPropertyAsPrivate.ts( // all errors c.x; ~~~ -!!! error TS2341: Property 'C.x' is inaccessible. +!!! error TS2341: Property 'x' is private and only accessible within class 'C'. c.y; ~~~ -!!! error TS2341: Property 'C.y' is inaccessible. +!!! error TS2341: Property 'y' is private and only accessible within class 'C'. c.y = 1; ~~~ -!!! error TS2341: Property 'C.y' is inaccessible. +!!! error TS2341: Property 'y' is private and only accessible within class 'C'. c.foo(); ~~~~~ -!!! error TS2341: Property 'C.foo' is inaccessible. +!!! error TS2341: Property 'foo' is private and only accessible within class 'C'. C.a; ~~~ -!!! error TS2341: Property 'C.a' is inaccessible. +!!! error TS2341: Property 'a' is private and only accessible within class 'C'. C.b(); ~~~ -!!! error TS2341: Property 'C.b' is inaccessible. +!!! error TS2341: Property 'b' is private and only accessible within class 'C'. C.b = 1; ~~~ -!!! error TS2341: Property 'C.b' is inaccessible. +!!! error TS2341: Property 'b' is private and only accessible within class 'C'. C.foo(); ~~~~~ -!!! error TS2341: Property 'C.foo' is inaccessible. \ No newline at end of file +!!! error TS2341: Property 'foo' is private and only accessible within class 'C'. \ No newline at end of file diff --git a/tests/baselines/reference/classPropertyAsProtected.errors.txt b/tests/baselines/reference/classPropertyAsProtected.errors.txt new file mode 100644 index 0000000000000..570ebc718ac42 --- /dev/null +++ b/tests/baselines/reference/classPropertyAsProtected.errors.txt @@ -0,0 +1,62 @@ +tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(3,19): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(4,19): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(8,26): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(9,26): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. +tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(15,1): error TS2445: Property 'x' is protected and only accessible within class 'C' and its subclasses. +tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(16,1): error TS2445: Property 'y' is protected and only accessible within class 'C' and its subclasses. +tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(17,1): error TS2445: Property 'y' is protected and only accessible within class 'C' and its subclasses. +tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(18,1): error TS2445: Property 'foo' is protected and only accessible within class 'C' and its subclasses. +tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(20,1): error TS2445: Property 'a' is protected and only accessible within class 'C' and its subclasses. +tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(21,1): error TS2445: Property 'b' is protected and only accessible within class 'C' and its subclasses. +tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(22,1): error TS2445: Property 'b' is protected and only accessible within class 'C' and its subclasses. +tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts(23,1): error TS2445: Property 'foo' is protected and only accessible within class 'C' and its subclasses. + + +==== tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts (12 errors) ==== + class C { + protected x: string; + protected get y() { return null; } + ~ +!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. + protected set y(x) { } + ~ +!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. + protected foo() { } + + protected static a: string; + protected static get b() { return null; } + ~ +!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. + protected static set b(x) { } + ~ +!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. + protected static foo() { } + } + + var c: C; + // all errors + c.x; + ~~~ +!!! error TS2445: Property 'x' is protected and only accessible within class 'C' and its subclasses. + c.y; + ~~~ +!!! error TS2445: Property 'y' is protected and only accessible within class 'C' and its subclasses. + c.y = 1; + ~~~ +!!! error TS2445: Property 'y' is protected and only accessible within class 'C' and its subclasses. + c.foo(); + ~~~~~ +!!! error TS2445: Property 'foo' is protected and only accessible within class 'C' and its subclasses. + + C.a; + ~~~ +!!! error TS2445: Property 'a' is protected and only accessible within class 'C' and its subclasses. + C.b(); + ~~~ +!!! error TS2445: Property 'b' is protected and only accessible within class 'C' and its subclasses. + C.b = 1; + ~~~ +!!! error TS2445: Property 'b' is protected and only accessible within class 'C' and its subclasses. + C.foo(); + ~~~~~ +!!! error TS2445: Property 'foo' is protected and only accessible within class 'C' and its subclasses. \ No newline at end of file diff --git a/tests/baselines/reference/classUpdateTests.errors.txt b/tests/baselines/reference/classUpdateTests.errors.txt index 660f2791148df..4548560df1565 100644 --- a/tests/baselines/reference/classUpdateTests.errors.txt +++ b/tests/baselines/reference/classUpdateTests.errors.txt @@ -10,9 +10,9 @@ tests/cases/compiler/classUpdateTests.ts(46,17): error TS2311: A class may only tests/cases/compiler/classUpdateTests.ts(47,18): error TS2335: 'super' can only be referenced in a derived class. tests/cases/compiler/classUpdateTests.ts(57,2): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties. tests/cases/compiler/classUpdateTests.ts(63,7): error TS2416: Class 'L' incorrectly extends base class 'G': - Private property 'p1' cannot be reimplemented. + Property 'p1' is private in type 'L' but not in type 'G'. tests/cases/compiler/classUpdateTests.ts(69,7): error TS2416: Class 'M' incorrectly extends base class 'G': - Private property 'p1' cannot be reimplemented. + Property 'p1' is private in type 'M' but not in type 'G'. tests/cases/compiler/classUpdateTests.ts(70,2): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties. tests/cases/compiler/classUpdateTests.ts(105,15): error TS2339: Property 'p1' does not exist on type 'Q'. tests/cases/compiler/classUpdateTests.ts(111,16): error TS2339: Property 'p1' does not exist on type 'R'. @@ -97,7 +97,7 @@ tests/cases/compiler/classUpdateTests.ts(111,16): error TS2339: Property 'p1' do class L extends G { ~ !!! error TS2416: Class 'L' incorrectly extends base class 'G': -!!! error TS2416: Private property 'p1' cannot be reimplemented. +!!! error TS2416: Property 'p1' is private in type 'L' but not in type 'G'. constructor(private p1:number) { super(); // NO ERROR } @@ -106,7 +106,7 @@ tests/cases/compiler/classUpdateTests.ts(111,16): error TS2339: Property 'p1' do class M extends G { ~ !!! error TS2416: Class 'M' incorrectly extends base class 'G': -!!! error TS2416: Private property 'p1' cannot be reimplemented. +!!! error TS2416: Property 'p1' is private in type 'M' but not in type 'G'. constructor(private p1:number) { // ERROR ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ var i = 0; diff --git a/tests/baselines/reference/classWithPrivateProperty.errors.txt b/tests/baselines/reference/classWithPrivateProperty.errors.txt index 54d960a412a16..93a94e2107582 100644 --- a/tests/baselines/reference/classWithPrivateProperty.errors.txt +++ b/tests/baselines/reference/classWithPrivateProperty.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/types/members/classWithPrivateProperty.ts(15,18): error TS2341: Property 'C.x' is inaccessible. -tests/cases/conformance/types/members/classWithPrivateProperty.ts(16,18): error TS2341: Property 'C.a' is inaccessible. -tests/cases/conformance/types/members/classWithPrivateProperty.ts(17,18): error TS2341: Property 'C.b' is inaccessible. -tests/cases/conformance/types/members/classWithPrivateProperty.ts(18,18): error TS2341: Property 'C.c' is inaccessible. -tests/cases/conformance/types/members/classWithPrivateProperty.ts(19,18): error TS2341: Property 'C.d' is inaccessible. -tests/cases/conformance/types/members/classWithPrivateProperty.ts(20,18): error TS2341: Property 'C.e' is inaccessible. -tests/cases/conformance/types/members/classWithPrivateProperty.ts(21,18): error TS2341: Property 'C.f' is inaccessible. -tests/cases/conformance/types/members/classWithPrivateProperty.ts(22,18): error TS2341: Property 'C.g' is inaccessible. +tests/cases/conformance/types/members/classWithPrivateProperty.ts(15,18): error TS2341: Property 'x' is private and only accessible within class 'C'. +tests/cases/conformance/types/members/classWithPrivateProperty.ts(16,18): error TS2341: Property 'a' is private and only accessible within class 'C'. +tests/cases/conformance/types/members/classWithPrivateProperty.ts(17,18): error TS2341: Property 'b' is private and only accessible within class 'C'. +tests/cases/conformance/types/members/classWithPrivateProperty.ts(18,18): error TS2341: Property 'c' is private and only accessible within class 'C'. +tests/cases/conformance/types/members/classWithPrivateProperty.ts(19,18): error TS2341: Property 'd' is private and only accessible within class 'C'. +tests/cases/conformance/types/members/classWithPrivateProperty.ts(20,18): error TS2341: Property 'e' is private and only accessible within class 'C'. +tests/cases/conformance/types/members/classWithPrivateProperty.ts(21,18): error TS2341: Property 'f' is private and only accessible within class 'C'. +tests/cases/conformance/types/members/classWithPrivateProperty.ts(22,18): error TS2341: Property 'g' is private and only accessible within class 'C'. ==== tests/cases/conformance/types/members/classWithPrivateProperty.ts (8 errors) ==== @@ -25,25 +25,25 @@ tests/cases/conformance/types/members/classWithPrivateProperty.ts(22,18): error var c = new C(); var r1: string = c.x; ~~~ -!!! error TS2341: Property 'C.x' is inaccessible. +!!! error TS2341: Property 'x' is private and only accessible within class 'C'. var r2: string = c.a; ~~~ -!!! error TS2341: Property 'C.a' is inaccessible. +!!! error TS2341: Property 'a' is private and only accessible within class 'C'. var r3: string = c.b; ~~~ -!!! error TS2341: Property 'C.b' is inaccessible. +!!! error TS2341: Property 'b' is private and only accessible within class 'C'. var r4: string = c.c(); ~~~ -!!! error TS2341: Property 'C.c' is inaccessible. +!!! error TS2341: Property 'c' is private and only accessible within class 'C'. var r5: string = c.d(); ~~~ -!!! error TS2341: Property 'C.d' is inaccessible. +!!! error TS2341: Property 'd' is private and only accessible within class 'C'. var r6: string = C.e; ~~~ -!!! error TS2341: Property 'C.e' is inaccessible. +!!! error TS2341: Property 'e' is private and only accessible within class 'C'. var r7: string = C.f(); ~~~ -!!! error TS2341: Property 'C.f' is inaccessible. +!!! error TS2341: Property 'f' is private and only accessible within class 'C'. var r8: string = C.g(); ~~~ -!!! error TS2341: Property 'C.g' is inaccessible. \ No newline at end of file +!!! error TS2341: Property 'g' is private and only accessible within class 'C'. \ No newline at end of file diff --git a/tests/baselines/reference/cloduleStaticMembers.errors.txt b/tests/baselines/reference/cloduleStaticMembers.errors.txt index 5b396c3be35da..914fea72424b3 100644 --- a/tests/baselines/reference/cloduleStaticMembers.errors.txt +++ b/tests/baselines/reference/cloduleStaticMembers.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/cloduleStaticMembers.ts(6,13): error TS2341: Property 'Clod.x' is inaccessible. +tests/cases/compiler/cloduleStaticMembers.ts(6,13): error TS2341: Property 'x' is private and only accessible within class 'Clod'. tests/cases/compiler/cloduleStaticMembers.ts(7,13): error TS2304: Cannot find name 'x'. tests/cases/compiler/cloduleStaticMembers.ts(10,13): error TS2304: Cannot find name 'y'. @@ -11,7 +11,7 @@ tests/cases/compiler/cloduleStaticMembers.ts(10,13): error TS2304: Cannot find n module Clod { var p = Clod.x; ~~~~~~ -!!! error TS2341: Property 'Clod.x' is inaccessible. +!!! error TS2341: Property 'x' is private and only accessible within class 'Clod'. var q = x; ~ !!! error TS2304: Cannot find name 'x'. diff --git a/tests/baselines/reference/constructorParameterProperties.errors.txt b/tests/baselines/reference/constructorParameterProperties.errors.txt index ed41bec0e4a96..ab9bebe9d2d0f 100644 --- a/tests/baselines/reference/constructorParameterProperties.errors.txt +++ b/tests/baselines/reference/constructorParameterProperties.errors.txt @@ -1,30 +1,39 @@ -tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(8,10): error TS2341: Property 'C.x' is inaccessible. -tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(17,10): error TS2341: Property 'D.x' is inaccessible. -tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(18,12): error TS2339: Property 'a' does not exist on type 'D'. +tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(8,10): error TS2341: Property 'x' is private and only accessible within class 'C'. +tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(9,10): error TS2445: Property 'z' is protected and only accessible within class 'C' and its subclasses. +tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(18,10): error TS2341: Property 'x' is private and only accessible within class 'D'. +tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(19,12): error TS2339: Property 'a' does not exist on type 'D'. +tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts(20,10): error TS2445: Property 'z' is protected and only accessible within class 'D' and its subclasses. -==== tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts (3 errors) ==== +==== tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts (5 errors) ==== class C { y: string; - constructor(private x: string) { } + constructor(private x: string, protected z: string) { } } var c: C; var r = c.y; var r2 = c.x; // error ~~~ -!!! error TS2341: Property 'C.x' is inaccessible. +!!! error TS2341: Property 'x' is private and only accessible within class 'C'. + var r3 = c.z; // error + ~~~ +!!! error TS2445: Property 'z' is protected and only accessible within class 'C' and its subclasses. class D { y: T; - constructor(a: T, private x: T) { } + constructor(a: T, private x: T, protected z: T) { } } var d: D; var r = d.y; var r2 = d.x; // error ~~~ -!!! error TS2341: Property 'D.x' is inaccessible. +!!! error TS2341: Property 'x' is private and only accessible within class 'D'. var r3 = d.a; // error ~ -!!! error TS2339: Property 'a' does not exist on type 'D'. \ No newline at end of file +!!! error TS2339: Property 'a' does not exist on type 'D'. + var r4 = d.z; // error + ~~~ +!!! error TS2445: Property 'z' is protected and only accessible within class 'D' and its subclasses. + \ No newline at end of file diff --git a/tests/baselines/reference/constructorParameterProperties.js b/tests/baselines/reference/constructorParameterProperties.js index 37ba30d24b05a..11446a316d39d 100644 --- a/tests/baselines/reference/constructorParameterProperties.js +++ b/tests/baselines/reference/constructorParameterProperties.js @@ -1,36 +1,42 @@ //// [constructorParameterProperties.ts] class C { y: string; - constructor(private x: string) { } + constructor(private x: string, protected z: string) { } } var c: C; var r = c.y; var r2 = c.x; // error +var r3 = c.z; // error class D { y: T; - constructor(a: T, private x: T) { } + constructor(a: T, private x: T, protected z: T) { } } var d: D; var r = d.y; var r2 = d.x; // error -var r3 = d.a; // error +var r3 = d.a; // error +var r4 = d.z; // error + //// [constructorParameterProperties.js] var C = (function () { - function C(x) { + function C(x, z) { this.x = x; + this.z = z; } return C; })(); var c; var r = c.y; var r2 = c.x; // error +var r3 = c.z; // error var D = (function () { - function D(a, x) { + function D(a, x, z) { this.x = x; + this.z = z; } return D; })(); @@ -38,3 +44,4 @@ var d; var r = d.y; var r2 = d.x; // error var r3 = d.a; // error +var r4 = d.z; // error diff --git a/tests/baselines/reference/constructorParameterProperties2.errors.txt b/tests/baselines/reference/constructorParameterProperties2.errors.txt index e6535bbbd54ca..df759fbe70911 100644 --- a/tests/baselines/reference/constructorParameterProperties2.errors.txt +++ b/tests/baselines/reference/constructorParameterProperties2.errors.txt @@ -1,8 +1,9 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(11,24): error TS2300: Duplicate identifier 'y'. tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(19,25): error TS2300: Duplicate identifier 'y'. +tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts(27,27): error TS2300: Duplicate identifier 'y'. -==== tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts (2 errors) ==== +==== tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts (3 errors) ==== class C { y: number; constructor(y: number) { } // ok @@ -29,4 +30,15 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/co } var e: E; - var r3 = e.y; // error \ No newline at end of file + var r3 = e.y; // error + + class F { + y: number; + constructor(protected y: number) { } // error + ~ +!!! error TS2300: Duplicate identifier 'y'. + } + + var f: F; + var r4 = f.y; // error + \ No newline at end of file diff --git a/tests/baselines/reference/constructorParameterProperties2.js b/tests/baselines/reference/constructorParameterProperties2.js index 8ad0c8b6ea632..02e4cf82c8403 100644 --- a/tests/baselines/reference/constructorParameterProperties2.js +++ b/tests/baselines/reference/constructorParameterProperties2.js @@ -21,7 +21,16 @@ class E { } var e: E; -var r3 = e.y; // error +var r3 = e.y; // error + +class F { + y: number; + constructor(protected y: number) { } // error +} + +var f: F; +var r4 = f.y; // error + //// [constructorParameterProperties2.js] var C = (function () { @@ -47,3 +56,11 @@ var E = (function () { })(); var e; var r3 = e.y; // error +var F = (function () { + function F(y) { + this.y = y; + } // error + return F; +})(); +var f; +var r4 = f.y; // error diff --git a/tests/baselines/reference/derivedClassOverridesPrivateFunction1.errors.txt b/tests/baselines/reference/derivedClassOverridesPrivateFunction1.errors.txt index 275701c797c75..ce9ec20406cd9 100644 --- a/tests/baselines/reference/derivedClassOverridesPrivateFunction1.errors.txt +++ b/tests/baselines/reference/derivedClassOverridesPrivateFunction1.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/derivedClassOverridesPrivateFunction1.ts(8,7): error TS2416: Class 'DerivedClass' incorrectly extends base class 'BaseClass': - Private property '_init' cannot be reimplemented. + Types have separate declarations of a private property '_init'. ==== tests/cases/compiler/derivedClassOverridesPrivateFunction1.ts (1 errors) ==== @@ -13,7 +13,7 @@ tests/cases/compiler/derivedClassOverridesPrivateFunction1.ts(8,7): error TS2416 class DerivedClass extends BaseClass { ~~~~~~~~~~~~ !!! error TS2416: Class 'DerivedClass' incorrectly extends base class 'BaseClass': -!!! error TS2416: Private property '_init' cannot be reimplemented. +!!! error TS2416: Types have separate declarations of a private property '_init'. constructor() { super(); } diff --git a/tests/baselines/reference/derivedClassOverridesPrivates.errors.txt b/tests/baselines/reference/derivedClassOverridesPrivates.errors.txt index 8f12f02bc3ae1..9e83faa9b4af0 100644 --- a/tests/baselines/reference/derivedClassOverridesPrivates.errors.txt +++ b/tests/baselines/reference/derivedClassOverridesPrivates.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPrivates.ts(5,7): error TS2416: Class 'Derived' incorrectly extends base class 'Base': - Private property 'x' cannot be reimplemented. + Types have separate declarations of a private property 'x'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPrivates.ts(13,7): error TS2418: Class static side 'typeof Derived2' incorrectly extends base class static side 'typeof Base2': - Private property 'y' cannot be reimplemented. + Types have separate declarations of a private property 'y'. ==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPrivates.ts (2 errors) ==== @@ -12,7 +12,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve class Derived extends Base { ~~~~~~~ !!! error TS2416: Class 'Derived' incorrectly extends base class 'Base': -!!! error TS2416: Private property 'x' cannot be reimplemented. +!!! error TS2416: Types have separate declarations of a private property 'x'. private x: { foo: string; bar: string; }; // error } @@ -23,6 +23,6 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve class Derived2 extends Base2 { ~~~~~~~~ !!! error TS2418: Class static side 'typeof Derived2' incorrectly extends base class static side 'typeof Base2': -!!! error TS2418: Private property 'y' cannot be reimplemented. +!!! error TS2418: Types have separate declarations of a private property 'y'. private static y: { foo: string; bar: string; }; // error } \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.errors.txt b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.errors.txt index 5bd992fa0b78a..f85e3be4b5ae3 100644 --- a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.errors.txt +++ b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWit tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateInstanceShadowingPublicInstance.ts(18,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateInstanceShadowingPublicInstance.ts(19,17): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateInstanceShadowingPublicInstance.ts(12,7): error TS2416: Class 'Derived' incorrectly extends base class 'Base': - Private property 'x' cannot be reimplemented. + Property 'x' is private in type 'Derived' but not in type 'Base'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateInstanceShadowingPublicInstance.ts(22,14): error TS2339: Property 'x' does not exist on type 'typeof Base'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateInstanceShadowingPublicInstance.ts(23,18): error TS2339: Property 'x' does not exist on type 'typeof Derived'. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateInstanceShadowingPublicInstance.ts(25,15): error TS2339: Property 'fn' does not exist on type 'typeof Base'. @@ -33,7 +33,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWit class Derived extends Base { ~~~~~~~ !!! error TS2416: Class 'Derived' incorrectly extends base class 'Base': -!!! error TS2416: Private property 'x' cannot be reimplemented. +!!! error TS2416: Property 'x' is private in type 'Derived' but not in type 'Base'. private x: string; private fn(): string { return ''; diff --git a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.errors.txt b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.errors.txt index 5ac30473e298d..a792c8ebff0fd 100644 --- a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.errors.txt +++ b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.errors.txt @@ -3,11 +3,11 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWit tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(19,24): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(20,24): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(13,7): error TS2418: Class static side 'typeof Derived' incorrectly extends base class static side 'typeof Base': - Private property 'x' cannot be reimplemented. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(24,10): error TS2341: Property 'Derived.x' is inaccessible. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(27,10): error TS2341: Property 'Derived.fn' is inaccessible. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(32,10): error TS2341: Property 'Derived.a' is inaccessible. -tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(33,1): error TS2341: Property 'Derived.a' is inaccessible. + Property 'x' is private in type 'typeof Derived' but not in type 'typeof Base'. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(24,10): error TS2341: Property 'x' is private and only accessible within class 'Derived'. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(27,10): error TS2341: Property 'fn' is private and only accessible within class 'Derived'. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(32,10): error TS2341: Property 'a' is private and only accessible within class 'Derived'. +tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts(33,1): error TS2341: Property 'a' is private and only accessible within class 'Derived'. ==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithPrivateStaticShadowingPublicStatic.ts (9 errors) ==== @@ -30,7 +30,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWit class Derived extends Base { ~~~~~~~ !!! error TS2418: Class static side 'typeof Derived' incorrectly extends base class static side 'typeof Base': -!!! error TS2418: Private property 'x' cannot be reimplemented. +!!! error TS2418: Property 'x' is private in type 'typeof Derived' but not in type 'typeof Base'. private static x: string; private static fn(): string { return ''; @@ -47,19 +47,19 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWit var r = Base.x; // ok var r2 = Derived.x; // error ~~~~~~~~~ -!!! error TS2341: Property 'Derived.x' is inaccessible. +!!! error TS2341: Property 'x' is private and only accessible within class 'Derived'. var r3 = Base.fn(); // ok var r4 = Derived.fn(); // error ~~~~~~~~~~ -!!! error TS2341: Property 'Derived.fn' is inaccessible. +!!! error TS2341: Property 'fn' is private and only accessible within class 'Derived'. var r5 = Base.a; // ok Base.a = 2; // ok var r6 = Derived.a; // error ~~~~~~~~~ -!!! error TS2341: Property 'Derived.a' is inaccessible. +!!! error TS2341: Property 'a' is private and only accessible within class 'Derived'. Derived.a = 2; // error ~~~~~~~~~ -!!! error TS2341: Property 'Derived.a' is inaccessible. \ No newline at end of file +!!! error TS2341: Property 'a' is private and only accessible within class 'Derived'. \ No newline at end of file diff --git a/tests/baselines/reference/errorSuperPropertyAccess.errors.txt b/tests/baselines/reference/errorSuperPropertyAccess.errors.txt index eba9953c34cae..e192e99b87f78 100644 --- a/tests/baselines/reference/errorSuperPropertyAccess.errors.txt +++ b/tests/baselines/reference/errorSuperPropertyAccess.errors.txt @@ -15,25 +15,25 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(21,9): error TS2335: 'super' can only be referenced in a derived class. 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(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 methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(61,23): error TS2340: Only public methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(65,23): error TS2340: Only public methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(69,19): error TS2340: Only public 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(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(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 methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(91,23): error TS2340: Only public methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(95,23): error TS2340: Only public methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(99,19): error TS2340: Only public methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(109,15): error TS2340: Only public methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(110,15): error TS2340: Only public methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(111,9): error TS2341: Property 'SomeBase.privateStaticFunc' is inaccessible. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(114,15): error TS2340: Only public methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(115,15): error TS2340: Only public methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(116,9): error TS2341: Property 'SomeBase.privateStaticFunc' is inaccessible. -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(120,15): error TS2340: Only public methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(121,15): error TS2340: Only public methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess.ts(122,9): error TS2341: Property 'SomeBase.privateStaticFunc' is inaccessible. +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(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(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(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(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 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 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 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,7 +141,7 @@ 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 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() { @@ -165,13 +165,13 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess super(); super.privateMember = 1; ~~~~~~~~~~~~~ -!!! error TS2340: Only public 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 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 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 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,26 +199,26 @@ tests/cases/conformance/expressions/superPropertyAccess/errorSuperPropertyAccess static fn() { super.publicStaticMember = 3; ~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public 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 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 'SomeBase.privateStaticFunc' is inaccessible. +!!! error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. } static get a() { ~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. super.publicStaticMember = 3; ~~~~~~~~~~~~~~~~~~ -!!! error TS2340: Only public 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 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 'SomeBase.privateStaticFunc' is inaccessible. +!!! error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. return ''; } static set a(n) { @@ -226,13 +226,13 @@ 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 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 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 'SomeBase.privateStaticFunc' is inaccessible. +!!! error TS2341: Property 'privateStaticFunc' is private and only accessible within class 'SomeBase'. } } diff --git a/tests/baselines/reference/functionOverloadErrors.errors.txt b/tests/baselines/reference/functionOverloadErrors.errors.txt index 05fafcb78c1c7..bc4fea0a98bc1 100644 --- a/tests/baselines/reference/functionOverloadErrors.errors.txt +++ b/tests/baselines/reference/functionOverloadErrors.errors.txt @@ -2,8 +2,8 @@ tests/cases/conformance/functions/functionOverloadErrors.ts(2,14): error TS2371: tests/cases/conformance/functions/functionOverloadErrors.ts(44,25): error TS2304: Cannot find name 'Window'. tests/cases/conformance/functions/functionOverloadErrors.ts(50,25): error TS2304: Cannot find name 'Window'. tests/cases/conformance/functions/functionOverloadErrors.ts(51,32): error TS2304: Cannot find name 'window'. -tests/cases/conformance/functions/functionOverloadErrors.ts(65,13): error TS2385: Overload signatures must all be public or private. -tests/cases/conformance/functions/functionOverloadErrors.ts(68,13): error TS2385: Overload signatures must all be public or private. +tests/cases/conformance/functions/functionOverloadErrors.ts(65,13): error TS2385: Overload signatures must all be public, private or protected. +tests/cases/conformance/functions/functionOverloadErrors.ts(68,13): error TS2385: Overload signatures must all be public, private or protected. tests/cases/conformance/functions/functionOverloadErrors.ts(75,21): error TS2383: Overload signatures must all be exported or not exported. tests/cases/conformance/functions/functionOverloadErrors.ts(79,14): error TS2383: Overload signatures must all be exported or not exported. tests/cases/conformance/functions/functionOverloadErrors.ts(85,18): error TS2384: Overload signatures must all be ambient or non-ambient. @@ -89,12 +89,12 @@ tests/cases/conformance/functions/functionOverloadErrors.ts(116,19): error TS237 public f(); private f(s: string); ~ -!!! error TS2385: Overload signatures must all be public or private. +!!! error TS2385: Overload signatures must all be public, private or protected. f() { } private g(s: string); ~ -!!! error TS2385: Overload signatures must all be public or private. +!!! error TS2385: Overload signatures must all be public, private or protected. public g(); g() { } } diff --git a/tests/baselines/reference/functionOverloads5.errors.txt b/tests/baselines/reference/functionOverloads5.errors.txt index 8c5639b87e43b..60a74f103e0dd 100644 --- a/tests/baselines/reference/functionOverloads5.errors.txt +++ b/tests/baselines/reference/functionOverloads5.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/functionOverloads5.ts(2,10): error TS2385: Overload signatures must all be public or private. +tests/cases/compiler/functionOverloads5.ts(2,10): error TS2385: Overload signatures must all be public, private or protected. ==== tests/cases/compiler/functionOverloads5.ts (1 errors) ==== class baz { public foo(); ~~~ -!!! error TS2385: Overload signatures must all be public or private. +!!! error TS2385: Overload signatures must all be public, private or protected. private foo(bar?:any){ } } \ No newline at end of file diff --git a/tests/baselines/reference/getEmitOutputDeclarationMultiFiles.baseline b/tests/baselines/reference/getEmitOutputDeclarationMultiFiles.baseline index 6aec1296d815e..4b89414059cdb 100644 --- a/tests/baselines/reference/getEmitOutputDeclarationMultiFiles.baseline +++ b/tests/baselines/reference/getEmitOutputDeclarationMultiFiles.baseline @@ -1,30 +1,30 @@ EmitOutputStatus : Succeeded Filename : tests/cases/fourslash/inputFile1.js -var x = 5; -var Bar = (function () { - function Bar() { - } - return Bar; -})(); +var x = 5; +var Bar = (function () { + function Bar() { + } + return Bar; +})(); Filename : tests/cases/fourslash/inputFile1.d.ts -declare var x: number; -declare class Bar { - x: string; - y: number; -} +declare var x: number; +declare class Bar { + x: string; + y: number; +} EmitOutputStatus : Succeeded Filename : tests/cases/fourslash/inputFile2.js -var x1 = "hello world"; -var Foo = (function () { - function Foo() { - } - return Foo; -})(); +var x1 = "hello world"; +var Foo = (function () { + function Foo() { + } + return Foo; +})(); Filename : tests/cases/fourslash/inputFile2.d.ts -declare var x1: string; -declare class Foo { - x: string; - y: number; -} +declare var x1: string; +declare class Foo { + x: string; + y: number; +} diff --git a/tests/baselines/reference/getEmitOutputDeclarationSingleFile.baseline b/tests/baselines/reference/getEmitOutputDeclarationSingleFile.baseline index ba40a69e39d6f..545c37a0728f2 100644 --- a/tests/baselines/reference/getEmitOutputDeclarationSingleFile.baseline +++ b/tests/baselines/reference/getEmitOutputDeclarationSingleFile.baseline @@ -1,26 +1,26 @@ EmitOutputStatus : Succeeded Filename : declSingleFile.js -var x = 5; -var Bar = (function () { - function Bar() { - } - return Bar; -})(); -var x1 = "hello world"; -var Foo = (function () { - function Foo() { - } - return Foo; -})(); +var x = 5; +var Bar = (function () { + function Bar() { + } + return Bar; +})(); +var x1 = "hello world"; +var Foo = (function () { + function Foo() { + } + return Foo; +})(); Filename : declSingleFile.d.ts -declare var x: number; -declare class Bar { - x: string; - y: number; -} -declare var x1: string; -declare class Foo { - x: string; - y: number; -} +declare var x: number; +declare class Bar { + x: string; + y: number; +} +declare var x1: string; +declare class Foo { + x: string; + y: number; +} diff --git a/tests/baselines/reference/getEmitOutputMapRoots.baseline b/tests/baselines/reference/getEmitOutputMapRoots.baseline index 2630257b03af9..93dab28e6fcb8 100644 --- a/tests/baselines/reference/getEmitOutputMapRoots.baseline +++ b/tests/baselines/reference/getEmitOutputMapRoots.baseline @@ -1,11 +1,11 @@ EmitOutputStatus : Succeeded Filename : declSingleFile.js.map {"version":3,"file":"declSingleFile.js","sourceRoot":"","sources":["../tests/cases/fourslash/inputFile.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}Filename : declSingleFile.js -var x = 109; -var foo = "hello world"; -var M = (function () { - function M() { - } - return M; -})(); +var x = 109; +var foo = "hello world"; +var M = (function () { + function M() { + } + return M; +})(); //# sourceMappingURL=mapRootDir/declSingleFile.js.map diff --git a/tests/baselines/reference/getEmitOutputNoErrors.baseline b/tests/baselines/reference/getEmitOutputNoErrors.baseline index 000ddb29ef517..47ba14353194d 100644 --- a/tests/baselines/reference/getEmitOutputNoErrors.baseline +++ b/tests/baselines/reference/getEmitOutputNoErrors.baseline @@ -1,9 +1,9 @@ EmitOutputStatus : Succeeded Filename : tests/cases/fourslash/inputFile.js -var x; -var M = (function () { - function M() { - } - return M; -})(); +var x; +var M = (function () { + function M() { + } + return M; +})(); diff --git a/tests/baselines/reference/getEmitOutputOnlyOneFile.baseline b/tests/baselines/reference/getEmitOutputOnlyOneFile.baseline index eaca7cda673eb..1f61d57c81ee8 100644 --- a/tests/baselines/reference/getEmitOutputOnlyOneFile.baseline +++ b/tests/baselines/reference/getEmitOutputOnlyOneFile.baseline @@ -1,9 +1,9 @@ EmitOutputStatus : Succeeded Filename : tests/cases/fourslash/inputFile2.js -var x; -var Foo = (function () { - function Foo() { - } - return Foo; -})(); +var x; +var Foo = (function () { + function Foo() { + } + return Foo; +})(); diff --git a/tests/baselines/reference/getEmitOutputSingleFile.baseline b/tests/baselines/reference/getEmitOutputSingleFile.baseline index fd3d2af4a5a9e..dd8f2be8079f1 100644 --- a/tests/baselines/reference/getEmitOutputSingleFile.baseline +++ b/tests/baselines/reference/getEmitOutputSingleFile.baseline @@ -1,15 +1,15 @@ EmitOutputStatus : Succeeded Filename : outputDir/singleFile.js -var x; -var Bar = (function () { - function Bar() { - } - return Bar; -})(); -var x; -var Foo = (function () { - function Foo() { - } - return Foo; -})(); +var x; +var Bar = (function () { + function Bar() { + } + return Bar; +})(); +var x; +var Foo = (function () { + function Foo() { + } + return Foo; +})(); diff --git a/tests/baselines/reference/getEmitOutputSingleFile2.baseline b/tests/baselines/reference/getEmitOutputSingleFile2.baseline index aac50ee87cbf6..77fa6b9acdd38 100644 --- a/tests/baselines/reference/getEmitOutputSingleFile2.baseline +++ b/tests/baselines/reference/getEmitOutputSingleFile2.baseline @@ -1,32 +1,32 @@ EmitOutputStatus : Succeeded Filename : tests/cases/fourslash/inputFile3.js -exports.foo = 10; -exports.bar = "hello world"; +exports.foo = 10; +exports.bar = "hello world"; Filename : tests/cases/fourslash/inputFile3.d.ts -export declare var foo: number; -export declare var bar: string; +export declare var foo: number; +export declare var bar: string; Filename : declSingleFile.js -var x = 5; -var Bar = (function () { - function Bar() { - } - return Bar; -})(); -var x1 = "hello world"; -var Foo = (function () { - function Foo() { - } - return Foo; -})(); +var x = 5; +var Bar = (function () { + function Bar() { + } + return Bar; +})(); +var x1 = "hello world"; +var Foo = (function () { + function Foo() { + } + return Foo; +})(); Filename : declSingleFile.d.ts -declare var x: number; -declare class Bar { - x: string; - y: number; -} -declare var x1: string; -declare class Foo { - x: string; - y: number; -} +declare var x: number; +declare class Bar { + x: string; + y: number; +} +declare var x1: string; +declare class Foo { + x: string; + y: number; +} diff --git a/tests/baselines/reference/getEmitOutputSourceMap.baseline b/tests/baselines/reference/getEmitOutputSourceMap.baseline index e3b7a47e12505..75ee2a266179d 100644 --- a/tests/baselines/reference/getEmitOutputSourceMap.baseline +++ b/tests/baselines/reference/getEmitOutputSourceMap.baseline @@ -1,11 +1,11 @@ EmitOutputStatus : Succeeded Filename : tests/cases/fourslash/inputFile.js.map {"version":3,"file":"inputFile.js","sourceRoot":"","sources":["inputFile.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}Filename : tests/cases/fourslash/inputFile.js -var x = 109; -var foo = "hello world"; -var M = (function () { - function M() { - } - return M; -})(); +var x = 109; +var foo = "hello world"; +var M = (function () { + function M() { + } + return M; +})(); //# sourceMappingURL=inputFile.js.map diff --git a/tests/baselines/reference/getEmitOutputSourceMap2.baseline b/tests/baselines/reference/getEmitOutputSourceMap2.baseline index d6745389e3a65..2c132d8cd6601 100644 --- a/tests/baselines/reference/getEmitOutputSourceMap2.baseline +++ b/tests/baselines/reference/getEmitOutputSourceMap2.baseline @@ -1,19 +1,19 @@ EmitOutputStatus : Succeeded Filename : sample/outDir/inputFile1.js.map {"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["../../tests/cases/fourslash/inputFile1.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}Filename : sample/outDir/inputFile1.js -var x = 109; -var foo = "hello world"; -var M = (function () { - function M() { - } - return M; -})(); +var x = 109; +var foo = "hello world"; +var M = (function () { + function M() { + } + return M; +})(); //# sourceMappingURL=inputFile1.js.map EmitOutputStatus : Succeeded Filename : sample/outDir/inputFile2.js.map {"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["../../tests/cases/fourslash/inputFile2.ts"],"names":[],"mappings":"AAAA,IAAI,KAAK,GAAG,aAAa,CAAC;AAC1B,EAAE,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC;IACvB,IAAI,CAAC,GAAG,EAAE,CAAC;AACd,CAAC"}Filename : sample/outDir/inputFile2.js -var intro = "hello world"; -if (intro !== undefined) { - var k = 10; -} +var intro = "hello world"; +if (intro !== undefined) { + var k = 10; +} //# sourceMappingURL=inputFile2.js.map diff --git a/tests/baselines/reference/getEmitOutputSourceRoot.baseline b/tests/baselines/reference/getEmitOutputSourceRoot.baseline index d8cba7ddd97b0..9252163165b17 100644 --- a/tests/baselines/reference/getEmitOutputSourceRoot.baseline +++ b/tests/baselines/reference/getEmitOutputSourceRoot.baseline @@ -1,11 +1,11 @@ EmitOutputStatus : Succeeded Filename : tests/cases/fourslash/inputFile.js.map {"version":3,"file":"inputFile.js","sourceRoot":"sourceRootDir/","sources":["inputFile.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}Filename : tests/cases/fourslash/inputFile.js -var x = 109; -var foo = "hello world"; -var M = (function () { - function M() { - } - return M; -})(); +var x = 109; +var foo = "hello world"; +var M = (function () { + function M() { + } + return M; +})(); //# sourceMappingURL=inputFile.js.map diff --git a/tests/baselines/reference/getEmitOutputSourceRootMultiFiles.baseline b/tests/baselines/reference/getEmitOutputSourceRootMultiFiles.baseline index eec0b05ecaa47..5c26a1920f9f7 100644 --- a/tests/baselines/reference/getEmitOutputSourceRootMultiFiles.baseline +++ b/tests/baselines/reference/getEmitOutputSourceRootMultiFiles.baseline @@ -1,21 +1,21 @@ EmitOutputStatus : Succeeded Filename : tests/cases/fourslash/inputFile1.js.map {"version":3,"file":"inputFile1.js","sourceRoot":"sourceRootDir/","sources":["inputFile1.ts"],"names":["M","M.constructor"],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}Filename : tests/cases/fourslash/inputFile1.js -var x = 109; -var foo = "hello world"; -var M = (function () { - function M() { - } - return M; -})(); +var x = 109; +var foo = "hello world"; +var M = (function () { + function M() { + } + return M; +})(); //# sourceMappingURL=inputFile1.js.map EmitOutputStatus : Succeeded Filename : tests/cases/fourslash/inputFile2.js.map {"version":3,"file":"inputFile2.js","sourceRoot":"sourceRootDir/","sources":["inputFile2.ts"],"names":["C","C.constructor"],"mappings":"AAAA,IAAI,GAAG,GAAG,wBAAwB,CAAC;AACnC,IAAM,CAAC;IAAPA,SAAMA,CAACA;IAGPC,CAACA;IAADD,QAACA;AAADA,CAACA,AAHD,IAGC"}Filename : tests/cases/fourslash/inputFile2.js -var bar = "hello world Typescript"; -var C = (function () { - function C() { - } - return C; -})(); +var bar = "hello world Typescript"; +var C = (function () { + function C() { + } + return C; +})(); //# sourceMappingURL=inputFile2.js.map diff --git a/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline b/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline index 13df5b18c36d4..f16e381059203 100644 --- a/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline @@ -1,12 +1,12 @@ EmitOutputStatus : EmitErrorsEncountered Filename : tests/cases/fourslash/inputFile.js -var M; -(function (M) { - var C = (function () { - function C() { - } - return C; - })(); - M.foo = new C(); -})(M || (M = {})); +var M; +(function (M) { + var C = (function () { + function C() { + } + return C; + })(); + M.foo = new C(); +})(M || (M = {})); diff --git a/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline b/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline index c05c01eb91fc2..4befff0466ced 100644 --- a/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline +++ b/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline @@ -1,14 +1,14 @@ EmitOutputStatus : EmitErrorsEncountered Filename : tests/cases/fourslash/inputFile.js -define(["require", "exports"], function (require, exports) { - var C = (function () { - function C() { - } - return C; - })(); - var M; - (function (M) { - M.foo = new C(); - })(M = exports.M || (exports.M = {})); -}); +define(["require", "exports"], function (require, exports) { + var C = (function () { + function C() { + } + return C; + })(); + var M; + (function (M) { + M.foo = new C(); + })(M = exports.M || (exports.M = {})); +}); diff --git a/tests/baselines/reference/getEmitOutputWithSemanticErrors.baseline b/tests/baselines/reference/getEmitOutputWithSemanticErrors.baseline index dabcd85e85459..fed9a4d208936 100644 --- a/tests/baselines/reference/getEmitOutputWithSemanticErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithSemanticErrors.baseline @@ -1,4 +1,4 @@ EmitOutputStatus : JSGeneratedWithSemanticErrors Filename : tests/cases/fourslash/inputFile.js -var x = "hello world"; +var x = "hello world"; diff --git a/tests/baselines/reference/getEmitOutputWithSemanticErrors2.baseline b/tests/baselines/reference/getEmitOutputWithSemanticErrors2.baseline index 0dd36c7455724..a2e296b85e292 100644 --- a/tests/baselines/reference/getEmitOutputWithSemanticErrors2.baseline +++ b/tests/baselines/reference/getEmitOutputWithSemanticErrors2.baseline @@ -1,4 +1,4 @@ EmitOutputStatus : DeclarationGenerationSkipped Filename : tests/cases/fourslash/inputFile.js -var x = "hello world"; +var x = "hello world"; diff --git a/tests/baselines/reference/i3.errors.txt b/tests/baselines/reference/i3.errors.txt index 5d8b3b3fabf88..1a03e690a2ff4 100644 --- a/tests/baselines/reference/i3.errors.txt +++ b/tests/baselines/reference/i3.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/i3.ts(6,1): error TS2322: Type 'I3' is not assignable to type '{ one: number; }': - Required property 'one' cannot be reimplemented with optional property in 'I3'. + Property 'one' is optional in type 'I3' but required in type '{ one: number; }'. ==== tests/cases/compiler/i3.ts (1 errors) ==== @@ -11,4 +11,4 @@ tests/cases/compiler/i3.ts(6,1): error TS2322: Type 'I3' is not assignable to ty x = i; ~ !!! error TS2322: Type 'I3' is not assignable to type '{ one: number; }': -!!! error TS2322: Required property 'one' cannot be reimplemented with optional property in 'I3'. \ No newline at end of file +!!! error TS2322: Property 'one' is optional in type 'I3' but required in type '{ one: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/implementPublicPropertyAsPrivate.errors.txt b/tests/baselines/reference/implementPublicPropertyAsPrivate.errors.txt index b131ffbf3337b..c445403c3fa94 100644 --- a/tests/baselines/reference/implementPublicPropertyAsPrivate.errors.txt +++ b/tests/baselines/reference/implementPublicPropertyAsPrivate.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/implementPublicPropertyAsPrivate.ts(4,7): error TS2421: Class 'C' incorrectly implements interface 'I': - Private property 'x' cannot be reimplemented. + Property 'x' is private in type 'C' but not in type 'I'. ==== tests/cases/compiler/implementPublicPropertyAsPrivate.ts (1 errors) ==== @@ -9,6 +9,6 @@ tests/cases/compiler/implementPublicPropertyAsPrivate.ts(4,7): error TS2421: Cla class C implements I { ~ !!! error TS2421: Class 'C' incorrectly implements interface 'I': -!!! error TS2421: Private property 'x' cannot be reimplemented. +!!! error TS2421: Property 'x' is private in type 'C' but not in type 'I'. private x = 0; // should raise error at class decl } \ No newline at end of file diff --git a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates.errors.txt b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates.errors.txt index b2a41ed4d0540..ab12cb9708bdd 100644 --- a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates.errors.txt +++ b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates.errors.txt @@ -3,9 +3,9 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInte tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithPrivates.ts(12,7): error TS2421: Class 'Bar2' incorrectly implements interface 'I': Property 'x' is missing in type 'Bar2'. tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithPrivates.ts(16,7): error TS2421: Class 'Bar3' incorrectly implements interface 'I': - Private property 'x' cannot be reimplemented. + Property 'x' is private in type 'I' but not in type 'Bar3'. tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithPrivates.ts(21,7): error TS2421: Class 'Bar4' incorrectly implements interface 'I': - Private property 'x' cannot be reimplemented. + Types have separate declarations of a private property 'x'. ==== tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithPrivates.ts (4 errors) ==== @@ -33,7 +33,7 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInte class Bar3 implements I { // error ~~~~ !!! error TS2421: Class 'Bar3' incorrectly implements interface 'I': -!!! error TS2421: Private property 'x' cannot be reimplemented. +!!! error TS2421: Property 'x' is private in type 'I' but not in type 'Bar3'. x: string; y: number; } @@ -41,7 +41,7 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInte class Bar4 implements I { // error ~~~~ !!! error TS2421: Class 'Bar4' incorrectly implements interface 'I': -!!! error TS2421: Private property 'x' cannot be reimplemented. +!!! error TS2421: Types have separate declarations of a private property 'x'. private x: string; y: number; } \ No newline at end of file diff --git a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates2.errors.txt b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates2.errors.txt index 5333f34b98b11..53fc5c54bee36 100644 --- a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates2.errors.txt +++ b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithPrivates2.errors.txt @@ -1,29 +1,29 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithPrivates2.ts(13,7): error TS2416: Class 'Bar2' incorrectly extends base class 'Foo': - Private property 'x' cannot be reimplemented. + Property 'x' is private in type 'Foo' but not in type 'Bar2'. tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithPrivates2.ts(13,7): error TS2421: Class 'Bar2' incorrectly implements interface 'I': - Private property 'x' cannot be reimplemented. + Property 'x' is private in type 'I' but not in type 'Bar2'. tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithPrivates2.ts(18,7): error TS2416: Class 'Bar3' incorrectly extends base class 'Foo': - Private property 'x' cannot be reimplemented. + Types have separate declarations of a private property 'x'. tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithPrivates2.ts(18,7): error TS2421: Class 'Bar3' incorrectly implements interface 'I': - Private property 'x' cannot be reimplemented. + Types have separate declarations of a private property 'x'. tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithPrivates2.ts(42,11): error TS2416: Class 'Bar2' incorrectly extends base class 'Foo': - Private property 'x' cannot be reimplemented. + Property 'x' is private in type 'Foo' but not in type 'Bar2'. tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithPrivates2.ts(42,11): error TS2421: Class 'Bar2' incorrectly implements interface 'I': Property 'z' is missing in type 'Bar2'. tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithPrivates2.ts(47,11): error TS2416: Class 'Bar3' incorrectly extends base class 'Foo': - Private property 'x' cannot be reimplemented. + Types have separate declarations of a private property 'x'. tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithPrivates2.ts(47,11): error TS2421: Class 'Bar3' incorrectly implements interface 'I': Property 'z' is missing in type 'Bar3'. tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithPrivates2.ts(67,11): error TS2421: Class 'Bar' incorrectly implements interface 'I': Property 'y' is missing in type 'Bar'. -tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithPrivates2.ts(73,14): error TS2341: Property 'Foo.x' is inaccessible. +tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithPrivates2.ts(73,14): error TS2341: Property 'x' is private and only accessible within class 'Foo'. tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithPrivates2.ts(74,16): error TS2339: Property 'y' does not exist on type 'Bar'. tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithPrivates2.ts(76,11): error TS2416: Class 'Bar2' incorrectly extends base class 'Foo': - Private property 'x' cannot be reimplemented. + Property 'x' is private in type 'Foo' but not in type 'Bar2'. tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithPrivates2.ts(76,11): error TS2421: Class 'Bar2' incorrectly implements interface 'I': Property 'y' is missing in type 'Bar2'. tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithPrivates2.ts(81,11): error TS2416: Class 'Bar3' incorrectly extends base class 'Foo': - Private property 'x' cannot be reimplemented. + Types have separate declarations of a private property 'x'. tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithPrivates2.ts(81,11): error TS2421: Class 'Bar3' incorrectly implements interface 'I': Property 'y' is missing in type 'Bar3'. @@ -44,10 +44,10 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInte class Bar2 extends Foo implements I { // error ~~~~ !!! error TS2416: Class 'Bar2' incorrectly extends base class 'Foo': -!!! error TS2416: Private property 'x' cannot be reimplemented. +!!! error TS2416: Property 'x' is private in type 'Foo' but not in type 'Bar2'. ~~~~ !!! error TS2421: Class 'Bar2' incorrectly implements interface 'I': -!!! error TS2421: Private property 'x' cannot be reimplemented. +!!! error TS2421: Property 'x' is private in type 'I' but not in type 'Bar2'. x: string; y: number; } @@ -55,10 +55,10 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInte class Bar3 extends Foo implements I { // error ~~~~ !!! error TS2416: Class 'Bar3' incorrectly extends base class 'Foo': -!!! error TS2416: Private property 'x' cannot be reimplemented. +!!! error TS2416: Types have separate declarations of a private property 'x'. ~~~~ !!! error TS2421: Class 'Bar3' incorrectly implements interface 'I': -!!! error TS2421: Private property 'x' cannot be reimplemented. +!!! error TS2421: Types have separate declarations of a private property 'x'. private x: string; y: number; } @@ -85,7 +85,7 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInte class Bar2 extends Foo implements I { // error ~~~~ !!! error TS2416: Class 'Bar2' incorrectly extends base class 'Foo': -!!! error TS2416: Private property 'x' cannot be reimplemented. +!!! error TS2416: Property 'x' is private in type 'Foo' but not in type 'Bar2'. ~~~~ !!! error TS2421: Class 'Bar2' incorrectly implements interface 'I': !!! error TS2421: Property 'z' is missing in type 'Bar2'. @@ -96,7 +96,7 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInte class Bar3 extends Foo implements I { // error ~~~~ !!! error TS2416: Class 'Bar3' incorrectly extends base class 'Foo': -!!! error TS2416: Private property 'x' cannot be reimplemented. +!!! error TS2416: Types have separate declarations of a private property 'x'. ~~~~ !!! error TS2421: Class 'Bar3' incorrectly implements interface 'I': !!! error TS2421: Property 'z' is missing in type 'Bar3'. @@ -130,7 +130,7 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInte var r1 = b.z; var r2 = b.x; // error ~~~ -!!! error TS2341: Property 'Foo.x' is inaccessible. +!!! error TS2341: Property 'x' is private and only accessible within class 'Foo'. var r3 = b.y; // error ~ !!! error TS2339: Property 'y' does not exist on type 'Bar'. @@ -138,7 +138,7 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInte class Bar2 extends Foo implements I { // error ~~~~ !!! error TS2416: Class 'Bar2' incorrectly extends base class 'Foo': -!!! error TS2416: Private property 'x' cannot be reimplemented. +!!! error TS2416: Property 'x' is private in type 'Foo' but not in type 'Bar2'. ~~~~ !!! error TS2421: Class 'Bar2' incorrectly implements interface 'I': !!! error TS2421: Property 'y' is missing in type 'Bar2'. @@ -149,7 +149,7 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInte class Bar3 extends Foo implements I { // error ~~~~ !!! error TS2416: Class 'Bar3' incorrectly extends base class 'Foo': -!!! error TS2416: Private property 'x' cannot be reimplemented. +!!! error TS2416: Types have separate declarations of a private property 'x'. ~~~~ !!! error TS2421: Class 'Bar3' incorrectly implements interface 'I': !!! error TS2421: Property 'y' is missing in type 'Bar3'. diff --git a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt new file mode 100644 index 0000000000000..fc7cbbed97a9b --- /dev/null +++ b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.errors.txt @@ -0,0 +1,74 @@ +tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts(9,7): error TS2421: Class 'Bar' incorrectly implements interface 'I': + Property 'y' is missing in type 'Bar'. +tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts(12,7): error TS2421: Class 'Bar2' incorrectly implements interface 'I': + Property 'x' is missing in type 'Bar2'. +tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts(16,7): error TS2421: Class 'Bar3' incorrectly implements interface 'I': + Property 'x' is protected but type 'Bar3' is not a class derived from 'Foo'. +tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts(21,7): error TS2421: Class 'Bar4' incorrectly implements interface 'I': + Property 'x' is protected but type 'Bar4' is not a class derived from 'Foo'. +tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts(26,7): error TS2421: Class 'Bar5' incorrectly implements interface 'I': + Property 'y' is missing in type 'Bar5'. +tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts(29,7): error TS2421: Class 'Bar6' incorrectly implements interface 'I': + Property 'y' is protected in type 'Bar6' but public in type 'I'. + + +==== tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts (6 errors) ==== + class Foo { + protected x: string; + } + + interface I extends Foo { + y: number; + } + + class Bar implements I { // error + ~~~ +!!! error TS2421: Class 'Bar' incorrectly implements interface 'I': +!!! error TS2421: Property 'y' is missing in type 'Bar'. + } + + class Bar2 implements I { // error + ~~~~ +!!! error TS2421: Class 'Bar2' incorrectly implements interface 'I': +!!! error TS2421: Property 'x' is missing in type 'Bar2'. + y: number; + } + + class Bar3 implements I { // error + ~~~~ +!!! error TS2421: Class 'Bar3' incorrectly implements interface 'I': +!!! error TS2421: Property 'x' is protected but type 'Bar3' is not a class derived from 'Foo'. + x: string; + y: number; + } + + class Bar4 implements I { // error + ~~~~ +!!! error TS2421: Class 'Bar4' incorrectly implements interface 'I': +!!! error TS2421: Property 'x' is protected but type 'Bar4' is not a class derived from 'Foo'. + protected x: string; + y: number; + } + + class Bar5 extends Foo implements I { // error + ~~~~ +!!! error TS2421: Class 'Bar5' incorrectly implements interface 'I': +!!! error TS2421: Property 'y' is missing in type 'Bar5'. + } + + class Bar6 extends Foo implements I { // error + ~~~~ +!!! error TS2421: Class 'Bar6' incorrectly implements interface 'I': +!!! error TS2421: Property 'y' is protected in type 'Bar6' but public in type 'I'. + protected y: number; + } + + class Bar7 extends Foo implements I { + y: number; + } + + class Bar8 extends Foo implements I { + x: string; + y: number; + } + \ No newline at end of file diff --git a/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.js b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.js new file mode 100644 index 0000000000000..1a79496bd12d1 --- /dev/null +++ b/tests/baselines/reference/implementingAnInterfaceExtendingClassWithProtecteds.js @@ -0,0 +1,103 @@ +//// [implementingAnInterfaceExtendingClassWithProtecteds.ts] +class Foo { + protected x: string; +} + +interface I extends Foo { + y: number; +} + +class Bar implements I { // error +} + +class Bar2 implements I { // error + y: number; +} + +class Bar3 implements I { // error + x: string; + y: number; +} + +class Bar4 implements I { // error + protected x: string; + y: number; +} + +class Bar5 extends Foo implements I { // error +} + +class Bar6 extends Foo implements I { // error + protected y: number; +} + +class Bar7 extends Foo implements I { + y: number; +} + +class Bar8 extends Foo implements I { + x: string; + y: number; +} + + +//// [implementingAnInterfaceExtendingClassWithProtecteds.js] +var __extends = this.__extends || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +var Bar = (function () { + function Bar() { + } + return Bar; +})(); +var Bar2 = (function () { + function Bar2() { + } + return Bar2; +})(); +var Bar3 = (function () { + function Bar3() { + } + return Bar3; +})(); +var Bar4 = (function () { + function Bar4() { + } + return Bar4; +})(); +var Bar5 = (function (_super) { + __extends(Bar5, _super); + function Bar5() { + _super.apply(this, arguments); + } + return Bar5; +})(Foo); +var Bar6 = (function (_super) { + __extends(Bar6, _super); + function Bar6() { + _super.apply(this, arguments); + } + return Bar6; +})(Foo); +var Bar7 = (function (_super) { + __extends(Bar7, _super); + function Bar7() { + _super.apply(this, arguments); + } + return Bar7; +})(Foo); +var Bar8 = (function (_super) { + __extends(Bar8, _super); + function Bar8() { + _super.apply(this, arguments); + } + return Bar8; +})(Foo); diff --git a/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollision.errors.txt b/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollision.errors.txt index ae9c62b0f1ecd..8bcef0e5a1458 100644 --- a/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollision.errors.txt +++ b/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollision.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/inheritanceGrandParentPrivateMemberCollision.ts(7,7): error TS2416: Class 'C' incorrectly extends base class 'B': - Private property 'myMethod' cannot be reimplemented. + Types have separate declarations of a private property 'myMethod'. ==== tests/cases/compiler/inheritanceGrandParentPrivateMemberCollision.ts (1 errors) ==== @@ -12,7 +12,7 @@ tests/cases/compiler/inheritanceGrandParentPrivateMemberCollision.ts(7,7): error class C extends B { ~ !!! error TS2416: Class 'C' incorrectly extends base class 'B': -!!! error TS2416: Private property 'myMethod' cannot be reimplemented. +!!! error TS2416: Types have separate declarations of a private property 'myMethod'. private myMethod() { } } \ No newline at end of file diff --git a/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.errors.txt b/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.errors.txt index 532214638d9ac..7676029fb8bd0 100644 --- a/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.errors.txt +++ b/tests/baselines/reference/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.ts(7,7): error TS2416: Class 'C' incorrectly extends base class 'B': - Private property 'myMethod' cannot be reimplemented. + Property 'myMethod' is private in type 'B' but not in type 'C'. ==== tests/cases/compiler/inheritanceGrandParentPrivateMemberCollisionWithPublicMember.ts (1 errors) ==== @@ -12,7 +12,7 @@ tests/cases/compiler/inheritanceGrandParentPrivateMemberCollisionWithPublicMembe class C extends B { ~ !!! error TS2416: Class 'C' incorrectly extends base class 'B': -!!! error TS2416: Private property 'myMethod' cannot be reimplemented. +!!! error TS2416: Property 'myMethod' is private in type 'B' but not in type 'C'. public myMethod() { } } \ No newline at end of file diff --git a/tests/baselines/reference/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.errors.txt b/tests/baselines/reference/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.errors.txt index 06508ede86804..c5d41868fab8a 100644 --- a/tests/baselines/reference/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.errors.txt +++ b/tests/baselines/reference/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.ts(7,7): error TS2416: Class 'C' incorrectly extends base class 'B': - Private property 'myMethod' cannot be reimplemented. + Property 'myMethod' is private in type 'C' but not in type 'B'. ==== tests/cases/compiler/inheritanceGrandParentPublicMemberCollisionWithPrivateMember.ts (1 errors) ==== @@ -12,7 +12,7 @@ tests/cases/compiler/inheritanceGrandParentPublicMemberCollisionWithPrivateMembe class C extends B { ~ !!! error TS2416: Class 'C' incorrectly extends base class 'B': -!!! error TS2416: Private property 'myMethod' cannot be reimplemented. +!!! error TS2416: Property 'myMethod' is private in type 'C' but not in type 'B'. private myMethod() { } } \ No newline at end of file diff --git a/tests/baselines/reference/interfaceExtendingClassWithPrivates.errors.txt b/tests/baselines/reference/interfaceExtendingClassWithPrivates.errors.txt index f7abe9cb1286c..93d8b7cfa57e3 100644 --- a/tests/baselines/reference/interfaceExtendingClassWithPrivates.errors.txt +++ b/tests/baselines/reference/interfaceExtendingClassWithPrivates.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithPrivates.ts(5,11): error TS2429: Interface 'I' incorrectly extends interface 'Foo': - Private property 'x' cannot be reimplemented. -tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithPrivates.ts(15,10): error TS2341: Property 'Foo.x' is inaccessible. + Property 'x' is private in type 'Foo' but not in type 'I'. +tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithPrivates.ts(15,10): error TS2341: Property 'x' is private and only accessible within class 'Foo'. ==== tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithPrivates.ts (2 errors) ==== @@ -11,7 +11,7 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtending interface I extends Foo { // error ~ !!! error TS2429: Interface 'I' incorrectly extends interface 'Foo': -!!! error TS2429: Private property 'x' cannot be reimplemented. +!!! error TS2429: Property 'x' is private in type 'Foo' but not in type 'I'. x: string; } @@ -23,4 +23,4 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtending var r = i.y; var r2 = i.x; // error ~~~ -!!! error TS2341: Property 'Foo.x' is inaccessible. \ No newline at end of file +!!! error TS2341: Property 'x' is private and only accessible within class 'Foo'. \ No newline at end of file diff --git a/tests/baselines/reference/interfaceExtendingClassWithPrivates2.errors.txt b/tests/baselines/reference/interfaceExtendingClassWithPrivates2.errors.txt index 77ed7a486bf49..f17a1ef348514 100644 --- a/tests/baselines/reference/interfaceExtendingClassWithPrivates2.errors.txt +++ b/tests/baselines/reference/interfaceExtendingClassWithPrivates2.errors.txt @@ -1,11 +1,11 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithPrivates2.ts(9,11): error TS2320: Interface 'I3' cannot simultaneously extend types 'Foo' and 'Bar': Named properties 'x' of types 'Foo' and 'Bar' are not identical. tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithPrivates2.ts(12,11): error TS2429: Interface 'I4' incorrectly extends interface 'Bar': - Private property 'x' cannot be reimplemented. + Property 'x' is private in type 'Bar' but not in type 'I4'. tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithPrivates2.ts(12,11): error TS2429: Interface 'I4' incorrectly extends interface 'Foo': - Private property 'x' cannot be reimplemented. -tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithPrivates2.ts(26,10): error TS2341: Property 'Foo.x' is inaccessible. -tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithPrivates2.ts(27,10): error TS2341: Property 'Baz.y' is inaccessible. + Property 'x' is private in type 'Foo' but not in type 'I4'. +tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithPrivates2.ts(26,10): error TS2341: Property 'x' is private and only accessible within class 'Foo'. +tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithPrivates2.ts(27,10): error TS2341: Property 'y' is private and only accessible within class 'Baz'. ==== tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithPrivates2.ts (5 errors) ==== @@ -26,10 +26,10 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtending interface I4 extends Foo, Bar { // error ~~ !!! error TS2429: Interface 'I4' incorrectly extends interface 'Bar': -!!! error TS2429: Private property 'x' cannot be reimplemented. +!!! error TS2429: Property 'x' is private in type 'Bar' but not in type 'I4'. ~~ !!! error TS2429: Interface 'I4' incorrectly extends interface 'Foo': -!!! error TS2429: Private property 'x' cannot be reimplemented. +!!! error TS2429: Property 'x' is private in type 'Foo' but not in type 'I4'. x: string; } @@ -45,7 +45,7 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtending var r: string = i.z; var r2 = i.x; // error ~~~ -!!! error TS2341: Property 'Foo.x' is inaccessible. +!!! error TS2341: Property 'x' is private and only accessible within class 'Foo'. var r3 = i.y; // error ~~~ -!!! error TS2341: Property 'Baz.y' is inaccessible. \ No newline at end of file +!!! error TS2341: Property 'y' is private and only accessible within class 'Baz'. \ No newline at end of file diff --git a/tests/baselines/reference/interfaceExtendingClassWithProtecteds.errors.txt b/tests/baselines/reference/interfaceExtendingClassWithProtecteds.errors.txt new file mode 100644 index 0000000000000..1cbc921e1ac48 --- /dev/null +++ b/tests/baselines/reference/interfaceExtendingClassWithProtecteds.errors.txt @@ -0,0 +1,26 @@ +tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithProtecteds.ts(5,11): error TS2429: Interface 'I' incorrectly extends interface 'Foo': + Property 'x' is protected but type 'I' is not a class derived from 'Foo'. +tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithProtecteds.ts(15,10): error TS2445: Property 'x' is protected and only accessible within class 'Foo' and its subclasses. + + +==== tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithProtecteds.ts (2 errors) ==== + class Foo { + protected x: string; + } + + interface I extends Foo { // error + ~ +!!! error TS2429: Interface 'I' incorrectly extends interface 'Foo': +!!! error TS2429: Property 'x' is protected but type 'I' is not a class derived from 'Foo'. + x: string; + } + + interface I2 extends Foo { + y: string; + } + + var i: I2; + var r = i.y; + var r2 = i.x; // error + ~~~ +!!! error TS2445: Property 'x' is protected and only accessible within class 'Foo' and its subclasses. \ No newline at end of file diff --git a/tests/baselines/reference/interfaceExtendingClassWithProtecteds.js b/tests/baselines/reference/interfaceExtendingClassWithProtecteds.js new file mode 100644 index 0000000000000..f2d95812fd2a6 --- /dev/null +++ b/tests/baselines/reference/interfaceExtendingClassWithProtecteds.js @@ -0,0 +1,26 @@ +//// [interfaceExtendingClassWithProtecteds.ts] +class Foo { + protected x: string; +} + +interface I extends Foo { // error + x: string; +} + +interface I2 extends Foo { + y: string; +} + +var i: I2; +var r = i.y; +var r2 = i.x; // error + +//// [interfaceExtendingClassWithProtecteds.js] +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +var i; +var r = i.y; +var r2 = i.x; // error diff --git a/tests/baselines/reference/interfaceExtendingClassWithProtecteds2.errors.txt b/tests/baselines/reference/interfaceExtendingClassWithProtecteds2.errors.txt new file mode 100644 index 0000000000000..4e5b636401053 --- /dev/null +++ b/tests/baselines/reference/interfaceExtendingClassWithProtecteds2.errors.txt @@ -0,0 +1,51 @@ +tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithProtecteds2.ts(9,11): error TS2320: Interface 'I3' cannot simultaneously extend types 'Foo' and 'Bar': + Named properties 'x' of types 'Foo' and 'Bar' are not identical. +tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithProtecteds2.ts(12,11): error TS2429: Interface 'I4' incorrectly extends interface 'Bar': + Property 'x' is protected but type 'I4' is not a class derived from 'Bar'. +tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithProtecteds2.ts(12,11): error TS2429: Interface 'I4' incorrectly extends interface 'Foo': + Property 'x' is protected but type 'I4' is not a class derived from 'Foo'. +tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithProtecteds2.ts(26,10): error TS2445: Property 'x' is protected and only accessible within class 'Foo' and its subclasses. +tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithProtecteds2.ts(27,10): error TS2445: Property 'y' is protected and only accessible within class 'Baz' and its subclasses. + + +==== tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithProtecteds2.ts (5 errors) ==== + class Foo { + protected x: string; + } + + class Bar { + protected x: string; + } + + interface I3 extends Foo, Bar { // error + ~~ +!!! error TS2320: Interface 'I3' cannot simultaneously extend types 'Foo' and 'Bar': +!!! error TS2320: Named properties 'x' of types 'Foo' and 'Bar' are not identical. + } + + interface I4 extends Foo, Bar { // error + ~~ +!!! error TS2429: Interface 'I4' incorrectly extends interface 'Bar': +!!! error TS2429: Property 'x' is protected but type 'I4' is not a class derived from 'Bar'. + ~~ +!!! error TS2429: Interface 'I4' incorrectly extends interface 'Foo': +!!! error TS2429: Property 'x' is protected but type 'I4' is not a class derived from 'Foo'. + x: string; + } + + class Baz { + protected y: string; + } + + interface I5 extends Foo, Baz { + z: string; + } + + var i: I5; + var r: string = i.z; + var r2 = i.x; // error + ~~~ +!!! error TS2445: Property 'x' is protected and only accessible within class 'Foo' and its subclasses. + var r3 = i.y; // error + ~~~ +!!! error TS2445: Property 'y' is protected and only accessible within class 'Baz' and its subclasses. \ No newline at end of file diff --git a/tests/baselines/reference/interfaceExtendingClassWithProtecteds2.js b/tests/baselines/reference/interfaceExtendingClassWithProtecteds2.js new file mode 100644 index 0000000000000..277c32a10c154 --- /dev/null +++ b/tests/baselines/reference/interfaceExtendingClassWithProtecteds2.js @@ -0,0 +1,49 @@ +//// [interfaceExtendingClassWithProtecteds2.ts] +class Foo { + protected x: string; +} + +class Bar { + protected x: string; +} + +interface I3 extends Foo, Bar { // error +} + +interface I4 extends Foo, Bar { // error + x: string; +} + +class Baz { + protected y: string; +} + +interface I5 extends Foo, Baz { + z: string; +} + +var i: I5; +var r: string = i.z; +var r2 = i.x; // error +var r3 = i.y; // error + +//// [interfaceExtendingClassWithProtecteds2.js] +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +var Bar = (function () { + function Bar() { + } + return Bar; +})(); +var Baz = (function () { + function Baz() { + } + return Baz; +})(); +var i; +var r = i.z; +var r2 = i.x; // error +var r3 = i.y; // error diff --git a/tests/baselines/reference/interfaceExtendsClassWithPrivate2.errors.txt b/tests/baselines/reference/interfaceExtendsClassWithPrivate2.errors.txt index 71b8b656db47c..a965d7003bb37 100644 --- a/tests/baselines/reference/interfaceExtendsClassWithPrivate2.errors.txt +++ b/tests/baselines/reference/interfaceExtendsClassWithPrivate2.errors.txt @@ -1,11 +1,11 @@ tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts(10,7): error TS2416: Class 'D' incorrectly extends base class 'C': - Private property 'x' cannot be reimplemented. + Types have separate declarations of a private property 'x'. tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts(10,7): error TS2421: Class 'D' incorrectly implements interface 'I': - Private property 'x' cannot be reimplemented. + Types have separate declarations of a private property 'x'. tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts(18,7): error TS2416: Class 'D2' incorrectly extends base class 'C': - Private property 'x' cannot be reimplemented. + Types have separate declarations of a private property 'x'. tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts(18,7): error TS2421: Class 'D2' incorrectly implements interface 'I': - Private property 'x' cannot be reimplemented. + Types have separate declarations of a private property 'x'. ==== tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts (4 errors) ==== @@ -21,10 +21,10 @@ tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts(18,7): error TS2421: C class D extends C implements I { // error ~ !!! error TS2416: Class 'D' incorrectly extends base class 'C': -!!! error TS2416: Private property 'x' cannot be reimplemented. +!!! error TS2416: Types have separate declarations of a private property 'x'. ~ !!! error TS2421: Class 'D' incorrectly implements interface 'I': -!!! error TS2421: Private property 'x' cannot be reimplemented. +!!! error TS2421: Types have separate declarations of a private property 'x'. public foo(x: any) { return x; } private x = 2; private y = 3; @@ -35,10 +35,10 @@ tests/cases/compiler/interfaceExtendsClassWithPrivate2.ts(18,7): error TS2421: C class D2 extends C implements I { // error ~~ !!! error TS2416: Class 'D2' incorrectly extends base class 'C': -!!! error TS2416: Private property 'x' cannot be reimplemented. +!!! error TS2416: Types have separate declarations of a private property 'x'. ~~ !!! error TS2421: Class 'D2' incorrectly implements interface 'I': -!!! error TS2421: Private property 'x' cannot be reimplemented. +!!! error TS2421: Types have separate declarations of a private property 'x'. public foo(x: any) { return x; } private x = ""; other(x: any) { return x; } diff --git a/tests/baselines/reference/interfaceImplementation1.errors.txt b/tests/baselines/reference/interfaceImplementation1.errors.txt index e0a6b311d08f8..59a81e6695734 100644 --- a/tests/baselines/reference/interfaceImplementation1.errors.txt +++ b/tests/baselines/reference/interfaceImplementation1.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/interfaceImplementation1.ts(12,7): error TS2421: Class 'C1' incorrectly implements interface 'I1': - Private property 'iObj' cannot be reimplemented. + Property 'iObj' is private in type 'C1' but not in type 'I1'. tests/cases/compiler/interfaceImplementation1.ts(12,7): error TS2421: Class 'C1' incorrectly implements interface 'I2': - Private property 'iFn' cannot be reimplemented. + Property 'iFn' is private in type 'C1' but not in type 'I2'. tests/cases/compiler/interfaceImplementation1.ts(34,5): error TS2323: Type '() => C2' is not assignable to type 'I4'. @@ -20,10 +20,10 @@ tests/cases/compiler/interfaceImplementation1.ts(34,5): error TS2323: Type '() = class C1 implements I1,I2 { ~~ !!! error TS2421: Class 'C1' incorrectly implements interface 'I1': -!!! error TS2421: Private property 'iObj' cannot be reimplemented. +!!! error TS2421: Property 'iObj' is private in type 'C1' but not in type 'I1'. ~~ !!! error TS2421: Class 'C1' incorrectly implements interface 'I2': -!!! error TS2421: Private property 'iFn' cannot be reimplemented. +!!! error TS2421: Property 'iFn' is private in type 'C1' but not in type 'I2'. private iFn(); private iFn(n?:number, s?:string) { } private iAny:any; diff --git a/tests/baselines/reference/interfaceImplementation6.errors.txt b/tests/baselines/reference/interfaceImplementation6.errors.txt index b076f30a2232a..0965a1c601963 100644 --- a/tests/baselines/reference/interfaceImplementation6.errors.txt +++ b/tests/baselines/reference/interfaceImplementation6.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/interfaceImplementation6.ts(9,7): error TS2421: Class 'C2' incorrectly implements interface 'I1': - Private property 'item' cannot be reimplemented. + Property 'item' is private in type 'C2' but not in type 'I1'. tests/cases/compiler/interfaceImplementation6.ts(13,7): error TS2421: Class 'C3' incorrectly implements interface 'I1': Property 'item' is missing in type 'C3'. @@ -16,7 +16,7 @@ tests/cases/compiler/interfaceImplementation6.ts(13,7): error TS2421: Class 'C3' class C2 implements I1 { ~~ !!! error TS2421: Class 'C2' incorrectly implements interface 'I1': -!!! error TS2421: Private property 'item' cannot be reimplemented. +!!! error TS2421: Property 'item' is private in type 'C2' but not in type 'I1'. private item:number; } diff --git a/tests/baselines/reference/interfaceImplementation8.errors.txt b/tests/baselines/reference/interfaceImplementation8.errors.txt index 1e810caedd73f..4d0d06042a1a5 100644 --- a/tests/baselines/reference/interfaceImplementation8.errors.txt +++ b/tests/baselines/reference/interfaceImplementation8.errors.txt @@ -1,9 +1,9 @@ tests/cases/compiler/interfaceImplementation8.ts(12,7): error TS2421: Class 'C2' incorrectly implements interface 'i1': - Private property 'name' cannot be reimplemented. + Property 'name' is private in type 'C2' but not in type 'i1'. tests/cases/compiler/interfaceImplementation8.ts(21,7): error TS2421: Class 'C5' incorrectly implements interface 'i1': - Private property 'name' cannot be reimplemented. + Property 'name' is private in type 'C5' but not in type 'i1'. tests/cases/compiler/interfaceImplementation8.ts(22,7): error TS2421: Class 'C6' incorrectly implements interface 'i1': - Private property 'name' cannot be reimplemented. + Property 'name' is private in type 'C6' but not in type 'i1'. ==== tests/cases/compiler/interfaceImplementation8.ts (3 errors) ==== @@ -21,7 +21,7 @@ tests/cases/compiler/interfaceImplementation8.ts(22,7): error TS2421: Class 'C6' class C2 implements i1 { ~~ !!! error TS2421: Class 'C2' incorrectly implements interface 'i1': -!!! error TS2421: Private property 'name' cannot be reimplemented. +!!! error TS2421: Property 'name' is private in type 'C2' but not in type 'i1'. private name:string; } @@ -33,11 +33,11 @@ tests/cases/compiler/interfaceImplementation8.ts(22,7): error TS2421: Class 'C6' class C5 extends C2 implements i1{ } ~~ !!! error TS2421: Class 'C5' incorrectly implements interface 'i1': -!!! error TS2421: Private property 'name' cannot be reimplemented. +!!! error TS2421: Property 'name' is private in type 'C5' but not in type 'i1'. class C6 extends C3 implements i1{ } ~~ !!! error TS2421: Class 'C6' incorrectly implements interface 'i1': -!!! error TS2421: Private property 'name' cannot be reimplemented. +!!! error TS2421: Property 'name' is private in type 'C6' but not in type 'i1'. /* 2 diff --git a/tests/baselines/reference/interfaceWithPropertyThatIsPrivateInBaseType.errors.txt b/tests/baselines/reference/interfaceWithPropertyThatIsPrivateInBaseType.errors.txt index 66043dc6f7e29..60c917d0fbc5b 100644 --- a/tests/baselines/reference/interfaceWithPropertyThatIsPrivateInBaseType.errors.txt +++ b/tests/baselines/reference/interfaceWithPropertyThatIsPrivateInBaseType.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithPropertyThatIsPrivateInBaseType.ts(5,11): error TS2429: Interface 'Foo' incorrectly extends interface 'Base': - Private property 'x' cannot be reimplemented. + Property 'x' is private in type 'Base' but not in type 'Foo'. tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithPropertyThatIsPrivateInBaseType.ts(13,11): error TS2429: Interface 'Foo2' incorrectly extends interface 'Base2': - Private property 'x' cannot be reimplemented. + Property 'x' is private in type 'Base2' but not in type 'Foo2'. ==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithPropertyThatIsPrivateInBaseType.ts (2 errors) ==== @@ -12,7 +12,7 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithPropertyTh interface Foo extends Base { // error ~~~ !!! error TS2429: Interface 'Foo' incorrectly extends interface 'Base': -!!! error TS2429: Private property 'x' cannot be reimplemented. +!!! error TS2429: Property 'x' is private in type 'Base' but not in type 'Foo'. x: number; } @@ -23,6 +23,6 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithPropertyTh interface Foo2 extends Base2 { // error ~~~~ !!! error TS2429: Interface 'Foo2' incorrectly extends interface 'Base2': -!!! error TS2429: Private property 'x' cannot be reimplemented. +!!! error TS2429: Property 'x' is private in type 'Base2' but not in type 'Foo2'. x: number; } \ No newline at end of file diff --git a/tests/baselines/reference/interfaceWithPropertyThatIsPrivateInBaseType2.errors.txt b/tests/baselines/reference/interfaceWithPropertyThatIsPrivateInBaseType2.errors.txt index 3f4be2ebac758..4ee4bf8709f51 100644 --- a/tests/baselines/reference/interfaceWithPropertyThatIsPrivateInBaseType2.errors.txt +++ b/tests/baselines/reference/interfaceWithPropertyThatIsPrivateInBaseType2.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithPropertyThatIsPrivateInBaseType2.ts(5,11): error TS2429: Interface 'Foo' incorrectly extends interface 'Base': - Private property 'x' cannot be reimplemented. + Property 'x' is private in type 'Base' but not in type 'Foo'. tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithPropertyThatIsPrivateInBaseType2.ts(13,11): error TS2429: Interface 'Foo2' incorrectly extends interface 'Base2': - Private property 'x' cannot be reimplemented. + Property 'x' is private in type 'Base2' but not in type 'Foo2'. ==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithPropertyThatIsPrivateInBaseType2.ts (2 errors) ==== @@ -12,7 +12,7 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithPropertyTh interface Foo extends Base { // error ~~~ !!! error TS2429: Interface 'Foo' incorrectly extends interface 'Base': -!!! error TS2429: Private property 'x' cannot be reimplemented. +!!! error TS2429: Property 'x' is private in type 'Base' but not in type 'Foo'. x(): any; } @@ -23,6 +23,6 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceWithPropertyTh interface Foo2 extends Base2 { // error ~~~~ !!! error TS2429: Interface 'Foo2' incorrectly extends interface 'Base2': -!!! error TS2429: Private property 'x' cannot be reimplemented. +!!! error TS2429: Property 'x' is private in type 'Base2' but not in type 'Foo2'. x(): any; } \ No newline at end of file diff --git a/tests/baselines/reference/memberFunctionsWithPrivateOverloads.errors.txt b/tests/baselines/reference/memberFunctionsWithPrivateOverloads.errors.txt index 45b1569dbfbe8..d6c3d4a659c93 100644 --- a/tests/baselines/reference/memberFunctionsWithPrivateOverloads.errors.txt +++ b/tests/baselines/reference/memberFunctionsWithPrivateOverloads.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPrivateOverloads.ts(43,9): error TS2341: Property 'C.foo' is inaccessible. -tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPrivateOverloads.ts(46,10): error TS2341: Property 'D.foo' is inaccessible. -tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPrivateOverloads.ts(48,10): error TS2341: Property 'C.foo' is inaccessible. -tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPrivateOverloads.ts(49,10): error TS2341: Property 'D.bar' is inaccessible. +tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPrivateOverloads.ts(43,9): error TS2341: Property 'foo' is private and only accessible within class 'C'. +tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPrivateOverloads.ts(46,10): error TS2341: Property 'foo' is private and only accessible within class 'D'. +tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPrivateOverloads.ts(48,10): error TS2341: Property 'foo' is private and only accessible within class 'C'. +tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPrivateOverloads.ts(49,10): error TS2341: Property 'bar' is private and only accessible within class 'D'. ==== tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPrivateOverloads.ts (4 errors) ==== @@ -49,16 +49,16 @@ tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclara var c: C; var r = c.foo(1); // error ~~~~~ -!!! error TS2341: Property 'C.foo' is inaccessible. +!!! error TS2341: Property 'foo' is private and only accessible within class 'C'. var d: D; var r2 = d.foo(2); // error ~~~~~ -!!! error TS2341: Property 'D.foo' is inaccessible. +!!! error TS2341: Property 'foo' is private and only accessible within class 'D'. var r3 = C.foo(1); // error ~~~~~ -!!! error TS2341: Property 'C.foo' is inaccessible. +!!! error TS2341: Property 'foo' is private and only accessible within class 'C'. var r4 = D.bar(''); // error ~~~~~ -!!! error TS2341: Property 'D.bar' is inaccessible. \ No newline at end of file +!!! error TS2341: Property 'bar' is private and only accessible within class 'D'. \ No newline at end of file diff --git a/tests/baselines/reference/memberFunctionsWithPublicPrivateOverloads.errors.txt b/tests/baselines/reference/memberFunctionsWithPublicPrivateOverloads.errors.txt index 57d92cc96966b..95c12e4db040c 100644 --- a/tests/baselines/reference/memberFunctionsWithPublicPrivateOverloads.errors.txt +++ b/tests/baselines/reference/memberFunctionsWithPublicPrivateOverloads.errors.txt @@ -1,13 +1,13 @@ -tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts(3,12): error TS2385: Overload signatures must all be public or private. -tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts(7,12): error TS2385: Overload signatures must all be public or private. -tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts(12,19): error TS2385: Overload signatures must all be public or private. -tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts(16,19): error TS2385: Overload signatures must all be public or private. -tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts(23,12): error TS2385: Overload signatures must all be public or private. -tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts(27,12): error TS2385: Overload signatures must all be public or private. -tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts(32,19): error TS2385: Overload signatures must all be public or private. -tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts(36,19): error TS2385: Overload signatures must all be public or private. -tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts(42,9): error TS2341: Property 'C.foo' is inaccessible. -tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts(45,10): error TS2341: Property 'D.foo' is inaccessible. +tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts(3,12): error TS2385: Overload signatures must all be public, private or protected. +tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts(7,12): error TS2385: Overload signatures must all be public, private or protected. +tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts(12,19): error TS2385: Overload signatures must all be public, private or protected. +tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts(16,19): error TS2385: Overload signatures must all be public, private or protected. +tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts(23,12): error TS2385: Overload signatures must all be public, private or protected. +tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts(27,12): error TS2385: Overload signatures must all be public, private or protected. +tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts(32,19): error TS2385: Overload signatures must all be public, private or protected. +tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts(36,19): error TS2385: Overload signatures must all be public, private or protected. +tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts(42,9): error TS2341: Property 'foo' is private and only accessible within class 'C'. +tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts(45,10): error TS2341: Property 'foo' is private and only accessible within class 'D'. ==== tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclarations/memberFunctionsWithPublicPrivateOverloads.ts (10 errors) ==== @@ -15,26 +15,26 @@ tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclara private foo(x: number); public foo(x: number, y: string); // error ~~~ -!!! error TS2385: Overload signatures must all be public or private. +!!! error TS2385: Overload signatures must all be public, private or protected. private foo(x: any, y?: any) { } private bar(x: 'hi'); public bar(x: string); // error ~~~ -!!! error TS2385: Overload signatures must all be public or private. +!!! error TS2385: Overload signatures must all be public, private or protected. private bar(x: number, y: string); private bar(x: any, y?: any) { } private static foo(x: number); public static foo(x: number, y: string); // error ~~~ -!!! error TS2385: Overload signatures must all be public or private. +!!! error TS2385: Overload signatures must all be public, private or protected. private static foo(x: any, y?: any) { } private static bar(x: 'hi'); public static bar(x: string); // error ~~~ -!!! error TS2385: Overload signatures must all be public or private. +!!! error TS2385: Overload signatures must all be public, private or protected. private static bar(x: number, y: string); private static bar(x: any, y?: any) { } } @@ -43,26 +43,26 @@ tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclara private foo(x: number); public foo(x: T, y: T); // error ~~~ -!!! error TS2385: Overload signatures must all be public or private. +!!! error TS2385: Overload signatures must all be public, private or protected. private foo(x: any, y?: any) { } private bar(x: 'hi'); public bar(x: string); // error ~~~ -!!! error TS2385: Overload signatures must all be public or private. +!!! error TS2385: Overload signatures must all be public, private or protected. private bar(x: T, y: T); private bar(x: any, y?: any) { } private static foo(x: number); public static foo(x: number, y: string); // error ~~~ -!!! error TS2385: Overload signatures must all be public or private. +!!! error TS2385: Overload signatures must all be public, private or protected. private static foo(x: any, y?: any) { } private static bar(x: 'hi'); public static bar(x: string); // error ~~~ -!!! error TS2385: Overload signatures must all be public or private. +!!! error TS2385: Overload signatures must all be public, private or protected. private static bar(x: number, y: string); private static bar(x: any, y?: any) { } } @@ -70,9 +70,9 @@ tests/cases/conformance/classes/propertyMemberDeclarations/memberFunctionDeclara var c: C; var r = c.foo(1); // error ~~~~~ -!!! error TS2341: Property 'C.foo' is inaccessible. +!!! error TS2341: Property 'foo' is private and only accessible within class 'C'. var d: D; var r2 = d.foo(2); // error ~~~~~ -!!! error TS2341: Property 'D.foo' is inaccessible. \ No newline at end of file +!!! error TS2341: Property 'foo' is private and only accessible within class 'D'. \ No newline at end of file diff --git a/tests/baselines/reference/mergedInterfacesWithInheritedPrivates.errors.txt b/tests/baselines/reference/mergedInterfacesWithInheritedPrivates.errors.txt index 3014b55a8cb43..f1ee1f383bfa3 100644 --- a/tests/baselines/reference/mergedInterfacesWithInheritedPrivates.errors.txt +++ b/tests/baselines/reference/mergedInterfacesWithInheritedPrivates.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithInheritedPrivates.ts(13,7): error TS2421: Class 'D' incorrectly implements interface 'A': - Private property 'x' cannot be reimplemented. + Types have separate declarations of a private property 'x'. tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithInheritedPrivates.ts(19,7): error TS2421: Class 'E' incorrectly implements interface 'A': - Private property 'x' cannot be reimplemented. -tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithInheritedPrivates.ts(26,9): error TS2341: Property 'C.x' is inaccessible. + Property 'x' is private in type 'A' but not in type 'E'. +tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithInheritedPrivates.ts(26,9): error TS2341: Property 'x' is private and only accessible within class 'C'. ==== tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithInheritedPrivates.ts (3 errors) ==== @@ -21,7 +21,7 @@ tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithInheri class D implements A { // error ~ !!! error TS2421: Class 'D' incorrectly implements interface 'A': -!!! error TS2421: Private property 'x' cannot be reimplemented. +!!! error TS2421: Types have separate declarations of a private property 'x'. private x: number; y: string; z: string; @@ -30,7 +30,7 @@ tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithInheri class E implements A { // error ~ !!! error TS2421: Class 'E' incorrectly implements interface 'A': -!!! error TS2421: Private property 'x' cannot be reimplemented. +!!! error TS2421: Property 'x' is private in type 'A' but not in type 'E'. x: number; y: string; z: string; @@ -39,4 +39,4 @@ tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithInheri var a: A; var r = a.x; // error ~~~ -!!! error TS2341: Property 'C.x' is inaccessible. \ No newline at end of file +!!! error TS2341: Property 'x' is private and only accessible within class 'C'. \ No newline at end of file diff --git a/tests/baselines/reference/mergedInterfacesWithInheritedPrivates2.errors.txt b/tests/baselines/reference/mergedInterfacesWithInheritedPrivates2.errors.txt index 64bc61efdf935..0ca3b4c3aa2a6 100644 --- a/tests/baselines/reference/mergedInterfacesWithInheritedPrivates2.errors.txt +++ b/tests/baselines/reference/mergedInterfacesWithInheritedPrivates2.errors.txt @@ -1,11 +1,11 @@ tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithInheritedPrivates2.ts(17,7): error TS2421: Class 'D' incorrectly implements interface 'A': - Private property 'w' cannot be reimplemented. + Types have separate declarations of a private property 'w'. tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithInheritedPrivates2.ts(23,7): error TS2416: Class 'E' incorrectly extends base class 'C2': - Private property 'w' cannot be reimplemented. + Property 'w' is private in type 'C2' but not in type 'E'. tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithInheritedPrivates2.ts(23,7): error TS2421: Class 'E' incorrectly implements interface 'A': Property 'x' is missing in type 'E'. -tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithInheritedPrivates2.ts(30,9): error TS2341: Property 'C.x' is inaccessible. -tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithInheritedPrivates2.ts(31,10): error TS2341: Property 'C2.w' is inaccessible. +tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithInheritedPrivates2.ts(30,9): error TS2341: Property 'x' is private and only accessible within class 'C'. +tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithInheritedPrivates2.ts(31,10): error TS2341: Property 'w' is private and only accessible within class 'C2'. ==== tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithInheritedPrivates2.ts (5 errors) ==== @@ -28,7 +28,7 @@ tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithInheri class D extends C implements A { // error ~ !!! error TS2421: Class 'D' incorrectly implements interface 'A': -!!! error TS2421: Private property 'w' cannot be reimplemented. +!!! error TS2421: Types have separate declarations of a private property 'w'. private w: number; y: string; z: string; @@ -37,7 +37,7 @@ tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithInheri class E extends C2 implements A { // error ~ !!! error TS2416: Class 'E' incorrectly extends base class 'C2': -!!! error TS2416: Private property 'w' cannot be reimplemented. +!!! error TS2416: Property 'w' is private in type 'C2' but not in type 'E'. ~ !!! error TS2421: Class 'E' incorrectly implements interface 'A': !!! error TS2421: Property 'x' is missing in type 'E'. @@ -49,7 +49,7 @@ tests/cases/conformance/interfaces/declarationMerging/mergedInterfacesWithInheri var a: A; var r = a.x; // error ~~~ -!!! error TS2341: Property 'C.x' is inaccessible. +!!! error TS2341: Property 'x' is private and only accessible within class 'C'. var r2 = a.w; // error ~~~ -!!! error TS2341: Property 'C2.w' is inaccessible. \ No newline at end of file +!!! error TS2341: Property 'w' is private and only accessible within class 'C2'. \ No newline at end of file diff --git a/tests/baselines/reference/optionalPropertiesTest.errors.txt b/tests/baselines/reference/optionalPropertiesTest.errors.txt index 3f32baa34078a..74b8dd7a73a61 100644 --- a/tests/baselines/reference/optionalPropertiesTest.errors.txt +++ b/tests/baselines/reference/optionalPropertiesTest.errors.txt @@ -5,7 +5,7 @@ tests/cases/compiler/optionalPropertiesTest.ts(25,5): error TS2322: Type '{}' is tests/cases/compiler/optionalPropertiesTest.ts(26,5): error TS2322: Type '{}' is not assignable to type 'i3': Property 'M' is missing in type '{}'. tests/cases/compiler/optionalPropertiesTest.ts(40,1): error TS2322: Type 'i2' is not assignable to type 'i1': - Required property 'M' cannot be reimplemented with optional property in 'i2'. + Property 'M' is optional in type 'i2' but required in type 'i1'. ==== tests/cases/compiler/optionalPropertiesTest.ts (4 errors) ==== @@ -60,4 +60,4 @@ tests/cases/compiler/optionalPropertiesTest.ts(40,1): error TS2322: Type 'i2' is test10_1 = test10_2; ~~~~~~~~ !!! error TS2322: Type 'i2' is not assignable to type 'i1': -!!! error TS2322: Required property 'M' cannot be reimplemented with optional property in 'i2'. \ No newline at end of file +!!! error TS2322: Property 'M' is optional in type 'i2' but required in type 'i1'. \ No newline at end of file diff --git a/tests/baselines/reference/overloadModifiersMustAgree.errors.txt b/tests/baselines/reference/overloadModifiersMustAgree.errors.txt index 0bfd9b4d2bd62..0efdbcdd1f604 100644 --- a/tests/baselines/reference/overloadModifiersMustAgree.errors.txt +++ b/tests/baselines/reference/overloadModifiersMustAgree.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/overloadModifiersMustAgree.ts(2,12): error TS2385: Overload signatures must all be public or private. +tests/cases/compiler/overloadModifiersMustAgree.ts(2,12): error TS2385: Overload signatures must all be public, private or protected. tests/cases/compiler/overloadModifiersMustAgree.ts(6,18): error TS2384: Overload signatures must all be ambient or non-ambient. tests/cases/compiler/overloadModifiersMustAgree.ts(7,17): error TS2383: Overload signatures must all be exported or not exported. tests/cases/compiler/overloadModifiersMustAgree.ts(12,5): error TS2386: Overload signatures must all be optional or required. @@ -8,7 +8,7 @@ tests/cases/compiler/overloadModifiersMustAgree.ts(12,5): error TS2386: Overload class baz { public foo(); ~~~ -!!! error TS2385: Overload signatures must all be public or private. +!!! error TS2385: Overload signatures must all be public, private or protected. private foo(bar?: any) { } // error - access modifiers do not agree } diff --git a/tests/baselines/reference/overridingPrivateStaticMembers.errors.txt b/tests/baselines/reference/overridingPrivateStaticMembers.errors.txt index 87fddf0ac86ce..6d51014f0051f 100644 --- a/tests/baselines/reference/overridingPrivateStaticMembers.errors.txt +++ b/tests/baselines/reference/overridingPrivateStaticMembers.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/overridingPrivateStaticMembers.ts(5,7): error TS2418: Class static side 'typeof Derived2' incorrectly extends base class static side 'typeof Base2': - Private property 'y' cannot be reimplemented. + Types have separate declarations of a private property 'y'. ==== tests/cases/compiler/overridingPrivateStaticMembers.ts (1 errors) ==== @@ -10,6 +10,6 @@ tests/cases/compiler/overridingPrivateStaticMembers.ts(5,7): error TS2418: Class class Derived2 extends Base2 { ~~~~~~~~ !!! error TS2418: Class static side 'typeof Derived2' incorrectly extends base class static side 'typeof Base2': -!!! error TS2418: Private property 'y' cannot be reimplemented. +!!! error TS2418: Types have separate declarations of a private property 'y'. private static y: { foo: string; bar: string; }; } \ No newline at end of file diff --git a/tests/baselines/reference/parserAstSpans1.errors.txt b/tests/baselines/reference/parserAstSpans1.errors.txt index 71bc20603980e..e4360dafa5317 100644 --- a/tests/baselines/reference/parserAstSpans1.errors.txt +++ b/tests/baselines/reference/parserAstSpans1.errors.txt @@ -4,8 +4,8 @@ tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(94,16): error TS10 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(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(111,25): error TS2340: Only public methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2340: Only public 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(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 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 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/privateAccessInSubclass1.errors.txt b/tests/baselines/reference/privateAccessInSubclass1.errors.txt index 471c938b644ef..5ffb876a72805 100644 --- a/tests/baselines/reference/privateAccessInSubclass1.errors.txt +++ b/tests/baselines/reference/privateAccessInSubclass1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/privateAccessInSubclass1.ts(7,5): error TS2341: Property 'Base.options' is inaccessible. +tests/cases/compiler/privateAccessInSubclass1.ts(7,5): error TS2341: Property 'options' is private and only accessible within class 'Base'. ==== tests/cases/compiler/privateAccessInSubclass1.ts (1 errors) ==== @@ -10,6 +10,6 @@ tests/cases/compiler/privateAccessInSubclass1.ts(7,5): error TS2341: Property 'B myMethod() { this.options; ~~~~~~~~~~~~ -!!! error TS2341: Property 'Base.options' is inaccessible. +!!! error TS2341: Property 'options' is private and only accessible within class 'Base'. } } \ No newline at end of file diff --git a/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt b/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt index d9b08e82713cf..1c173ff0fb18d 100644 --- a/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt +++ b/tests/baselines/reference/privateInstanceMemberAccessibility.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(10,15): error TS1003: Identifier expected. tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(12,8): error TS1110: Type expected. -tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(6,15): error TS2340: Only public 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 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 methods of the base class are accessible via the 'super' keyword -tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts(12,8): error TS2341: Property 'Base.foo' is inaccessible. +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,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 TS2341: Property 'foo' is private and only accessible within class 'Base'. ==== tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAccessibility.ts (6 errors) ==== @@ -14,21 +14,21 @@ tests/cases/conformance/classes/members/accessibility/privateInstanceMemberAcces class Derived extends Base { x = super.foo; // error ~~~ -!!! error TS2340: Only public 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 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 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 ~~~~ !!! error TS1110: Type expected. ~~~~~~~~ -!!! error TS2341: Property 'Base.foo' is inaccessible. +!!! error TS2341: Property 'foo' is private and only accessible within class 'Base'. } \ No newline at end of file diff --git a/tests/baselines/reference/privateInterfaceProperties.errors.txt b/tests/baselines/reference/privateInterfaceProperties.errors.txt index fcd3cc87f15a3..faff968379fb4 100644 --- a/tests/baselines/reference/privateInterfaceProperties.errors.txt +++ b/tests/baselines/reference/privateInterfaceProperties.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/privateInterfaceProperties.ts(4,7): error TS2421: Class 'c1' incorrectly implements interface 'i1': - Private property 'name' cannot be reimplemented. + Property 'name' is private in type 'c1' but not in type 'i1'. ==== tests/cases/compiler/privateInterfaceProperties.ts (1 errors) ==== @@ -9,7 +9,7 @@ tests/cases/compiler/privateInterfaceProperties.ts(4,7): error TS2421: Class 'c1 class c1 implements i1 { private name:string; } ~~ !!! error TS2421: Class 'c1' incorrectly implements interface 'i1': -!!! error TS2421: Private property 'name' cannot be reimplemented. +!!! error TS2421: Property 'name' is private in type 'c1' but not in type 'i1'. // should be ok class c2 implements i1 { public name:string; } diff --git a/tests/baselines/reference/privateStaticMemberAccessibility.errors.txt b/tests/baselines/reference/privateStaticMemberAccessibility.errors.txt index a2c2d9971bd34..4ec16f020454c 100644 --- a/tests/baselines/reference/privateStaticMemberAccessibility.errors.txt +++ b/tests/baselines/reference/privateStaticMemberAccessibility.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/classes/members/accessibility/privateStaticMemberAccessibility.ts(6,18): error TS2341: Property 'Base.foo' is inaccessible. -tests/cases/conformance/classes/members/accessibility/privateStaticMemberAccessibility.ts(7,18): error TS2341: Property 'Base.foo' is inaccessible. +tests/cases/conformance/classes/members/accessibility/privateStaticMemberAccessibility.ts(6,18): error TS2341: Property 'foo' is private and only accessible within class 'Base'. +tests/cases/conformance/classes/members/accessibility/privateStaticMemberAccessibility.ts(7,18): error TS2341: Property 'foo' is private and only accessible within class 'Base'. ==== tests/cases/conformance/classes/members/accessibility/privateStaticMemberAccessibility.ts (2 errors) ==== @@ -10,8 +10,8 @@ tests/cases/conformance/classes/members/accessibility/privateStaticMemberAccessi class Derived extends Base { static bar = Base.foo; // error ~~~~~~~~ -!!! error TS2341: Property 'Base.foo' is inaccessible. +!!! error TS2341: Property 'foo' is private and only accessible within class 'Base'. bing = () => Base.foo; // error ~~~~~~~~ -!!! error TS2341: Property 'Base.foo' is inaccessible. +!!! error TS2341: Property 'foo' is private and only accessible within class 'Base'. } \ No newline at end of file diff --git a/tests/baselines/reference/privateStaticNotAccessibleInClodule.errors.txt b/tests/baselines/reference/privateStaticNotAccessibleInClodule.errors.txt index 48da525b55a71..a5834b6cd0fd7 100644 --- a/tests/baselines/reference/privateStaticNotAccessibleInClodule.errors.txt +++ b/tests/baselines/reference/privateStaticNotAccessibleInClodule.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/members/accessibility/privateStaticNotAccessibleInClodule.ts(9,20): error TS2341: Property 'C.bar' is inaccessible. +tests/cases/conformance/classes/members/accessibility/privateStaticNotAccessibleInClodule.ts(9,20): error TS2341: Property 'bar' is private and only accessible within class 'C'. ==== tests/cases/conformance/classes/members/accessibility/privateStaticNotAccessibleInClodule.ts (1 errors) ==== @@ -12,5 +12,5 @@ tests/cases/conformance/classes/members/accessibility/privateStaticNotAccessible module C { export var y = C.bar; // error ~~~~~ -!!! error TS2341: Property 'C.bar' is inaccessible. +!!! error TS2341: Property 'bar' is private and only accessible within class 'C'. } \ No newline at end of file diff --git a/tests/baselines/reference/privateStaticNotAccessibleInClodule2.errors.txt b/tests/baselines/reference/privateStaticNotAccessibleInClodule2.errors.txt index 3c58189147864..950649ee4b224 100644 --- a/tests/baselines/reference/privateStaticNotAccessibleInClodule2.errors.txt +++ b/tests/baselines/reference/privateStaticNotAccessibleInClodule2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/members/accessibility/privateStaticNotAccessibleInClodule2.ts(13,20): error TS2341: Property 'C.bar' is inaccessible. +tests/cases/conformance/classes/members/accessibility/privateStaticNotAccessibleInClodule2.ts(13,20): error TS2341: Property 'bar' is private and only accessible within class 'C'. ==== tests/cases/conformance/classes/members/accessibility/privateStaticNotAccessibleInClodule2.ts (1 errors) ==== @@ -16,5 +16,5 @@ tests/cases/conformance/classes/members/accessibility/privateStaticNotAccessible module D { export var y = D.bar; // error ~~~~~ -!!! error TS2341: Property 'C.bar' is inaccessible. +!!! error TS2341: Property 'bar' is private and only accessible within class 'C'. } \ No newline at end of file diff --git a/tests/baselines/reference/privateVisibility.errors.txt b/tests/baselines/reference/privateVisibility.errors.txt index 9c2283383581a..88784706f4381 100644 --- a/tests/baselines/reference/privateVisibility.errors.txt +++ b/tests/baselines/reference/privateVisibility.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/privateVisibility.ts(9,1): error TS2341: Property 'Foo.privMeth' is inaccessible. -tests/cases/compiler/privateVisibility.ts(10,1): error TS2341: Property 'Foo.privProp' is inaccessible. -tests/cases/compiler/privateVisibility.ts(24,1): error TS2341: Property 'M.C.priv' is inaccessible. +tests/cases/compiler/privateVisibility.ts(9,1): error TS2341: Property 'privMeth' is private and only accessible within class 'Foo'. +tests/cases/compiler/privateVisibility.ts(10,1): error TS2341: Property 'privProp' is private and only accessible within class 'Foo'. +tests/cases/compiler/privateVisibility.ts(24,1): error TS2341: Property 'priv' is private and only accessible within class 'C'. ==== tests/cases/compiler/privateVisibility.ts (3 errors) ==== @@ -14,10 +14,10 @@ tests/cases/compiler/privateVisibility.ts(24,1): error TS2341: Property 'M.C.pri var f = new Foo(); f.privMeth(); // should not work ~~~~~~~~~~ -!!! error TS2341: Property 'Foo.privMeth' is inaccessible. +!!! error TS2341: Property 'privMeth' is private and only accessible within class 'Foo'. f.privProp; // should not work ~~~~~~~~~~ -!!! error TS2341: Property 'Foo.privProp' is inaccessible. +!!! error TS2341: Property 'privProp' is private and only accessible within class 'Foo'. f.pubMeth(); // should work f.pubProp; // should work @@ -33,6 +33,6 @@ tests/cases/compiler/privateVisibility.ts(24,1): error TS2341: Property 'M.C.pri c.pub; // should work c.priv; // should not work ~~~~~~ -!!! error TS2341: Property 'M.C.priv' is inaccessible. +!!! error TS2341: Property 'priv' is private and only accessible within class 'C'. \ No newline at end of file diff --git a/tests/baselines/reference/propertyAccessibility1.errors.txt b/tests/baselines/reference/propertyAccessibility1.errors.txt index a26dd0d93718c..2caf251b2a590 100644 --- a/tests/baselines/reference/propertyAccessibility1.errors.txt +++ b/tests/baselines/reference/propertyAccessibility1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/propertyAccessibility1.ts(5,1): error TS2341: Property 'Foo.privProp' is inaccessible. +tests/cases/compiler/propertyAccessibility1.ts(5,1): error TS2341: Property 'privProp' is private and only accessible within class 'Foo'. ==== tests/cases/compiler/propertyAccessibility1.ts (1 errors) ==== @@ -8,5 +8,5 @@ tests/cases/compiler/propertyAccessibility1.ts(5,1): error TS2341: Property 'Foo var f = new Foo(); f.privProp; ~~~~~~~~~~ -!!! error TS2341: Property 'Foo.privProp' is inaccessible. +!!! error TS2341: Property 'privProp' is private and only accessible within class 'Foo'. \ No newline at end of file diff --git a/tests/baselines/reference/propertyAccessibility2.errors.txt b/tests/baselines/reference/propertyAccessibility2.errors.txt index fba83b50a8b5c..7eb81d45ed44a 100644 --- a/tests/baselines/reference/propertyAccessibility2.errors.txt +++ b/tests/baselines/reference/propertyAccessibility2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/propertyAccessibility2.ts(4,9): error TS2341: Property 'C.x' is inaccessible. +tests/cases/compiler/propertyAccessibility2.ts(4,9): error TS2341: Property 'x' is private and only accessible within class 'C'. ==== tests/cases/compiler/propertyAccessibility2.ts (1 errors) ==== @@ -7,5 +7,5 @@ tests/cases/compiler/propertyAccessibility2.ts(4,9): error TS2341: Property 'C.x } var c = C.x; ~~~ -!!! error TS2341: Property 'C.x' is inaccessible. +!!! error TS2341: Property 'x' is private and only accessible within class 'C'. \ No newline at end of file diff --git a/tests/baselines/reference/propertyParameterWithQuestionMark.errors.txt b/tests/baselines/reference/propertyParameterWithQuestionMark.errors.txt index 31472877d055d..e68922ccf3638 100644 --- a/tests/baselines/reference/propertyParameterWithQuestionMark.errors.txt +++ b/tests/baselines/reference/propertyParameterWithQuestionMark.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/propertyParameterWithQuestionMark.ts(6,5): error TS2322: Type '{}' is not assignable to type 'C': Property 'x' is missing in type '{}'. tests/cases/compiler/propertyParameterWithQuestionMark.ts(8,1): error TS2322: Type '{ x?: any; }' is not assignable to type 'C': - Required property 'x' cannot be reimplemented with optional property in '{ x?: any; }'. + Property 'x' is optional in type '{ x?: any; }' but required in type 'C'. ==== tests/cases/compiler/propertyParameterWithQuestionMark.ts (2 errors) ==== @@ -18,5 +18,5 @@ tests/cases/compiler/propertyParameterWithQuestionMark.ts(8,1): error TS2322: Ty v = v2; // Should fail ~ !!! error TS2322: Type '{ x?: any; }' is not assignable to type 'C': -!!! error TS2322: Required property 'x' cannot be reimplemented with optional property in '{ x?: any; }'. +!!! error TS2322: Property 'x' is optional in type '{ x?: any; }' but required in type 'C'. var v3: { x } = new C; // Should succeed \ No newline at end of file diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinClass.js b/tests/baselines/reference/protectedClassPropertyAccessibleWithinClass.js new file mode 100644 index 0000000000000..992011ee4af75 --- /dev/null +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinClass.js @@ -0,0 +1,117 @@ +//// [protectedClassPropertyAccessibleWithinClass.ts] +// no errors + +class C { + protected x: string; + protected get y() { return this.x; } + protected set y(x) { this.y = this.x; } + protected foo() { return this.foo; } + + protected static x: string; + protected static get y() { return this.x; } + protected static set y(x) { this.y = this.x; } + protected static foo() { return this.foo; } + protected static bar() { this.foo(); } +} + +// added level of function nesting +class C2 { + protected x: string; + protected get y() { () => this.x; return null; } + protected set y(x) { () => { this.y = this.x; } } + protected foo() { () => this.foo; } + + protected static x: string; + protected static get y() { () => this.x; return null; } + protected static set y(x) { + () => { this.y = this.x; } + } + protected static foo() { () => this.foo; } + protected static bar() { () => this.foo(); } +} + + +//// [protectedClassPropertyAccessibleWithinClass.js] +// no errors +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "y", { + get: function () { + return this.x; + }, + set: function (x) { + this.y = this.x; + }, + enumerable: true, + configurable: true + }); + C.prototype.foo = function () { + return this.foo; + }; + Object.defineProperty(C, "y", { + get: function () { + return this.x; + }, + set: function (x) { + this.y = this.x; + }, + enumerable: true, + configurable: true + }); + C.foo = function () { + return this.foo; + }; + C.bar = function () { + this.foo(); + }; + return C; +})(); +// added level of function nesting +var C2 = (function () { + function C2() { + } + Object.defineProperty(C2.prototype, "y", { + get: function () { + var _this = this; + (function () { return _this.x; }); + return null; + }, + set: function (x) { + var _this = this; + (function () { + _this.y = _this.x; + }); + }, + enumerable: true, + configurable: true + }); + C2.prototype.foo = function () { + var _this = this; + (function () { return _this.foo; }); + }; + Object.defineProperty(C2, "y", { + get: function () { + var _this = this; + (function () { return _this.x; }); + return null; + }, + set: function (x) { + var _this = this; + (function () { + _this.y = _this.x; + }); + }, + enumerable: true, + configurable: true + }); + C2.foo = function () { + var _this = this; + (function () { return _this.foo; }); + }; + C2.bar = function () { + var _this = this; + (function () { return _this.foo(); }); + }; + return C2; +})(); diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinClass.types b/tests/baselines/reference/protectedClassPropertyAccessibleWithinClass.types new file mode 100644 index 0000000000000..241b3cfc7a161 --- /dev/null +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinClass.types @@ -0,0 +1,139 @@ +=== tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinClass.ts === +// no errors + +class C { +>C : C + + protected x: string; +>x : string + + protected get y() { return this.x; } +>y : string +>this.x : string +>this : C +>x : string + + protected set y(x) { this.y = this.x; } +>y : string +>x : string +>this.y = this.x : string +>this.y : string +>this : C +>y : string +>this.x : string +>this : C +>x : string + + protected foo() { return this.foo; } +>foo : () => any +>this.foo : () => any +>this : C +>foo : () => any + + protected static x: string; +>x : string + + protected static get y() { return this.x; } +>y : string +>this.x : string +>this : typeof C +>x : string + + protected static set y(x) { this.y = this.x; } +>y : string +>x : string +>this.y = this.x : string +>this.y : string +>this : typeof C +>y : string +>this.x : string +>this : typeof C +>x : string + + protected static foo() { return this.foo; } +>foo : () => typeof C.foo +>this.foo : () => typeof C.foo +>this : typeof C +>foo : () => typeof C.foo + + protected static bar() { this.foo(); } +>bar : () => void +>this.foo() : () => typeof C.foo +>this.foo : () => typeof C.foo +>this : typeof C +>foo : () => typeof C.foo +} + +// added level of function nesting +class C2 { +>C2 : C2 + + protected x: string; +>x : string + + protected get y() { () => this.x; return null; } +>y : any +>() => this.x : () => string +>this.x : string +>this : C2 +>x : string + + protected set y(x) { () => { this.y = this.x; } } +>y : any +>x : any +>() => { this.y = this.x; } : () => void +>this.y = this.x : string +>this.y : any +>this : C2 +>y : any +>this.x : string +>this : C2 +>x : string + + protected foo() { () => this.foo; } +>foo : () => void +>() => this.foo : () => () => void +>this.foo : () => void +>this : C2 +>foo : () => void + + protected static x: string; +>x : string + + protected static get y() { () => this.x; return null; } +>y : any +>() => this.x : () => string +>this.x : string +>this : typeof C2 +>x : string + + protected static set y(x) { +>y : any +>x : any + + () => { this.y = this.x; } +>() => { this.y = this.x; } : () => void +>this.y = this.x : string +>this.y : any +>this : typeof C2 +>y : any +>this.x : string +>this : typeof C2 +>x : string + } + protected static foo() { () => this.foo; } +>foo : () => void +>() => this.foo : () => () => void +>this.foo : () => void +>this : typeof C2 +>foo : () => void + + protected static bar() { () => this.foo(); } +>bar : () => void +>() => this.foo() : () => void +>this.foo() : void +>this.foo : () => void +>this : typeof C2 +>foo : () => void +} + diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.js b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.js new file mode 100644 index 0000000000000..381d10f43ea9c --- /dev/null +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.js @@ -0,0 +1,73 @@ +//// [protectedClassPropertyAccessibleWithinSubclass.ts] +// no errors + +class B { + protected x: string; + protected static x: string; +} + +class C extends B { + protected get y() { return this.x; } + protected set y(x) { this.y = this.x; } + protected foo() { return this.x; } + protected bar() { return this.foo(); } + + protected static get y() { return this.x; } + protected static set y(x) { this.y = this.x; } + protected static foo() { return this.x; } + protected static bar() { this.foo(); } +} + + +//// [protectedClassPropertyAccessibleWithinSubclass.js] +// no errors +var __extends = this.__extends || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var B = (function () { + function B() { + } + return B; +})(); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + Object.defineProperty(C.prototype, "y", { + get: function () { + return this.x; + }, + set: function (x) { + this.y = this.x; + }, + enumerable: true, + configurable: true + }); + C.prototype.foo = function () { + return this.x; + }; + C.prototype.bar = function () { + return this.foo(); + }; + Object.defineProperty(C, "y", { + get: function () { + return this.x; + }, + set: function (x) { + this.y = this.x; + }, + enumerable: true, + configurable: true + }); + C.foo = function () { + return this.x; + }; + C.bar = function () { + this.foo(); + }; + return C; +})(B); diff --git a/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.types b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.types new file mode 100644 index 0000000000000..bd230239d47b9 --- /dev/null +++ b/tests/baselines/reference/protectedClassPropertyAccessibleWithinSubclass.types @@ -0,0 +1,78 @@ +=== tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass.ts === +// no errors + +class B { +>B : B + + protected x: string; +>x : string + + protected static x: string; +>x : string +} + +class C extends B { +>C : C +>B : B + + protected get y() { return this.x; } +>y : string +>this.x : string +>this : C +>x : string + + protected set y(x) { this.y = this.x; } +>y : string +>x : string +>this.y = this.x : string +>this.y : string +>this : C +>y : string +>this.x : string +>this : C +>x : string + + protected foo() { return this.x; } +>foo : () => string +>this.x : string +>this : C +>x : string + + protected bar() { return this.foo(); } +>bar : () => string +>this.foo() : string +>this.foo : () => string +>this : C +>foo : () => string + + protected static get y() { return this.x; } +>y : string +>this.x : string +>this : typeof C +>x : string + + protected static set y(x) { this.y = this.x; } +>y : string +>x : string +>this.y = this.x : string +>this.y : string +>this : typeof C +>y : string +>this.x : string +>this : typeof C +>x : string + + protected static foo() { return this.x; } +>foo : () => string +>this.x : string +>this : typeof C +>x : string + + protected static bar() { this.foo(); } +>bar : () => void +>this.foo() : string +>this.foo : () => string +>this : typeof C +>foo : () => string +} + diff --git a/tests/baselines/reference/protectedInstanceMemberAccessibility.errors.txt b/tests/baselines/reference/protectedInstanceMemberAccessibility.errors.txt new file mode 100644 index 0000000000000..03671925febc1 --- /dev/null +++ b/tests/baselines/reference/protectedInstanceMemberAccessibility.errors.txt @@ -0,0 +1,86 @@ +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(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'. +tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(23,18): error TS2446: Property 'f' is protected and only accessible through an instance of class 'B'. +tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(24,20): error TS2339: Property 'y' does not exist on type 'A'. +tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(25,20): error TS2339: Property 'z' does not exist on type 'A'. +tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(31,20): error TS2339: Property 'z' does not exist on type 'B'. +tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(34,18): error TS2446: Property 'x' is protected and only accessible through an instance of class 'B'. +tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(35,18): error TS2446: Property 'f' is protected and only accessible through an instance of class 'B'. +tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(36,20): error TS2339: Property 'y' does not exist on type 'C'. +tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts(37,18): error TS2445: Property 'z' is protected and only accessible within class 'C' and its subclasses. + + +==== tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts (13 errors) ==== + class A { + protected x: string; + protected f(): string { + return "hello"; + } + } + + class B extends A { + protected y: string; + g() { + var t1 = this.x; + var t2 = this.f(); + var t3 = this.y; + var t4 = this.z; // error + ~ +!!! error TS2339: Property 'z' does not exist on type 'B'. + + var s1 = super.x; // error + ~ +!!! 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 + ~ +!!! error TS2339: Property 'y' does not exist on type 'A'. + var s4 = super.z; // error + ~ +!!! error TS2339: Property 'z' does not exist on type 'A'. + + var a: A; + var a1 = a.x; // error + ~~~ +!!! error TS2446: Property 'x' is protected and only accessible through an instance of class 'B'. + var a2 = a.f(); // error + ~~~ +!!! error TS2446: Property 'f' is protected and only accessible through an instance of class 'B'. + var a3 = a.y; // error + ~ +!!! error TS2339: Property 'y' does not exist on type 'A'. + var a4 = a.z; // error + ~ +!!! error TS2339: Property 'z' does not exist on type 'A'. + + var b: B; + var b1 = b.x; + var b2 = b.f(); + var b3 = b.y; + var b4 = b.z; // error + ~ +!!! error TS2339: Property 'z' does not exist on type 'B'. + + var c: C; + var c1 = c.x; // error + ~~~ +!!! error TS2446: Property 'x' is protected and only accessible through an instance of class 'B'. + var c2 = c.f(); // error + ~~~ +!!! error TS2446: Property 'f' is protected and only accessible through an instance of class 'B'. + var c3 = c.y; // error + ~ +!!! error TS2339: Property 'y' does not exist on type 'C'. + var c4 = c.z; // error + ~~~ +!!! error TS2445: Property 'z' is protected and only accessible within class 'C' and its subclasses. + } + } + + class C extends A { + protected z: string; + } + \ No newline at end of file diff --git a/tests/baselines/reference/protectedInstanceMemberAccessibility.js b/tests/baselines/reference/protectedInstanceMemberAccessibility.js new file mode 100644 index 0000000000000..de7a6e0d00e7f --- /dev/null +++ b/tests/baselines/reference/protectedInstanceMemberAccessibility.js @@ -0,0 +1,100 @@ +//// [protectedInstanceMemberAccessibility.ts] +class A { + protected x: string; + protected f(): string { + return "hello"; + } +} + +class B extends A { + protected y: string; + g() { + var t1 = this.x; + var t2 = this.f(); + var t3 = this.y; + var t4 = this.z; // error + + var s1 = super.x; // error + var s2 = super.f(); + var s3 = super.y; // error + var s4 = super.z; // error + + var a: A; + var a1 = a.x; // error + var a2 = a.f(); // error + var a3 = a.y; // error + var a4 = a.z; // error + + var b: B; + var b1 = b.x; + var b2 = b.f(); + var b3 = b.y; + var b4 = b.z; // error + + var c: C; + var c1 = c.x; // error + var c2 = c.f(); // error + var c3 = c.y; // error + var c4 = c.z; // error + } +} + +class C extends A { + protected z: string; +} + + +//// [protectedInstanceMemberAccessibility.js] +var __extends = this.__extends || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + __.prototype = b.prototype; + d.prototype = new __(); +}; +var A = (function () { + function A() { + } + A.prototype.f = function () { + return "hello"; + }; + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + B.prototype.g = function () { + var t1 = this.x; + var t2 = this.f(); + var t3 = this.y; + var t4 = this.z; // error + var s1 = _super.prototype.x; // error + var s2 = _super.prototype.f.call(this); + var s3 = _super.prototype.y; // error + var s4 = _super.prototype.z; // error + var a; + var a1 = a.x; // error + var a2 = a.f(); // error + var a3 = a.y; // error + var a4 = a.z; // error + var b; + var b1 = b.x; + var b2 = b.f(); + var b3 = b.y; + var b4 = b.z; // error + var c; + var c1 = c.x; // error + var c2 = c.f(); // error + var c3 = c.y; // error + var c4 = c.z; // error + }; + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); diff --git a/tests/baselines/reference/protectedMembers.errors.txt b/tests/baselines/reference/protectedMembers.errors.txt new file mode 100644 index 0000000000000..ce9529a7f6726 --- /dev/null +++ b/tests/baselines/reference/protectedMembers.errors.txt @@ -0,0 +1,167 @@ +tests/cases/compiler/protectedMembers.ts(86,5): error TS1089: 'protected' modifier cannot appear on a constructor declaration. +tests/cases/compiler/protectedMembers.ts(40,1): error TS2445: Property 'x' is protected and only accessible within class 'C1' and its subclasses. +tests/cases/compiler/protectedMembers.ts(41,1): error TS2445: Property 'f' is protected and only accessible within class 'C1' and its subclasses. +tests/cases/compiler/protectedMembers.ts(42,1): error TS2445: Property 'sx' is protected and only accessible within class 'C1' and its subclasses. +tests/cases/compiler/protectedMembers.ts(43,1): error TS2445: Property 'sf' is protected and only accessible within class 'C1' and its subclasses. +tests/cases/compiler/protectedMembers.ts(46,1): error TS2445: Property 'x' is protected and only accessible within class 'C1' and its subclasses. +tests/cases/compiler/protectedMembers.ts(47,1): error TS2445: Property 'f' is protected and only accessible within class 'C2' and its subclasses. +tests/cases/compiler/protectedMembers.ts(48,1): error TS2445: Property 'sx' is protected and only accessible within class 'C1' and its subclasses. +tests/cases/compiler/protectedMembers.ts(49,1): error TS2445: Property 'sf' is protected and only accessible within class 'C2' and its subclasses. +tests/cases/compiler/protectedMembers.ts(68,9): error TS2446: Property 'x' is protected and only accessible through an instance of class 'C'. +tests/cases/compiler/protectedMembers.ts(69,9): error TS2446: Property 'x' is protected and only accessible through an instance of class 'C'. +tests/cases/compiler/protectedMembers.ts(98,1): error TS2322: Type 'B1' is not assignable to type 'A1': + Property 'x' is protected but type 'B1' is not a class derived from 'A1'. +tests/cases/compiler/protectedMembers.ts(99,1): error TS2322: Type 'A1' is not assignable to type 'B1': + Property 'x' is protected in type 'A1' but public in type 'B1'. +tests/cases/compiler/protectedMembers.ts(112,7): error TS2416: Class 'B3' incorrectly extends base class 'A3': + Property 'x' is protected in type 'B3' but public in type 'A3'. + + +==== tests/cases/compiler/protectedMembers.ts (14 errors) ==== + // Class with protected members + class C1 { + protected x: number; + protected static sx: number; + protected f() { + return this.x; + } + protected static sf() { + return this.sx; + } + } + + // Derived class accessing protected members + class C2 extends C1 { + protected f() { + return super.f() + this.x; + } + protected static sf() { + return super.sf() + this.sx; + } + } + + // Derived class making protected members public + class C3 extends C2 { + x: number; + static sx: number; + f() { + return super.f(); + } + static sf() { + return super.sf(); + } + } + + var c1: C1; + var c2: C2; + var c3: C3; + + // All of these should be errors + c1.x; + ~~~~ +!!! error TS2445: Property 'x' is protected and only accessible within class 'C1' and its subclasses. + c1.f(); + ~~~~ +!!! error TS2445: Property 'f' is protected and only accessible within class 'C1' and its subclasses. + C1.sx; + ~~~~~ +!!! error TS2445: Property 'sx' is protected and only accessible within class 'C1' and its subclasses. + C1.sf(); + ~~~~~ +!!! error TS2445: Property 'sf' is protected and only accessible within class 'C1' and its subclasses. + + // All of these should be errors + c2.x; + ~~~~ +!!! error TS2445: Property 'x' is protected and only accessible within class 'C1' and its subclasses. + c2.f(); + ~~~~ +!!! error TS2445: Property 'f' is protected and only accessible within class 'C2' and its subclasses. + C2.sx; + ~~~~~ +!!! error TS2445: Property 'sx' is protected and only accessible within class 'C1' and its subclasses. + C2.sf(); + ~~~~~ +!!! error TS2445: Property 'sf' is protected and only accessible within class 'C2' and its subclasses. + + // All of these should be ok + c3.x; + c3.f(); + C3.sx; + C3.sf(); + + class A { + protected x; + } + + class B extends A { + y; + } + + class C extends A { + z; + static foo(a: A, b: B, c: C, d: D, e: E) { + a.x = 1; // Error, access must be through C or type derived from C + ~~~ +!!! error TS2446: Property 'x' is protected and only accessible through an instance of class 'C'. + b.x = 1; // Error, access must be through C or type derived from C + ~~~ +!!! error TS2446: Property 'x' is protected and only accessible through an instance of class 'C'. + c.x = 1; + d.x = 1; + e.x = 1; + } + } + + class D extends C { + d; + } + + interface E extends C { + e; + } + + class CC { + // Error, constructor cannot be protected + protected constructor() { + ~~~~~~~~~ +!!! error TS1089: 'protected' modifier cannot appear on a constructor declaration. + } + } + + class A1 { + protected x; + } + class B1 { + x; + } + var a1: A1; + var b1: B1; + a1 = b1; // Error, B1 doesn't derive from A1 + ~~ +!!! error TS2322: Type 'B1' is not assignable to type 'A1': +!!! error TS2322: Property 'x' is protected but type 'B1' is not a class derived from 'A1'. + b1 = a1; // Error, x is protected in A1 but public in B1 + ~~ +!!! error TS2322: Type 'A1' is not assignable to type 'B1': +!!! error TS2322: Property 'x' is protected in type 'A1' but public in type 'B1'. + + class A2 { + protected x; + } + class B2 extends A2 { + x; + } + + class A3 { + x; + } + // Error x is protected in B3 but public in A3 + class B3 extends A3 { + ~~ +!!! error TS2416: Class 'B3' incorrectly extends base class 'A3': +!!! error TS2416: Property 'x' is protected in type 'B3' but public in type 'A3'. + protected x; + } + + \ No newline at end of file diff --git a/tests/baselines/reference/publicMemberImplementedAsPrivateInDerivedClass.errors.txt b/tests/baselines/reference/publicMemberImplementedAsPrivateInDerivedClass.errors.txt index 7e73338b4ec32..b5404823218ff 100644 --- a/tests/baselines/reference/publicMemberImplementedAsPrivateInDerivedClass.errors.txt +++ b/tests/baselines/reference/publicMemberImplementedAsPrivateInDerivedClass.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/publicMemberImplementedAsPrivateInDerivedClass.ts(4,7): error TS2421: Class 'Foo' incorrectly implements interface 'Qux': - Private property 'Bar' cannot be reimplemented. + Property 'Bar' is private in type 'Foo' but not in type 'Qux'. ==== tests/cases/compiler/publicMemberImplementedAsPrivateInDerivedClass.ts (1 errors) ==== @@ -9,7 +9,7 @@ tests/cases/compiler/publicMemberImplementedAsPrivateInDerivedClass.ts(4,7): err class Foo implements Qux { ~~~ !!! error TS2421: Class 'Foo' incorrectly implements interface 'Qux': -!!! error TS2421: Private property 'Bar' cannot be reimplemented. +!!! error TS2421: Property 'Bar' is private in type 'Foo' but not in type 'Qux'. private Bar: number; } \ No newline at end of file diff --git a/tests/baselines/reference/scopeTests.errors.txt b/tests/baselines/reference/scopeTests.errors.txt index f8c2ec5768877..59749eaf396c8 100644 --- a/tests/baselines/reference/scopeTests.errors.txt +++ b/tests/baselines/reference/scopeTests.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/scopeTests.ts(2,7): error TS2416: Class 'D' incorrectly extends base class 'C': - Private property 'v' cannot be reimplemented. + Property 'v' is private in type 'C' but not in type 'D'. ==== tests/cases/compiler/scopeTests.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/scopeTests.ts(2,7): error TS2416: Class 'D' incorrectly ext class D extends C { ~ !!! error TS2416: Class 'D' incorrectly extends base class 'C': -!!! error TS2416: Private property 'v' cannot be reimplemented. +!!! error TS2416: Property 'v' is private in type 'C' but not in type 'D'. public v: number; public p: number constructor() { diff --git a/tests/baselines/reference/shadowPrivateMembers.errors.txt b/tests/baselines/reference/shadowPrivateMembers.errors.txt index 54ba537071d54..94dd577c1c4f4 100644 --- a/tests/baselines/reference/shadowPrivateMembers.errors.txt +++ b/tests/baselines/reference/shadowPrivateMembers.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/shadowPrivateMembers.ts(2,7): error TS2416: Class 'derived' incorrectly extends base class 'base': - Private property 'n' cannot be reimplemented. + Types have separate declarations of a private property 'n'. ==== tests/cases/compiler/shadowPrivateMembers.ts (1 errors) ==== @@ -7,5 +7,5 @@ tests/cases/compiler/shadowPrivateMembers.ts(2,7): error TS2416: Class 'derived' class derived extends base { private n() {} } ~~~~~~~ !!! error TS2416: Class 'derived' incorrectly extends base class 'base': -!!! error TS2416: Private property 'n' cannot be reimplemented. +!!! error TS2416: Types have separate declarations of a private property 'n'. \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithObjectMembersAccessibility.errors.txt b/tests/baselines/reference/subtypingWithObjectMembersAccessibility.errors.txt index cf81925bdd3b8..09dfa1696df34 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersAccessibility.errors.txt +++ b/tests/baselines/reference/subtypingWithObjectMembersAccessibility.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersAccessibility.ts(15,7): error TS2416: Class 'B' incorrectly extends base class 'A': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'B' but not in type 'A'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersAccessibility.ts(23,7): error TS2416: Class 'B2' incorrectly extends base class 'A2': - Private property '1' cannot be reimplemented. + Property '1' is private in type 'B2' but not in type 'A2'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersAccessibility.ts(31,7): error TS2416: Class 'B3' incorrectly extends base class 'A3': - Private property ''1'' cannot be reimplemented. + Property ''1'' is private in type 'B3' but not in type 'A3'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersAccessibility.ts (3 errors) ==== @@ -24,7 +24,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B extends A { ~ !!! error TS2416: Class 'B' incorrectly extends base class 'A': -!!! error TS2416: Private property 'foo' cannot be reimplemented. +!!! error TS2416: Property 'foo' is private in type 'B' but not in type 'A'. private foo: Derived; // error } @@ -35,7 +35,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B2 extends A2 { ~~ !!! error TS2416: Class 'B2' incorrectly extends base class 'A2': -!!! error TS2416: Private property '1' cannot be reimplemented. +!!! error TS2416: Property '1' is private in type 'B2' but not in type 'A2'. private 1: Derived; // error } @@ -46,6 +46,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B3 extends A3 { ~~ !!! error TS2416: Class 'B3' incorrectly extends base class 'A3': -!!! error TS2416: Private property ''1'' cannot be reimplemented. +!!! error TS2416: Property ''1'' is private in type 'B3' but not in type 'A3'. private '1': Derived; // error } \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithObjectMembersAccessibility2.errors.txt b/tests/baselines/reference/subtypingWithObjectMembersAccessibility2.errors.txt index dcb66748752ab..9af7e894b2711 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersAccessibility2.errors.txt +++ b/tests/baselines/reference/subtypingWithObjectMembersAccessibility2.errors.txt @@ -1,15 +1,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersAccessibility2.ts(16,11): error TS2416: Class 'B' incorrectly extends base class 'A': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'A' but not in type 'B'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersAccessibility2.ts(24,11): error TS2416: Class 'B2' incorrectly extends base class 'A2': - Private property '1' cannot be reimplemented. + Property '1' is private in type 'A2' but not in type 'B2'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersAccessibility2.ts(32,11): error TS2416: Class 'B3' incorrectly extends base class 'A3': - Private property ''1'' cannot be reimplemented. + Property ''1'' is private in type 'A3' but not in type 'B3'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersAccessibility2.ts(42,11): error TS2416: Class 'B' incorrectly extends base class 'A': - Private property 'foo' cannot be reimplemented. + Property 'foo' is private in type 'A' but not in type 'B'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersAccessibility2.ts(50,11): error TS2416: Class 'B2' incorrectly extends base class 'A2': - Private property '1' cannot be reimplemented. + Property '1' is private in type 'A2' but not in type 'B2'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersAccessibility2.ts(58,11): error TS2416: Class 'B3' incorrectly extends base class 'A3': - Private property ''1'' cannot be reimplemented. + Property ''1'' is private in type 'A3' but not in type 'B3'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersAccessibility2.ts (6 errors) ==== @@ -31,7 +31,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B extends A { ~ !!! error TS2416: Class 'B' incorrectly extends base class 'A': -!!! error TS2416: Private property 'foo' cannot be reimplemented. +!!! error TS2416: Property 'foo' is private in type 'A' but not in type 'B'. public foo: Derived; // error } @@ -42,7 +42,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B2 extends A2 { ~~ !!! error TS2416: Class 'B2' incorrectly extends base class 'A2': -!!! error TS2416: Private property '1' cannot be reimplemented. +!!! error TS2416: Property '1' is private in type 'A2' but not in type 'B2'. public 1: Derived; // error } @@ -53,7 +53,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B3 extends A3 { ~~ !!! error TS2416: Class 'B3' incorrectly extends base class 'A3': -!!! error TS2416: Private property ''1'' cannot be reimplemented. +!!! error TS2416: Property ''1'' is private in type 'A3' but not in type 'B3'. public '1': Derived; // error } } @@ -66,7 +66,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B extends A { ~ !!! error TS2416: Class 'B' incorrectly extends base class 'A': -!!! error TS2416: Private property 'foo' cannot be reimplemented. +!!! error TS2416: Property 'foo' is private in type 'A' but not in type 'B'. foo: Derived; // error } @@ -77,7 +77,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B2 extends A2 { ~~ !!! error TS2416: Class 'B2' incorrectly extends base class 'A2': -!!! error TS2416: Private property '1' cannot be reimplemented. +!!! error TS2416: Property '1' is private in type 'A2' but not in type 'B2'. 1: Derived; // error } @@ -88,7 +88,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW class B3 extends A3 { ~~ !!! error TS2416: Class 'B3' incorrectly extends base class 'A3': -!!! error TS2416: Private property ''1'' cannot be reimplemented. +!!! error TS2416: Property ''1'' is private in type 'A3' but not in type 'B3'. '1': Derived; // error } } \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithObjectMembersOptionality2.errors.txt b/tests/baselines/reference/subtypingWithObjectMembersOptionality2.errors.txt index 8b1883588fb52..74d47f1256593 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersOptionality2.errors.txt +++ b/tests/baselines/reference/subtypingWithObjectMembersOptionality2.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts(10,11): error TS2429: Interface 'S' incorrectly extends interface 'T': - Required property 'Foo' cannot be reimplemented with optional property in 'S'. + Property 'Foo' is optional in type 'S' but required in type 'T'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts(18,11): error TS2429: Interface 'S2' incorrectly extends interface 'T2': - Required property '1' cannot be reimplemented with optional property in 'S2'. + Property '1' is optional in type 'S2' but required in type 'T2'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts(26,11): error TS2429: Interface 'S3' incorrectly extends interface 'T3': - Required property '1' cannot be reimplemented with optional property in 'S3'. + Property ''1'' is optional in type 'S3' but required in type 'T3'. tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembersOptionality2.ts(33,9): error TS2367: No best common type exists between '{ Foo: Base; }' and '{ Foo?: Derived; }'. @@ -20,7 +20,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface S extends T { ~ !!! error TS2429: Interface 'S' incorrectly extends interface 'T': -!!! error TS2429: Required property 'Foo' cannot be reimplemented with optional property in 'S'. +!!! error TS2429: Property 'Foo' is optional in type 'S' but required in type 'T'. Foo?: Derived // error } @@ -31,7 +31,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface S2 extends T2 { ~~ !!! error TS2429: Interface 'S2' incorrectly extends interface 'T2': -!!! error TS2429: Required property '1' cannot be reimplemented with optional property in 'S2'. +!!! error TS2429: Property '1' is optional in type 'S2' but required in type 'T2'. 1?: Derived; // error } @@ -42,7 +42,7 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW interface S3 extends T3 { ~~ !!! error TS2429: Interface 'S3' incorrectly extends interface 'T3': -!!! error TS2429: Required property '1' cannot be reimplemented with optional property in 'S3'. +!!! error TS2429: Property ''1'' is optional in type 'S3' but required in type 'T3'. '1'?: Derived; // error } diff --git a/tests/baselines/reference/superAccess.errors.txt b/tests/baselines/reference/superAccess.errors.txt index b44466516dc65..64c921e0e7f99 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 methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superAccess.ts(11,24): error TS2340: Only public 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 methods of !!! 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 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 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/superInLambdas.errors.txt b/tests/baselines/reference/superInLambdas.errors.txt index d59036efc3f13..ee25873d4764f 100644 --- a/tests/baselines/reference/superInLambdas.errors.txt +++ b/tests/baselines/reference/superInLambdas.errors.txt @@ -1,7 +1,7 @@ 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. -tests/cases/compiler/superInLambdas.ts(47,49): error TS2340: Only public methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superInLambdas.ts(51,49): error TS2340: Only public 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 (4 errors) ==== @@ -53,13 +53,13 @@ tests/cases/compiler/superInLambdas.ts(51,49): error TS2340: Only public methods // super property in a nested lambda in a constructor var superName = () => () => () => super.name; ~~~~ -!!! error TS2340: Only public 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 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 e791f2ae9b73f..4880bf66f17c4 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 methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess.ts(24,9): error TS2341: Property 'MyBase.p1' is inaccessible. -tests/cases/compiler/superPropertyAccess.ts(26,24): error TS2340: Only public methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess.ts(28,24): error TS2340: Only public methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess.ts(32,15): error TS2340: Only public methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess.ts(34,23): error TS2340: Only public 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 (8 errors) ==== @@ -36,28 +36,28 @@ tests/cases/compiler/superPropertyAccess.ts(34,23): error TS2340: Only public me super.m2.bind(this); // Should error, instance property, not a public instance member function ~~ -!!! error TS2340: Only public 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 ~~~~~~~~ -!!! error TS2341: Property 'MyBase.p1' is inaccessible. +!!! error TS2341: Property 'p1' is private and only accessible within class 'MyBase'. var l1 = super.d1; // Should error, instance data property not a public instance member function ~~ -!!! error TS2340: Only public 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 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 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 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 b3c65b6cda5e1..f5b565cae6edc 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(22,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/superPropertyAccess1.ts(13,15): error TS2340: Only public methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess1.ts(19,15): error TS2340: Only public methods of the base class are accessible via the 'super' keyword -tests/cases/compiler/superPropertyAccess1.ts(24,15): error TS2340: Only public 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(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 m super.bar(); super.x; // error ~ -!!! error TS2340: Only public 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 m super.bar(); super.x; // error ~ -!!! error TS2340: Only public 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 m super.bar(); super.x; // error ~ -!!! error TS2340: Only public 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 6175f79f58948..df9a5ee666b8c 100644 --- a/tests/baselines/reference/superPropertyAccess2.errors.txt +++ b/tests/baselines/reference/superPropertyAccess2.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/superPropertyAccess2.ts(3,16): error TS1056: Accessors are tests/cases/compiler/superPropertyAccess2.ts(22,23): 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 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(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 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/typeIdentityConsidersBrands.errors.txt b/tests/baselines/reference/typeIdentityConsidersBrands.errors.txt index 66337deb504f6..7d25976cb2f74 100644 --- a/tests/baselines/reference/typeIdentityConsidersBrands.errors.txt +++ b/tests/baselines/reference/typeIdentityConsidersBrands.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/typeIdentityConsidersBrands.ts(30,1): error TS2322: Type 'X_1' is not assignable to type 'Y_1': - Private property 'name' cannot be reimplemented. + Types have separate declarations of a private property 'name'. tests/cases/compiler/typeIdentityConsidersBrands.ts(31,6): error TS2345: Argument of type 'Y_1' is not assignable to parameter of type 'X_1'. @@ -36,7 +36,7 @@ tests/cases/compiler/typeIdentityConsidersBrands.ts(31,6): error TS2345: Argumen a2 = b2; // should error ~~ !!! error TS2322: Type 'X_1' is not assignable to type 'Y_1': -!!! error TS2322: Private property 'name' cannot be reimplemented. +!!! error TS2322: Types have separate declarations of a private property 'name'. foo2(a2); // should error ~~ !!! error TS2345: Argument of type 'Y_1' is not assignable to parameter of type 'X_1'. diff --git a/tests/baselines/reference/typeMatch1.errors.txt b/tests/baselines/reference/typeMatch1.errors.txt index 082679cd24a26..5921ba0a8d300 100644 --- a/tests/baselines/reference/typeMatch1.errors.txt +++ b/tests/baselines/reference/typeMatch1.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/typeMatch1.ts(18,1): error TS2322: Type 'D' is not assignable to type 'C': - Private property 'x' cannot be reimplemented. + Types have separate declarations of a private property 'x'. tests/cases/compiler/typeMatch1.ts(19,1): error TS2322: Type 'typeof C' is not assignable to type 'C': Property 'x' is missing in type 'typeof C'. tests/cases/compiler/typeMatch1.ts(20,1): error TS2365: Operator '==' cannot be applied to types 'typeof C' and 'typeof D'. @@ -26,7 +26,7 @@ tests/cases/compiler/typeMatch1.ts(20,1): error TS2365: Operator '==' cannot be x6 = x7; ~~ !!! error TS2322: Type 'D' is not assignable to type 'C': -!!! error TS2322: Private property 'x' cannot be reimplemented. +!!! error TS2322: Types have separate declarations of a private property 'x'. x6=C; ~~ !!! error TS2322: Type 'typeof C' is not assignable to type 'C': diff --git a/tests/cases/compiler/protectedMembers.ts b/tests/cases/compiler/protectedMembers.ts new file mode 100644 index 0000000000000..ae32e47242505 --- /dev/null +++ b/tests/cases/compiler/protectedMembers.ts @@ -0,0 +1,115 @@ +// Class with protected members +class C1 { + protected x: number; + protected static sx: number; + protected f() { + return this.x; + } + protected static sf() { + return this.sx; + } +} + +// Derived class accessing protected members +class C2 extends C1 { + protected f() { + return super.f() + this.x; + } + protected static sf() { + return super.sf() + this.sx; + } +} + +// Derived class making protected members public +class C3 extends C2 { + x: number; + static sx: number; + f() { + return super.f(); + } + static sf() { + return super.sf(); + } +} + +var c1: C1; +var c2: C2; +var c3: C3; + +// All of these should be errors +c1.x; +c1.f(); +C1.sx; +C1.sf(); + +// All of these should be errors +c2.x; +c2.f(); +C2.sx; +C2.sf(); + +// All of these should be ok +c3.x; +c3.f(); +C3.sx; +C3.sf(); + +class A { + protected x; +} + +class B extends A { + y; +} + +class C extends A { + z; + static foo(a: A, b: B, c: C, d: D, e: E) { + a.x = 1; // Error, access must be through C or type derived from C + b.x = 1; // Error, access must be through C or type derived from C + c.x = 1; + d.x = 1; + e.x = 1; + } +} + +class D extends C { + d; +} + +interface E extends C { + e; +} + +class CC { + // Error, constructor cannot be protected + protected constructor() { + } +} + +class A1 { + protected x; +} +class B1 { + x; +} +var a1: A1; +var b1: B1; +a1 = b1; // Error, B1 doesn't derive from A1 +b1 = a1; // Error, x is protected in A1 but public in B1 + +class A2 { + protected x; +} +class B2 extends A2 { + x; +} + +class A3 { + x; +} +// Error x is protected in B3 but public in A3 +class B3 extends A3 { + protected x; +} + diff --git a/tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts b/tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts index 353ab012234d2..c2e4855e63a3b 100644 --- a/tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts +++ b/tests/cases/conformance/classes/constructorDeclarations/classConstructorAccessibility.ts @@ -6,8 +6,13 @@ class D { private constructor(public x: number) { } // error } +class E { + protected constructor(public x: number) { } // error +} + var c = new C(1); var d = new D(1); +var e = new E(1); module Generic { class C { @@ -18,6 +23,11 @@ module Generic { private constructor(public x: T) { } // error } + class E { + protected constructor(public x: T) { } // error + } + var c = new C(1); var d = new D(1); + var e = new E(1); } diff --git a/tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts b/tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts index e3ea627f0c370..f4d63da1192fc 100644 --- a/tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts +++ b/tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties.ts @@ -1,18 +1,20 @@ class C { y: string; - constructor(private x: string) { } + constructor(private x: string, protected z: string) { } } var c: C; var r = c.y; var r2 = c.x; // error +var r3 = c.z; // error class D { y: T; - constructor(a: T, private x: T) { } + constructor(a: T, private x: T, protected z: T) { } } var d: D; var r = d.y; var r2 = d.x; // error -var r3 = d.a; // error \ No newline at end of file +var r3 = d.a; // error +var r4 = d.z; // error diff --git a/tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts b/tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts index 4d14e4bafbdce..b95891c0845e7 100644 --- a/tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts +++ b/tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorParameterProperties2.ts @@ -20,4 +20,12 @@ class E { } var e: E; -var r3 = e.y; // error \ No newline at end of file +var r3 = e.y; // error + +class F { + y: number; + constructor(protected y: number) { } // error +} + +var f: F; +var r4 = f.y; // error diff --git a/tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts b/tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts new file mode 100644 index 0000000000000..7efe159c058f2 --- /dev/null +++ b/tests/cases/conformance/classes/members/accessibility/classPropertyAsProtected.ts @@ -0,0 +1,23 @@ +class C { + protected x: string; + protected get y() { return null; } + protected set y(x) { } + protected foo() { } + + protected static a: string; + protected static get b() { return null; } + protected static set b(x) { } + protected static foo() { } +} + +var c: C; +// all errors +c.x; +c.y; +c.y = 1; +c.foo(); + +C.a; +C.b(); +C.b = 1; +C.foo(); \ No newline at end of file diff --git a/tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinClass.ts b/tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinClass.ts new file mode 100644 index 0000000000000..08f99af59727f --- /dev/null +++ b/tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinClass.ts @@ -0,0 +1,31 @@ +// @target: ES5 +// no errors + +class C { + protected x: string; + protected get y() { return this.x; } + protected set y(x) { this.y = this.x; } + protected foo() { return this.foo; } + + protected static x: string; + protected static get y() { return this.x; } + protected static set y(x) { this.y = this.x; } + protected static foo() { return this.foo; } + protected static bar() { this.foo(); } +} + +// added level of function nesting +class C2 { + protected x: string; + protected get y() { () => this.x; return null; } + protected set y(x) { () => { this.y = this.x; } } + protected foo() { () => this.foo; } + + protected static x: string; + protected static get y() { () => this.x; return null; } + protected static set y(x) { + () => { this.y = this.x; } + } + protected static foo() { () => this.foo; } + protected static bar() { () => this.foo(); } +} diff --git a/tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass.ts b/tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass.ts new file mode 100644 index 0000000000000..56c591f41ce6d --- /dev/null +++ b/tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass.ts @@ -0,0 +1,19 @@ +// @target: ES5 +// no errors + +class B { + protected x: string; + protected static x: string; +} + +class C extends B { + protected get y() { return this.x; } + protected set y(x) { this.y = this.x; } + protected foo() { return this.x; } + protected bar() { return this.foo(); } + + protected static get y() { return this.x; } + protected static set y(x) { this.y = this.x; } + protected static foo() { return this.x; } + protected static bar() { this.foo(); } +} diff --git a/tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts b/tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts new file mode 100644 index 0000000000000..b92d29d4d632d --- /dev/null +++ b/tests/cases/conformance/classes/members/accessibility/protectedInstanceMemberAccessibility.ts @@ -0,0 +1,43 @@ +class A { + protected x: string; + protected f(): string { + return "hello"; + } +} + +class B extends A { + protected y: string; + g() { + var t1 = this.x; + var t2 = this.f(); + var t3 = this.y; + var t4 = this.z; // error + + var s1 = super.x; // error + var s2 = super.f(); + var s3 = super.y; // error + var s4 = super.z; // error + + var a: A; + var a1 = a.x; // error + var a2 = a.f(); // error + var a3 = a.y; // error + var a4 = a.z; // error + + var b: B; + var b1 = b.x; + var b2 = b.f(); + var b3 = b.y; + var b4 = b.z; // error + + var c: C; + var c1 = c.x; // error + var c2 = c.f(); // error + var c3 = c.y; // error + var c4 = c.z; // error + } +} + +class C extends A { + protected z: string; +} diff --git a/tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts b/tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts new file mode 100644 index 0000000000000..746ab5bc393c4 --- /dev/null +++ b/tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts @@ -0,0 +1,40 @@ +class Foo { + protected x: string; +} + +interface I extends Foo { + y: number; +} + +class Bar implements I { // error +} + +class Bar2 implements I { // error + y: number; +} + +class Bar3 implements I { // error + x: string; + y: number; +} + +class Bar4 implements I { // error + protected x: string; + y: number; +} + +class Bar5 extends Foo implements I { // error +} + +class Bar6 extends Foo implements I { // error + protected y: number; +} + +class Bar7 extends Foo implements I { + y: number; +} + +class Bar8 extends Foo implements I { + x: string; + y: number; +} diff --git a/tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithProtecteds.ts b/tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithProtecteds.ts new file mode 100644 index 0000000000000..6a504a916da41 --- /dev/null +++ b/tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithProtecteds.ts @@ -0,0 +1,15 @@ +class Foo { + protected x: string; +} + +interface I extends Foo { // error + x: string; +} + +interface I2 extends Foo { + y: string; +} + +var i: I2; +var r = i.y; +var r2 = i.x; // error \ No newline at end of file diff --git a/tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithProtecteds2.ts b/tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithProtecteds2.ts new file mode 100644 index 0000000000000..4663709bce8f2 --- /dev/null +++ b/tests/cases/conformance/interfaces/interfacesExtendingClasses/interfaceExtendingClassWithProtecteds2.ts @@ -0,0 +1,27 @@ +class Foo { + protected x: string; +} + +class Bar { + protected x: string; +} + +interface I3 extends Foo, Bar { // error +} + +interface I4 extends Foo, Bar { // error + x: string; +} + +class Baz { + protected y: string; +} + +interface I5 extends Foo, Baz { + z: string; +} + +var i: I5; +var r: string = i.z; +var r2 = i.x; // error +var r3 = i.y; // error \ No newline at end of file