From 98f631e23fa49dd22b7ffb3dd6e99fc12433a4f2 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 11 Aug 2014 14:15:57 -0700 Subject: [PATCH] Make changes to report error if the type used from external module cannot be named Adds test cases too --- src/compiler/checker.ts | 51 ++- .../diagnosticInformationMap.generated.ts | 12 + src/compiler/diagnosticMessages.json | 48 ++ src/compiler/emitter.ts | 84 ++-- ...ivacyCannotNameAccessorDeclFile.errors.txt | 151 +++++++ .../privacyCannotNameAccessorDeclFile.js | 410 +++++++++++++++++ ...rivacyCannotNameVarTypeDeclFile.errors.txt | 123 +++++ .../privacyCannotNameVarTypeDeclFile.js | 238 ++++++++++ ...CannotNameParameterTypeDeclFile.errors.txt | 203 +++++++++ ...FunctionCannotNameParameterTypeDeclFile.js | 424 ++++++++++++++++++ ...ionCannotNameReturnTypeDeclFile.errors.txt | 186 ++++++++ ...acyFunctionCannotNameReturnTypeDeclFile.js | 381 ++++++++++++++++ .../privacyCannotNameAccessorDeclFile.ts | 138 ++++++ .../privacyCannotNameVarTypeDeclFile.ts | 101 +++++ ...FunctionCannotNameParameterTypeDeclFile.ts | 157 +++++++ ...acyFunctionCannotNameReturnTypeDeclFile.ts | 163 +++++++ 16 files changed, 2831 insertions(+), 39 deletions(-) create mode 100644 tests/baselines/reference/privacyCannotNameAccessorDeclFile.errors.txt create mode 100644 tests/baselines/reference/privacyCannotNameAccessorDeclFile.js create mode 100644 tests/baselines/reference/privacyCannotNameVarTypeDeclFile.errors.txt create mode 100644 tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js create mode 100644 tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.errors.txt create mode 100644 tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.js create mode 100644 tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.errors.txt create mode 100644 tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.js create mode 100644 tests/cases/compiler/privacyCannotNameAccessorDeclFile.ts create mode 100644 tests/cases/compiler/privacyCannotNameVarTypeDeclFile.ts create mode 100644 tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile.ts create mode 100644 tests/cases/compiler/privacyFunctionCannotNameReturnTypeDeclFile.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b3c61262adb..b32b86db639 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -681,9 +681,11 @@ module ts { function isAccessible(symbolFromSymbolTable: Symbol, resolvedAliasSymbol?: Symbol) { if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) { - // if symbolfrom symbolTable or alias resolution matches the symbol, + // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) + // and if symbolfrom symbolTable or alias resolution matches the symbol, // check the symbol can be qualified, it is only then this symbol is accessible - return canQualifySymbol(symbolFromSymbolTable, meaning); + return !forEach(symbolFromSymbolTable.declarations, declaration => hasExternalModuleSymbol(declaration)) && + canQualifySymbol(symbolFromSymbolTable, meaning); } } @@ -779,14 +781,42 @@ module ts { symbol = symbol.parent; } - // This is a local symbol that cannot be named + // This could be a symbol that is not exported in the external module + // or it could be a symbol from different external module that is not aliased and hence cannot be named + var symbolExternalModule = forEach(initialSymbol.declarations, declaration => getExternalModuleContainer(declaration)); + if (symbolExternalModule) { + var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration); + if (symbolExternalModule !== enclosingExternalModule) { + // name from different external module that is not visibile + return { + accessibility: SymbolAccessibility.CannotBeNamed, + errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), + errorModuleName: symbolToString(symbolExternalModule) + }; + } + } + + // Just a local name that is not accessible return { - accessibility: SymbolAccessibility.CannotBeNamed, + accessibility: SymbolAccessibility.NotAccessible, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), }; } return { accessibility: SymbolAccessibility.Accessible }; + + function getExternalModuleContainer(declaration: Declaration) { + for (; declaration; declaration = declaration.parent) { + if (hasExternalModuleSymbol(declaration)) { + return getSymbolOfNode(declaration); + } + } + } + } + + function hasExternalModuleSymbol(declaration: Declaration) { + return (declaration.kind === SyntaxKind.ModuleDeclaration && declaration.name.kind === SyntaxKind.StringLiteral) || + (declaration.kind === SyntaxKind.SourceFile && isExternalModule(declaration)); } function hasVisibleDeclarations(symbol: Symbol): { aliasesToMakeVisible?: ImportDeclaration[]; } { @@ -855,7 +885,18 @@ module ts { while (symbol) { var isFirstName = !symbolName; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning); - var currentSymbolName = accessibleSymbolChain ? ts.map(accessibleSymbolChain, accessibleSymbol => getSymbolName(accessibleSymbol)).join(".") : getSymbolName(symbol); + + var currentSymbolName: string; + if (accessibleSymbolChain) { + currentSymbolName = ts.map(accessibleSymbolChain, accessibleSymbol => getSymbolName(accessibleSymbol)).join("."); + } + else { + // If we didnt find accessible symbol chain for this symbol, break if this is external module + if (!isFirstName && ts.forEach(symbol.declarations, declaration => hasExternalModuleSymbol(declaration))) { + break; + } + currentSymbolName = getSymbolName(symbol); + } symbolName = currentSymbolName + (isFirstName ? "" : ("." + symbolName)); if (accessibleSymbolChain && !needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { break; diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index aa89b29acad..c917a7ba123 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -231,6 +231,18 @@ module ts { A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2246, category: DiagnosticCategory.Error, key: "A parameter property is only allowed in a constructor implementation." }, Function_overload_must_be_static: { code: 2247, category: DiagnosticCategory.Error, key: "Function overload must be static." }, Function_overload_must_not_be_static: { code: 2248, category: DiagnosticCategory.Error, key: "Function overload must not be static." }, + Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 2249, category: DiagnosticCategory.Error, key: "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 2250, category: DiagnosticCategory.Error, key: "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 2251, category: DiagnosticCategory.Error, key: "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 2252, category: DiagnosticCategory.Error, key: "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 2253, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 2254, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named." }, + Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 2255, category: DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named." }, + Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 2256, category: DiagnosticCategory.Error, key: "Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 2257, category: DiagnosticCategory.Error, key: "Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 2258, category: DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 2259, category: DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named." }, + Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named: { code: 2260, category: DiagnosticCategory.Error, key: "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named." }, Circular_definition_of_import_alias_0: { code: 3000, category: DiagnosticCategory.Error, key: "Circular definition of import alias '{0}'." }, Cannot_find_name_0: { code: 3001, category: DiagnosticCategory.Error, key: "Cannot find name '{0}'." }, Module_0_has_no_exported_member_1: { code: 3002, category: DiagnosticCategory.Error, key: "Module '{0}' has no exported member '{1}'." }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index e9ce55dd3bd..682952ba84f 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -916,6 +916,54 @@ "category": "Error", "code": 2248 }, + "Public static property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named.": { + "category": "Error", + "code": 2249 + }, + "Public property '{0}' of exported class has or is using name '{1}' from external module {2} but cannot be named.": { + "category": "Error", + "code": 2250 + }, + "Exported variable '{0}' has or is using name '{1}' from external module {2} but cannot be named.": { + "category": "Error", + "code": 2251 + }, + "Parameter '{0}' of constructor from exported class has or is using name '{1}' from external module {2} but cannot be named.": { + "category": "Error", + "code": 2252 + }, + "Parameter '{0}' of public static method from exported class has or is using name '{1}' from external module {2} but cannot be named.": { + "category": "Error", + "code": 2253 + }, + "Parameter '{0}' of public method from exported class has or is using name '{1}' from external module {2} but cannot be named.": { + "category": "Error", + "code": 2254 + }, + "Parameter '{0}' of exported function has or is using name '{1}' from external module {2} but cannot be named.": { + "category": "Error", + "code": 2255 + }, + "Return type of public static property getter from exported class has or is using name '{0}' from external module {1} but cannot be named.": { + "category": "Error", + "code": 2256 + }, + "Return type of public property getter from exported class has or is using name '{0}' from external module {1} but cannot be named.": { + "category": "Error", + "code": 2257 + }, + "Return type of public static method from exported class has or is using name '{0}' from external module {1} but cannot be named.": { + "category": "Error", + "code": 2258 + }, + "Return type of public method from exported class has or is using name '{0}' from external module {1} but cannot be named.": { + "category": "Error", + "code": 2259 + }, + "Return type of exported function has or is using name '{0}' from external module {1} but cannot be named.": { + "category": "Error", + "code": 2260 + }, "Circular definition of import alias '{0}'.": { "category": "Error", "code": 3000 diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index bb182e9a812..973f7123360 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2093,7 +2093,7 @@ module ts { function emitTypeParameters(typeParameters: TypeParameterDeclaration[]) { function emitTypeParameter(node: TypeParameterDeclaration) { function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult) { - // TODO(shkamat) Cannot access name errors + // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage: DiagnosticMessage; switch (node.parent.kind) { case SyntaxKind.ClassDeclaration: @@ -2183,42 +2183,30 @@ module ts { function getHeritageClauseVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult) { var diagnosticMessage: DiagnosticMessage; + // Heritage clause is written by user so it can always be named if (node.parent.kind === SyntaxKind.ClassDeclaration) { // Class - if (symbolAccesibilityResult.accessibility == SymbolAccessibility.NotAccessible) { - if (symbolAccesibilityResult.errorModuleName) { - // Module is inaccessible - diagnosticMessage = isImplementsList ? - Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2 : - Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2; - } - else { - // Class or Interface implemented/extended is inaccessible - diagnosticMessage = isImplementsList ? - Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : - Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; - } + if (symbolAccesibilityResult.errorModuleName) { + // Module is inaccessible + diagnosticMessage = isImplementsList ? + Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2 : + Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2; } else { - // CannotBeNamed - // TODO(shkamat): CannotBeNamed error needs to be handled + // Class or Interface implemented/extended is inaccessible + diagnosticMessage = isImplementsList ? + Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : + Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_private_name_1; } } else { - // Interface - if (symbolAccesibilityResult.accessibility == SymbolAccessibility.NotAccessible) { - if (symbolAccesibilityResult.errorModuleName) { - // Module is inaccessible - diagnosticMessage = Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_name_1_from_private_module_2; - } - else { - // interface is inaccessible - diagnosticMessage = Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; - } + if (symbolAccesibilityResult.errorModuleName) { + // Module is inaccessible + diagnosticMessage = Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_name_1_from_private_module_2; } else { - // CannotBeNamed - // TODO(shkamat): CannotBeNamed error needs to be handled + // interface is inaccessible + diagnosticMessage = Diagnostics.Extends_clause_of_exported_interface_0_has_or_is_using_private_name_1; } } @@ -2309,10 +2297,11 @@ module ts { } function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult) { - // TODO(shkamat) Cannot access name errors var diagnosticMessage: DiagnosticMessage; if (node.kind === SyntaxKind.VariableDeclaration) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } @@ -2320,15 +2309,20 @@ module ts { else if (node.kind === SyntaxKind.Property) { if (node.flags & NodeFlags.Static) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } else if (node.parent.kind === SyntaxKind.ClassDeclaration) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; } else { + // Interfaces cannot have types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1; @@ -2369,9 +2363,9 @@ module ts { } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult) { - // TODO(shkamat) Cannot access name errors var diagnosticMessage: DiagnosticMessage; if (node.kind === SyntaxKind.SetAccessor) { + // Setters have to have type named and cannot infer it so, the type should always be named if (node.parent.flags & NodeFlags.Static) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -2391,11 +2385,15 @@ module ts { else { if (node.flags & NodeFlags.Static) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : Diagnostics.Return_type_of_public_static_property_getter_from_exported_class_has_or_is_using_private_name_0; } else { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_name_0_from_private_module_1 : Diagnostics.Return_type_of_public_property_getter_from_exported_class_has_or_is_using_private_name_0; } @@ -2465,22 +2463,24 @@ module ts { writeLine(); function getReturnTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult) { - // TODO(shkamat) Cannot access name errors var diagnosticMessage: DiagnosticMessage; switch (node.kind) { case SyntaxKind.ConstructSignature: - diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + // Interfaces cannot have return types that cannot be named + diagnosticMessage = symbolAccesibilityResult.errorModuleName ? Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; case SyntaxKind.CallSignature: + // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; case SyntaxKind.IndexSignature: + // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; @@ -2489,15 +2489,20 @@ module ts { case SyntaxKind.Method: if (node.flags & NodeFlags.Static) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } else if (node.parent.kind === SyntaxKind.ClassDeclaration) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; } else { + // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; @@ -2506,6 +2511,8 @@ module ts { case SyntaxKind.FunctionDeclaration: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; break; @@ -2519,7 +2526,6 @@ module ts { errorNode: node.name || node, }; } - } function emitParameterDeclaration(node: ParameterDeclaration) { @@ -2538,22 +2544,25 @@ module ts { } function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult) { - // TODO(shkamat) Cannot access name errors var diagnosticMessage: DiagnosticMessage; switch (node.parent.kind) { case SyntaxKind.Constructor: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; break; case SyntaxKind.ConstructSignature: + // Interfaces cannot have parameter types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; case SyntaxKind.CallSignature: + // Interfaces cannot have parameter types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; @@ -2562,15 +2571,20 @@ module ts { case SyntaxKind.Method: if (node.parent.flags & NodeFlags.Static) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } else if (node.parent.parent.kind === SyntaxKind.ClassDeclaration) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { + // Interfaces cannot have parameter types that cannot be named diagnosticMessage = symbolAccesibilityResult.errorModuleName ? Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; @@ -2579,6 +2593,8 @@ module ts { case SyntaxKind.FunctionDeclaration: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? + symbolAccesibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? + Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; break; diff --git a/tests/baselines/reference/privacyCannotNameAccessorDeclFile.errors.txt b/tests/baselines/reference/privacyCannotNameAccessorDeclFile.errors.txt new file mode 100644 index 00000000000..4f7f684d073 --- /dev/null +++ b/tests/baselines/reference/privacyCannotNameAccessorDeclFile.errors.txt @@ -0,0 +1,151 @@ +==== tests/cases/compiler/privacyCannotNameAccessorDeclFile_consumer.ts (8 errors) ==== + import exporter = require("privacyCannotNameAccessorDeclFile_exporter"); + export class publicClassWithWithPrivateGetAccessorTypes { + static get myPublicStaticMethod() { // Error + ~~~~~~~~~~~~~~~~~~~~ +!!! Return type of public static property getter from exported class has or is using name 'Widget1' from external module "tests/cases/compiler/privacyCannotNameAccessorDeclFile_Widgets" but cannot be named. + return exporter.createExportedWidget1(); + } + private static get myPrivateStaticMethod() { + return exporter.createExportedWidget1(); + } + get myPublicMethod() { // Error + ~~~~~~~~~~~~~~ +!!! Return type of public property getter from exported class has or is using name 'Widget1' from external module "tests/cases/compiler/privacyCannotNameAccessorDeclFile_Widgets" but cannot be named. + return exporter.createExportedWidget1(); + } + private get myPrivateMethod() { + return exporter.createExportedWidget1(); + } + static get myPublicStaticMethod1() { // Error + ~~~~~~~~~~~~~~~~~~~~~ +!!! Return type of public static property getter from exported class has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. + return exporter.createExportedWidget3(); + } + private static get myPrivateStaticMethod1() { + return exporter.createExportedWidget3(); + } + get myPublicMethod1() { // Error + ~~~~~~~~~~~~~~~ +!!! Return type of public property getter from exported class has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. + return exporter.createExportedWidget3(); + } + private get myPrivateMethod1() { + return exporter.createExportedWidget3(); + } + } + + class privateClassWithWithPrivateGetAccessorTypes { + static get myPublicStaticMethod() { + return exporter.createExportedWidget1(); + } + private static get myPrivateStaticMethod() { + return exporter.createExportedWidget1(); + } + get myPublicMethod() { + return exporter.createExportedWidget1(); + } + private get myPrivateMethod() { + return exporter.createExportedWidget1(); + } + static get myPublicStaticMethod1() { + return exporter.createExportedWidget3(); + } + private static get myPrivateStaticMethod1() { + return exporter.createExportedWidget3(); + } + get myPublicMethod1() { + return exporter.createExportedWidget3(); + } + private get myPrivateMethod1() { + return exporter.createExportedWidget3(); + } + } + + export class publicClassWithPrivateModuleGetAccessorTypes { + static get myPublicStaticMethod() { // Error + ~~~~~~~~~~~~~~~~~~~~ +!!! Return type of public static property getter from exported class has or is using name 'SpecializedWidget.Widget2' from external module "tests/cases/compiler/privacyCannotNameAccessorDeclFile_Widgets" but cannot be named. + return exporter.createExportedWidget2(); + } + get myPublicMethod() { // Error + ~~~~~~~~~~~~~~ +!!! Return type of public property getter from exported class has or is using name 'SpecializedWidget.Widget2' from external module "tests/cases/compiler/privacyCannotNameAccessorDeclFile_Widgets" but cannot be named. + return exporter.createExportedWidget2(); + } + static get myPublicStaticMethod1() { // Error + ~~~~~~~~~~~~~~~~~~~~~ +!!! Return type of public static property getter from exported class has or is using name 'SpecializedGlobalWidget.Widget4' from external module "GlobalWidgets" but cannot be named. + return exporter.createExportedWidget4(); + } + get myPublicMethod1() { // Error + ~~~~~~~~~~~~~~~ +!!! Return type of public property getter from exported class has or is using name 'SpecializedGlobalWidget.Widget4' from external module "GlobalWidgets" but cannot be named. + return exporter.createExportedWidget4(); + } + } + + class privateClassWithPrivateModuleGetAccessorTypes { + static get myPublicStaticMethod() { + return exporter.createExportedWidget2(); + } + get myPublicMethod() { + return exporter.createExportedWidget2(); + } + static get myPublicStaticMethod1() { + return exporter.createExportedWidget4(); + } + get myPublicMethod1() { + return exporter.createExportedWidget4(); + } + } +==== tests/cases/compiler/privacyCannotNameAccessorDeclFile_GlobalWidgets.ts (0 errors) ==== + + declare module "GlobalWidgets" { + export class Widget3 { + name: string; + } + export function createWidget3(): Widget3; + + export module SpecializedGlobalWidget { + export class Widget4 { + name: string; + } + function createWidget4(): Widget4; + } + } + +==== tests/cases/compiler/privacyCannotNameAccessorDeclFile_Widgets.ts (0 errors) ==== + export class Widget1 { + name = 'one'; + } + export function createWidget1() { + return new Widget1(); + } + + export module SpecializedWidget { + export class Widget2 { + name = 'one'; + } + export function createWidget2() { + return new Widget2(); + } + } + +==== tests/cases/compiler/privacyCannotNameAccessorDeclFile_exporter.ts (0 errors) ==== + /// + import Widgets = require("privacyCannotNameAccessorDeclFile_Widgets"); + import Widgets1 = require("GlobalWidgets"); + export function createExportedWidget1() { + return Widgets.createWidget1(); + } + export function createExportedWidget2() { + return Widgets.SpecializedWidget.createWidget2(); + } + export function createExportedWidget3() { + return Widgets1.createWidget3(); + } + export function createExportedWidget4() { + return Widgets1.SpecializedGlobalWidget.createWidget4(); + } + \ No newline at end of file diff --git a/tests/baselines/reference/privacyCannotNameAccessorDeclFile.js b/tests/baselines/reference/privacyCannotNameAccessorDeclFile.js new file mode 100644 index 00000000000..947c3c1fc0d --- /dev/null +++ b/tests/baselines/reference/privacyCannotNameAccessorDeclFile.js @@ -0,0 +1,410 @@ +//// [tests/cases/compiler/privacyCannotNameAccessorDeclFile.ts] //// + +//// [privacyCannotNameAccessorDeclFile_GlobalWidgets.ts] + +declare module "GlobalWidgets" { + export class Widget3 { + name: string; + } + export function createWidget3(): Widget3; + + export module SpecializedGlobalWidget { + export class Widget4 { + name: string; + } + function createWidget4(): Widget4; + } +} + +//// [privacyCannotNameAccessorDeclFile_Widgets.ts] +export class Widget1 { + name = 'one'; +} +export function createWidget1() { + return new Widget1(); +} + +export module SpecializedWidget { + export class Widget2 { + name = 'one'; + } + export function createWidget2() { + return new Widget2(); + } +} + +//// [privacyCannotNameAccessorDeclFile_exporter.ts] +/// +import Widgets = require("privacyCannotNameAccessorDeclFile_Widgets"); +import Widgets1 = require("GlobalWidgets"); +export function createExportedWidget1() { + return Widgets.createWidget1(); +} +export function createExportedWidget2() { + return Widgets.SpecializedWidget.createWidget2(); +} +export function createExportedWidget3() { + return Widgets1.createWidget3(); +} +export function createExportedWidget4() { + return Widgets1.SpecializedGlobalWidget.createWidget4(); +} + +//// [privacyCannotNameAccessorDeclFile_consumer.ts] +import exporter = require("privacyCannotNameAccessorDeclFile_exporter"); +export class publicClassWithWithPrivateGetAccessorTypes { + static get myPublicStaticMethod() { // Error + return exporter.createExportedWidget1(); + } + private static get myPrivateStaticMethod() { + return exporter.createExportedWidget1(); + } + get myPublicMethod() { // Error + return exporter.createExportedWidget1(); + } + private get myPrivateMethod() { + return exporter.createExportedWidget1(); + } + static get myPublicStaticMethod1() { // Error + return exporter.createExportedWidget3(); + } + private static get myPrivateStaticMethod1() { + return exporter.createExportedWidget3(); + } + get myPublicMethod1() { // Error + return exporter.createExportedWidget3(); + } + private get myPrivateMethod1() { + return exporter.createExportedWidget3(); + } +} + +class privateClassWithWithPrivateGetAccessorTypes { + static get myPublicStaticMethod() { + return exporter.createExportedWidget1(); + } + private static get myPrivateStaticMethod() { + return exporter.createExportedWidget1(); + } + get myPublicMethod() { + return exporter.createExportedWidget1(); + } + private get myPrivateMethod() { + return exporter.createExportedWidget1(); + } + static get myPublicStaticMethod1() { + return exporter.createExportedWidget3(); + } + private static get myPrivateStaticMethod1() { + return exporter.createExportedWidget3(); + } + get myPublicMethod1() { + return exporter.createExportedWidget3(); + } + private get myPrivateMethod1() { + return exporter.createExportedWidget3(); + } +} + +export class publicClassWithPrivateModuleGetAccessorTypes { + static get myPublicStaticMethod() { // Error + return exporter.createExportedWidget2(); + } + get myPublicMethod() { // Error + return exporter.createExportedWidget2(); + } + static get myPublicStaticMethod1() { // Error + return exporter.createExportedWidget4(); + } + get myPublicMethod1() { // Error + return exporter.createExportedWidget4(); + } +} + +class privateClassWithPrivateModuleGetAccessorTypes { + static get myPublicStaticMethod() { + return exporter.createExportedWidget2(); + } + get myPublicMethod() { + return exporter.createExportedWidget2(); + } + static get myPublicStaticMethod1() { + return exporter.createExportedWidget4(); + } + get myPublicMethod1() { + return exporter.createExportedWidget4(); + } +} + +//// [privacyCannotNameAccessorDeclFile_GlobalWidgets.js] +//// [privacyCannotNameAccessorDeclFile_Widgets.js] +var Widget1 = (function () { + function Widget1() { + this.name = 'one'; + } + return Widget1; +})(); +exports.Widget1 = Widget1; +function createWidget1() { + return new Widget1(); +} +exports.createWidget1 = createWidget1; +(function (SpecializedWidget) { + var Widget2 = (function () { + function Widget2() { + this.name = 'one'; + } + return Widget2; + })(); + SpecializedWidget.Widget2 = Widget2; + function createWidget2() { + return new Widget2(); + } + SpecializedWidget.createWidget2 = createWidget2; +})(exports.SpecializedWidget || (exports.SpecializedWidget = {})); +var SpecializedWidget = exports.SpecializedWidget; +//// [privacyCannotNameAccessorDeclFile_exporter.js] +var Widgets = require("privacyCannotNameAccessorDeclFile_Widgets"); +var Widgets1 = require("GlobalWidgets"); +function createExportedWidget1() { + return Widgets.createWidget1(); +} +exports.createExportedWidget1 = createExportedWidget1; +function createExportedWidget2() { + return Widgets.SpecializedWidget.createWidget2(); +} +exports.createExportedWidget2 = createExportedWidget2; +function createExportedWidget3() { + return Widgets1.createWidget3(); +} +exports.createExportedWidget3 = createExportedWidget3; +function createExportedWidget4() { + return Widgets1.SpecializedGlobalWidget.createWidget4(); +} +exports.createExportedWidget4 = createExportedWidget4; +//// [privacyCannotNameAccessorDeclFile_consumer.js] +var exporter = require("privacyCannotNameAccessorDeclFile_exporter"); +var publicClassWithWithPrivateGetAccessorTypes = (function () { + function publicClassWithWithPrivateGetAccessorTypes() { + } + Object.defineProperty(publicClassWithWithPrivateGetAccessorTypes, "myPublicStaticMethod", { + get: function () { + return exporter.createExportedWidget1(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(publicClassWithWithPrivateGetAccessorTypes, "myPrivateStaticMethod", { + get: function () { + return exporter.createExportedWidget1(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(publicClassWithWithPrivateGetAccessorTypes.prototype, "myPublicMethod", { + get: function () { + return exporter.createExportedWidget1(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(publicClassWithWithPrivateGetAccessorTypes.prototype, "myPrivateMethod", { + get: function () { + return exporter.createExportedWidget1(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(publicClassWithWithPrivateGetAccessorTypes, "myPublicStaticMethod1", { + get: function () { + return exporter.createExportedWidget3(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(publicClassWithWithPrivateGetAccessorTypes, "myPrivateStaticMethod1", { + get: function () { + return exporter.createExportedWidget3(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(publicClassWithWithPrivateGetAccessorTypes.prototype, "myPublicMethod1", { + get: function () { + return exporter.createExportedWidget3(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(publicClassWithWithPrivateGetAccessorTypes.prototype, "myPrivateMethod1", { + get: function () { + return exporter.createExportedWidget3(); + }, + enumerable: true, + configurable: true + }); + return publicClassWithWithPrivateGetAccessorTypes; +})(); +exports.publicClassWithWithPrivateGetAccessorTypes = publicClassWithWithPrivateGetAccessorTypes; +var privateClassWithWithPrivateGetAccessorTypes = (function () { + function privateClassWithWithPrivateGetAccessorTypes() { + } + Object.defineProperty(privateClassWithWithPrivateGetAccessorTypes, "myPublicStaticMethod", { + get: function () { + return exporter.createExportedWidget1(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(privateClassWithWithPrivateGetAccessorTypes, "myPrivateStaticMethod", { + get: function () { + return exporter.createExportedWidget1(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(privateClassWithWithPrivateGetAccessorTypes.prototype, "myPublicMethod", { + get: function () { + return exporter.createExportedWidget1(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(privateClassWithWithPrivateGetAccessorTypes.prototype, "myPrivateMethod", { + get: function () { + return exporter.createExportedWidget1(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(privateClassWithWithPrivateGetAccessorTypes, "myPublicStaticMethod1", { + get: function () { + return exporter.createExportedWidget3(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(privateClassWithWithPrivateGetAccessorTypes, "myPrivateStaticMethod1", { + get: function () { + return exporter.createExportedWidget3(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(privateClassWithWithPrivateGetAccessorTypes.prototype, "myPublicMethod1", { + get: function () { + return exporter.createExportedWidget3(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(privateClassWithWithPrivateGetAccessorTypes.prototype, "myPrivateMethod1", { + get: function () { + return exporter.createExportedWidget3(); + }, + enumerable: true, + configurable: true + }); + return privateClassWithWithPrivateGetAccessorTypes; +})(); +var publicClassWithPrivateModuleGetAccessorTypes = (function () { + function publicClassWithPrivateModuleGetAccessorTypes() { + } + Object.defineProperty(publicClassWithPrivateModuleGetAccessorTypes, "myPublicStaticMethod", { + get: function () { + return exporter.createExportedWidget2(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(publicClassWithPrivateModuleGetAccessorTypes.prototype, "myPublicMethod", { + get: function () { + return exporter.createExportedWidget2(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(publicClassWithPrivateModuleGetAccessorTypes, "myPublicStaticMethod1", { + get: function () { + return exporter.createExportedWidget4(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(publicClassWithPrivateModuleGetAccessorTypes.prototype, "myPublicMethod1", { + get: function () { + return exporter.createExportedWidget4(); + }, + enumerable: true, + configurable: true + }); + return publicClassWithPrivateModuleGetAccessorTypes; +})(); +exports.publicClassWithPrivateModuleGetAccessorTypes = publicClassWithPrivateModuleGetAccessorTypes; +var privateClassWithPrivateModuleGetAccessorTypes = (function () { + function privateClassWithPrivateModuleGetAccessorTypes() { + } + Object.defineProperty(privateClassWithPrivateModuleGetAccessorTypes, "myPublicStaticMethod", { + get: function () { + return exporter.createExportedWidget2(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(privateClassWithPrivateModuleGetAccessorTypes.prototype, "myPublicMethod", { + get: function () { + return exporter.createExportedWidget2(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(privateClassWithPrivateModuleGetAccessorTypes, "myPublicStaticMethod1", { + get: function () { + return exporter.createExportedWidget4(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(privateClassWithPrivateModuleGetAccessorTypes.prototype, "myPublicMethod1", { + get: function () { + return exporter.createExportedWidget4(); + }, + enumerable: true, + configurable: true + }); + return privateClassWithPrivateModuleGetAccessorTypes; +})(); + + +//// [privacyCannotNameAccessorDeclFile_GlobalWidgets.d.ts] +declare module "GlobalWidgets" { + class Widget3 { + name: string; + } + function createWidget3(): Widget3; + module SpecializedGlobalWidget { + class Widget4 { + name: string; + } + function createWidget4(): Widget4; + } +} +//// [privacyCannotNameAccessorDeclFile_Widgets.d.ts] +export declare class Widget1 { + name: string; +} +export declare function createWidget1(): Widget1; +export declare module SpecializedWidget { + class Widget2 { + name: string; + } + function createWidget2(): Widget2; +} +//// [privacyCannotNameAccessorDeclFile_exporter.d.ts] +/// +import Widgets = require("privacyCannotNameAccessorDeclFile_Widgets"); +import Widgets1 = require("GlobalWidgets"); +export declare function createExportedWidget1(): Widgets.Widget1; +export declare function createExportedWidget2(): Widgets.SpecializedWidget.Widget2; +export declare function createExportedWidget3(): Widgets1.Widget3; +export declare function createExportedWidget4(): Widgets1.SpecializedGlobalWidget.Widget4; diff --git a/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.errors.txt b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.errors.txt new file mode 100644 index 00000000000..92a2f349908 --- /dev/null +++ b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.errors.txt @@ -0,0 +1,123 @@ +==== tests/cases/compiler/privacyCannotNameVarTypeDeclFile_consumer.ts (12 errors) ==== + import exporter = require("privacyCannotNameVarTypeDeclFile_exporter"); + export class publicClassWithWithPrivatePropertyTypes { + static myPublicStaticProperty = exporter.createExportedWidget1(); // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Public static property 'myPublicStaticProperty' of exported class has or is using name 'Widget1' from external module "tests/cases/compiler/privacyCannotNameVarTypeDeclFile_Widgets" but cannot be named. + private static myPrivateStaticProperty = exporter.createExportedWidget1(); + myPublicProperty = exporter.createExportedWidget1(); // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Public property 'myPublicProperty' of exported class has or is using name 'Widget1' from external module "tests/cases/compiler/privacyCannotNameVarTypeDeclFile_Widgets" but cannot be named. + private myPrivateProperty = exporter.createExportedWidget1(); + + static myPublicStaticProperty1 = exporter.createExportedWidget3(); // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Public static property 'myPublicStaticProperty1' of exported class has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. + private static myPrivateStaticProperty1 = exporter.createExportedWidget3(); + myPublicProperty1 = exporter.createExportedWidget3(); // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Public property 'myPublicProperty1' of exported class has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. + private myPrivateProperty1 = exporter.createExportedWidget3(); + } + + class privateClassWithWithPrivatePropertyTypes { + static myPublicStaticProperty = exporter.createExportedWidget1(); + private static myPrivateStaticProperty = exporter.createExportedWidget1(); + myPublicProperty = exporter.createExportedWidget1(); + private myPrivateProperty = exporter.createExportedWidget1(); + + static myPublicStaticProperty1 = exporter.createExportedWidget3(); + private static myPrivateStaticProperty1 = exporter.createExportedWidget3(); + myPublicProperty1 = exporter.createExportedWidget3(); + private myPrivateProperty1 = exporter.createExportedWidget3(); + } + + export var publicVarWithPrivatePropertyTypes= exporter.createExportedWidget1(); // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Exported variable 'publicVarWithPrivatePropertyTypes' has or is using name 'Widget1' from external module "tests/cases/compiler/privacyCannotNameVarTypeDeclFile_Widgets" but cannot be named. + var privateVarWithPrivatePropertyTypes= exporter.createExportedWidget1(); + export var publicVarWithPrivatePropertyTypes1 = exporter.createExportedWidget3(); // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Exported variable 'publicVarWithPrivatePropertyTypes1' has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. + var privateVarWithPrivatePropertyTypes1 = exporter.createExportedWidget3(); + + export class publicClassWithPrivateModulePropertyTypes { + static myPublicStaticProperty= exporter.createExportedWidget2(); // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Public static property 'myPublicStaticProperty' of exported class has or is using name 'SpecializedWidget.Widget2' from external module "tests/cases/compiler/privacyCannotNameVarTypeDeclFile_Widgets" but cannot be named. + myPublicProperty = exporter.createExportedWidget2(); // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Public property 'myPublicProperty' of exported class has or is using name 'SpecializedWidget.Widget2' from external module "tests/cases/compiler/privacyCannotNameVarTypeDeclFile_Widgets" but cannot be named. + static myPublicStaticProperty1 = exporter.createExportedWidget4(); // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Public static property 'myPublicStaticProperty1' of exported class has or is using name 'SpecializedGlobalWidget.Widget4' from external module "GlobalWidgets" but cannot be named. + myPublicProperty1 = exporter.createExportedWidget4(); // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Public property 'myPublicProperty1' of exported class has or is using name 'SpecializedGlobalWidget.Widget4' from external module "GlobalWidgets" but cannot be named. + } + export var publicVarWithPrivateModulePropertyTypes= exporter.createExportedWidget2(); // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Exported variable 'publicVarWithPrivateModulePropertyTypes' has or is using name 'SpecializedWidget.Widget2' from external module "tests/cases/compiler/privacyCannotNameVarTypeDeclFile_Widgets" but cannot be named. + export var publicVarWithPrivateModulePropertyTypes1 = exporter.createExportedWidget4(); // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Exported variable 'publicVarWithPrivateModulePropertyTypes1' has or is using name 'SpecializedGlobalWidget.Widget4' from external module "GlobalWidgets" but cannot be named. + + class privateClassWithPrivateModulePropertyTypes { + static myPublicStaticProperty= exporter.createExportedWidget2(); + myPublicProperty= exporter.createExportedWidget2(); + static myPublicStaticProperty1 = exporter.createExportedWidget4(); + myPublicProperty1 = exporter.createExportedWidget4(); + } + var privateVarWithPrivateModulePropertyTypes= exporter.createExportedWidget2(); + var privateVarWithPrivateModulePropertyTypes1 = exporter.createExportedWidget4(); +==== tests/cases/compiler/privacyCannotNameVarTypeDeclFile_GlobalWidgets.ts (0 errors) ==== + + + declare module "GlobalWidgets" { + export class Widget3 { + name: string; + } + export function createWidget3(): Widget3; + + export module SpecializedGlobalWidget { + export class Widget4 { + name: string; + } + function createWidget4(): Widget4; + } + } + +==== tests/cases/compiler/privacyCannotNameVarTypeDeclFile_Widgets.ts (0 errors) ==== + export class Widget1 { + name = 'one'; + } + export function createWidget1() { + return new Widget1(); + } + + export module SpecializedWidget { + export class Widget2 { + name = 'one'; + } + export function createWidget2() { + return new Widget2(); + } + } + +==== tests/cases/compiler/privacyCannotNameVarTypeDeclFile_exporter.ts (0 errors) ==== + /// + import Widgets = require("privacyCannotNameVarTypeDeclFile_Widgets"); + import Widgets1 = require("GlobalWidgets"); + export function createExportedWidget1() { + return Widgets.createWidget1(); + } + export function createExportedWidget2() { + return Widgets.SpecializedWidget.createWidget2(); + } + export function createExportedWidget3() { + return Widgets1.createWidget3(); + } + export function createExportedWidget4() { + return Widgets1.SpecializedGlobalWidget.createWidget4(); + } + \ No newline at end of file diff --git a/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js new file mode 100644 index 00000000000..d113b0a8095 --- /dev/null +++ b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js @@ -0,0 +1,238 @@ +//// [tests/cases/compiler/privacyCannotNameVarTypeDeclFile.ts] //// + +//// [privacyCannotNameVarTypeDeclFile_GlobalWidgets.ts] + + +declare module "GlobalWidgets" { + export class Widget3 { + name: string; + } + export function createWidget3(): Widget3; + + export module SpecializedGlobalWidget { + export class Widget4 { + name: string; + } + function createWidget4(): Widget4; + } +} + +//// [privacyCannotNameVarTypeDeclFile_Widgets.ts] +export class Widget1 { + name = 'one'; +} +export function createWidget1() { + return new Widget1(); +} + +export module SpecializedWidget { + export class Widget2 { + name = 'one'; + } + export function createWidget2() { + return new Widget2(); + } +} + +//// [privacyCannotNameVarTypeDeclFile_exporter.ts] +/// +import Widgets = require("privacyCannotNameVarTypeDeclFile_Widgets"); +import Widgets1 = require("GlobalWidgets"); +export function createExportedWidget1() { + return Widgets.createWidget1(); +} +export function createExportedWidget2() { + return Widgets.SpecializedWidget.createWidget2(); +} +export function createExportedWidget3() { + return Widgets1.createWidget3(); +} +export function createExportedWidget4() { + return Widgets1.SpecializedGlobalWidget.createWidget4(); +} + +//// [privacyCannotNameVarTypeDeclFile_consumer.ts] +import exporter = require("privacyCannotNameVarTypeDeclFile_exporter"); +export class publicClassWithWithPrivatePropertyTypes { + static myPublicStaticProperty = exporter.createExportedWidget1(); // Error + private static myPrivateStaticProperty = exporter.createExportedWidget1(); + myPublicProperty = exporter.createExportedWidget1(); // Error + private myPrivateProperty = exporter.createExportedWidget1(); + + static myPublicStaticProperty1 = exporter.createExportedWidget3(); // Error + private static myPrivateStaticProperty1 = exporter.createExportedWidget3(); + myPublicProperty1 = exporter.createExportedWidget3(); // Error + private myPrivateProperty1 = exporter.createExportedWidget3(); +} + +class privateClassWithWithPrivatePropertyTypes { + static myPublicStaticProperty = exporter.createExportedWidget1(); + private static myPrivateStaticProperty = exporter.createExportedWidget1(); + myPublicProperty = exporter.createExportedWidget1(); + private myPrivateProperty = exporter.createExportedWidget1(); + + static myPublicStaticProperty1 = exporter.createExportedWidget3(); + private static myPrivateStaticProperty1 = exporter.createExportedWidget3(); + myPublicProperty1 = exporter.createExportedWidget3(); + private myPrivateProperty1 = exporter.createExportedWidget3(); +} + +export var publicVarWithPrivatePropertyTypes= exporter.createExportedWidget1(); // Error +var privateVarWithPrivatePropertyTypes= exporter.createExportedWidget1(); +export var publicVarWithPrivatePropertyTypes1 = exporter.createExportedWidget3(); // Error +var privateVarWithPrivatePropertyTypes1 = exporter.createExportedWidget3(); + +export class publicClassWithPrivateModulePropertyTypes { + static myPublicStaticProperty= exporter.createExportedWidget2(); // Error + myPublicProperty = exporter.createExportedWidget2(); // Error + static myPublicStaticProperty1 = exporter.createExportedWidget4(); // Error + myPublicProperty1 = exporter.createExportedWidget4(); // Error +} +export var publicVarWithPrivateModulePropertyTypes= exporter.createExportedWidget2(); // Error +export var publicVarWithPrivateModulePropertyTypes1 = exporter.createExportedWidget4(); // Error + +class privateClassWithPrivateModulePropertyTypes { + static myPublicStaticProperty= exporter.createExportedWidget2(); + myPublicProperty= exporter.createExportedWidget2(); + static myPublicStaticProperty1 = exporter.createExportedWidget4(); + myPublicProperty1 = exporter.createExportedWidget4(); +} +var privateVarWithPrivateModulePropertyTypes= exporter.createExportedWidget2(); +var privateVarWithPrivateModulePropertyTypes1 = exporter.createExportedWidget4(); + +//// [privacyCannotNameVarTypeDeclFile_GlobalWidgets.js] +//// [privacyCannotNameVarTypeDeclFile_Widgets.js] +var Widget1 = (function () { + function Widget1() { + this.name = 'one'; + } + return Widget1; +})(); +exports.Widget1 = Widget1; +function createWidget1() { + return new Widget1(); +} +exports.createWidget1 = createWidget1; +(function (SpecializedWidget) { + var Widget2 = (function () { + function Widget2() { + this.name = 'one'; + } + return Widget2; + })(); + SpecializedWidget.Widget2 = Widget2; + function createWidget2() { + return new Widget2(); + } + SpecializedWidget.createWidget2 = createWidget2; +})(exports.SpecializedWidget || (exports.SpecializedWidget = {})); +var SpecializedWidget = exports.SpecializedWidget; +//// [privacyCannotNameVarTypeDeclFile_exporter.js] +var Widgets = require("privacyCannotNameVarTypeDeclFile_Widgets"); +var Widgets1 = require("GlobalWidgets"); +function createExportedWidget1() { + return Widgets.createWidget1(); +} +exports.createExportedWidget1 = createExportedWidget1; +function createExportedWidget2() { + return Widgets.SpecializedWidget.createWidget2(); +} +exports.createExportedWidget2 = createExportedWidget2; +function createExportedWidget3() { + return Widgets1.createWidget3(); +} +exports.createExportedWidget3 = createExportedWidget3; +function createExportedWidget4() { + return Widgets1.SpecializedGlobalWidget.createWidget4(); +} +exports.createExportedWidget4 = createExportedWidget4; +//// [privacyCannotNameVarTypeDeclFile_consumer.js] +var exporter = require("privacyCannotNameVarTypeDeclFile_exporter"); +var publicClassWithWithPrivatePropertyTypes = (function () { + function publicClassWithWithPrivatePropertyTypes() { + this.myPublicProperty = exporter.createExportedWidget1(); + this.myPrivateProperty = exporter.createExportedWidget1(); + this.myPublicProperty1 = exporter.createExportedWidget3(); + this.myPrivateProperty1 = exporter.createExportedWidget3(); + } + publicClassWithWithPrivatePropertyTypes.myPublicStaticProperty = exporter.createExportedWidget1(); + publicClassWithWithPrivatePropertyTypes.myPrivateStaticProperty = exporter.createExportedWidget1(); + publicClassWithWithPrivatePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget3(); + publicClassWithWithPrivatePropertyTypes.myPrivateStaticProperty1 = exporter.createExportedWidget3(); + return publicClassWithWithPrivatePropertyTypes; +})(); +exports.publicClassWithWithPrivatePropertyTypes = publicClassWithWithPrivatePropertyTypes; +var privateClassWithWithPrivatePropertyTypes = (function () { + function privateClassWithWithPrivatePropertyTypes() { + this.myPublicProperty = exporter.createExportedWidget1(); + this.myPrivateProperty = exporter.createExportedWidget1(); + this.myPublicProperty1 = exporter.createExportedWidget3(); + this.myPrivateProperty1 = exporter.createExportedWidget3(); + } + privateClassWithWithPrivatePropertyTypes.myPublicStaticProperty = exporter.createExportedWidget1(); + privateClassWithWithPrivatePropertyTypes.myPrivateStaticProperty = exporter.createExportedWidget1(); + privateClassWithWithPrivatePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget3(); + privateClassWithWithPrivatePropertyTypes.myPrivateStaticProperty1 = exporter.createExportedWidget3(); + return privateClassWithWithPrivatePropertyTypes; +})(); +exports.publicVarWithPrivatePropertyTypes = exporter.createExportedWidget1(); +var privateVarWithPrivatePropertyTypes = exporter.createExportedWidget1(); +exports.publicVarWithPrivatePropertyTypes1 = exporter.createExportedWidget3(); +var privateVarWithPrivatePropertyTypes1 = exporter.createExportedWidget3(); +var publicClassWithPrivateModulePropertyTypes = (function () { + function publicClassWithPrivateModulePropertyTypes() { + this.myPublicProperty = exporter.createExportedWidget2(); + this.myPublicProperty1 = exporter.createExportedWidget4(); + } + publicClassWithPrivateModulePropertyTypes.myPublicStaticProperty = exporter.createExportedWidget2(); + publicClassWithPrivateModulePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget4(); + return publicClassWithPrivateModulePropertyTypes; +})(); +exports.publicClassWithPrivateModulePropertyTypes = publicClassWithPrivateModulePropertyTypes; +exports.publicVarWithPrivateModulePropertyTypes = exporter.createExportedWidget2(); +exports.publicVarWithPrivateModulePropertyTypes1 = exporter.createExportedWidget4(); +var privateClassWithPrivateModulePropertyTypes = (function () { + function privateClassWithPrivateModulePropertyTypes() { + this.myPublicProperty = exporter.createExportedWidget2(); + this.myPublicProperty1 = exporter.createExportedWidget4(); + } + privateClassWithPrivateModulePropertyTypes.myPublicStaticProperty = exporter.createExportedWidget2(); + privateClassWithPrivateModulePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget4(); + return privateClassWithPrivateModulePropertyTypes; +})(); +var privateVarWithPrivateModulePropertyTypes = exporter.createExportedWidget2(); +var privateVarWithPrivateModulePropertyTypes1 = exporter.createExportedWidget4(); + + +//// [privacyCannotNameVarTypeDeclFile_GlobalWidgets.d.ts] +declare module "GlobalWidgets" { + class Widget3 { + name: string; + } + function createWidget3(): Widget3; + module SpecializedGlobalWidget { + class Widget4 { + name: string; + } + function createWidget4(): Widget4; + } +} +//// [privacyCannotNameVarTypeDeclFile_Widgets.d.ts] +export declare class Widget1 { + name: string; +} +export declare function createWidget1(): Widget1; +export declare module SpecializedWidget { + class Widget2 { + name: string; + } + function createWidget2(): Widget2; +} +//// [privacyCannotNameVarTypeDeclFile_exporter.d.ts] +/// +import Widgets = require("privacyCannotNameVarTypeDeclFile_Widgets"); +import Widgets1 = require("GlobalWidgets"); +export declare function createExportedWidget1(): Widgets.Widget1; +export declare function createExportedWidget2(): Widgets.SpecializedWidget.Widget2; +export declare function createExportedWidget3(): Widgets1.Widget3; +export declare function createExportedWidget4(): Widgets1.SpecializedGlobalWidget.Widget4; diff --git a/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.errors.txt b/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.errors.txt new file mode 100644 index 00000000000..269be5ed425 --- /dev/null +++ b/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.errors.txt @@ -0,0 +1,203 @@ +==== tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_consumer.ts (24 errors) ==== + import exporter = require("privacyFunctionCannotNameParameterTypeDeclFile_exporter"); + export class publicClassWithWithPrivateParmeterTypes { + static myPublicStaticMethod(param = exporter.createExportedWidget1()) { // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param' of public static method from exported class has or is using name 'Widget1' from external module "tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_Widgets" but cannot be named. + } + private static myPrivateStaticMethod(param = exporter.createExportedWidget1()) { + } + myPublicMethod(param = exporter.createExportedWidget1()) { // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param' of public method from exported class has or is using name 'Widget1' from external module "tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_Widgets" but cannot be named. + } + private myPrivateMethod(param = exporter.createExportedWidget1()) { + } + constructor(param = exporter.createExportedWidget1(), private param1 = exporter.createExportedWidget1(), public param2 = exporter.createExportedWidget1()) { // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param' of constructor from exported class has or is using name 'Widget1' from external module "tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_Widgets" but cannot be named. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param1' of constructor from exported class has or is using name 'Widget1' from external module "tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_Widgets" but cannot be named. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param2' of constructor from exported class has or is using name 'Widget1' from external module "tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_Widgets" but cannot be named. + } + } + export class publicClassWithWithPrivateParmeterTypes1 { + static myPublicStaticMethod(param = exporter.createExportedWidget3()) { // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param' of public static method from exported class has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. + } + private static myPrivateStaticMethod(param = exporter.createExportedWidget3()) { + } + myPublicMethod(param = exporter.createExportedWidget3()) { // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param' of public method from exported class has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. + } + private myPrivateMethod(param = exporter.createExportedWidget3()) { + } + constructor(param = exporter.createExportedWidget3(), private param1 = exporter.createExportedWidget3(), public param2 = exporter.createExportedWidget3()) { // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param' of constructor from exported class has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param1' of constructor from exported class has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param2' of constructor from exported class has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. + } + } + + class privateClassWithWithPrivateParmeterTypes { + static myPublicStaticMethod(param = exporter.createExportedWidget1()) { + } + private static myPrivateStaticMethod(param = exporter.createExportedWidget1()) { + } + myPublicMethod(param = exporter.createExportedWidget1()) { + } + private myPrivateMethod(param = exporter.createExportedWidget1()) { + } + constructor(param = exporter.createExportedWidget1(), private param1 = exporter.createExportedWidget1(), public param2 = exporter.createExportedWidget1()) { + } + } + class privateClassWithWithPrivateParmeterTypes2 { + static myPublicStaticMethod(param = exporter.createExportedWidget3()) { + } + private static myPrivateStaticMethod(param = exporter.createExportedWidget3()) { + } + myPublicMethod(param = exporter.createExportedWidget3()) { + } + private myPrivateMethod(param = exporter.createExportedWidget3()) { + } + constructor(param = exporter.createExportedWidget3(), private param1 = exporter.createExportedWidget3(), public param2 = exporter.createExportedWidget3()) { + } + } + + export function publicFunctionWithPrivateParmeterTypes(param = exporter.createExportedWidget1()) { // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param' of exported function has or is using name 'Widget1' from external module "tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_Widgets" but cannot be named. + } + function privateFunctionWithPrivateParmeterTypes(param = exporter.createExportedWidget1()) { + } + export function publicFunctionWithPrivateParmeterTypes1(param = exporter.createExportedWidget3()) { // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param' of exported function has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. + } + function privateFunctionWithPrivateParmeterTypes1(param = exporter.createExportedWidget3()) { + } + + + export class publicClassWithPrivateModuleParameterTypes { + static myPublicStaticMethod(param= exporter.createExportedWidget2()) { // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param' of public static method from exported class has or is using name 'SpecializedWidget.Widget2' from external module "tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_Widgets" but cannot be named. + } + myPublicMethod(param= exporter.createExportedWidget2()) { // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param' of public method from exported class has or is using name 'SpecializedWidget.Widget2' from external module "tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_Widgets" but cannot be named. + } + constructor(param= exporter.createExportedWidget2(), private param1= exporter.createExportedWidget2(), public param2= exporter.createExportedWidget2()) { // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param' of constructor from exported class has or is using name 'SpecializedWidget.Widget2' from external module "tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_Widgets" but cannot be named. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param1' of constructor from exported class has or is using name 'SpecializedWidget.Widget2' from external module "tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_Widgets" but cannot be named. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param2' of constructor from exported class has or is using name 'SpecializedWidget.Widget2' from external module "tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_Widgets" but cannot be named. + } + } + export class publicClassWithPrivateModuleParameterTypes2 { + static myPublicStaticMethod(param= exporter.createExportedWidget4()) { // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param' of public static method from exported class has or is using name 'SpecializedGlobalWidget.Widget4' from external module "GlobalWidgets" but cannot be named. + } + myPublicMethod(param= exporter.createExportedWidget4()) { // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param' of public method from exported class has or is using name 'SpecializedGlobalWidget.Widget4' from external module "GlobalWidgets" but cannot be named. + } + constructor(param= exporter.createExportedWidget4(), private param1= exporter.createExportedWidget4(), public param2= exporter.createExportedWidget4()) { // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param' of constructor from exported class has or is using name 'SpecializedGlobalWidget.Widget4' from external module "GlobalWidgets" but cannot be named. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param1' of constructor from exported class has or is using name 'SpecializedGlobalWidget.Widget4' from external module "GlobalWidgets" but cannot be named. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param2' of constructor from exported class has or is using name 'SpecializedGlobalWidget.Widget4' from external module "GlobalWidgets" but cannot be named. + } + } + export function publicFunctionWithPrivateModuleParameterTypes(param= exporter.createExportedWidget2()) { // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param' of exported function has or is using name 'SpecializedWidget.Widget2' from external module "tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_Widgets" but cannot be named. + } + export function publicFunctionWithPrivateModuleParameterTypes1(param= exporter.createExportedWidget4()) { // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Parameter 'param' of exported function has or is using name 'SpecializedGlobalWidget.Widget4' from external module "GlobalWidgets" but cannot be named. + } + + + class privateClassWithPrivateModuleParameterTypes { + static myPublicStaticMethod(param= exporter.createExportedWidget2()) { + } + myPublicMethod(param= exporter.createExportedWidget2()) { + } + constructor(param= exporter.createExportedWidget2(), private param1= exporter.createExportedWidget2(), public param2= exporter.createExportedWidget2()) { + } + } + class privateClassWithPrivateModuleParameterTypes1 { + static myPublicStaticMethod(param= exporter.createExportedWidget4()) { + } + myPublicMethod(param= exporter.createExportedWidget4()) { + } + constructor(param= exporter.createExportedWidget4(), private param1= exporter.createExportedWidget4(), public param2= exporter.createExportedWidget4()) { + } + } + function privateFunctionWithPrivateModuleParameterTypes(param= exporter.createExportedWidget2()) { + } + function privateFunctionWithPrivateModuleParameterTypes1(param= exporter.createExportedWidget4()) { + } +==== tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_GlobalWidgets.ts (0 errors) ==== + + + declare module "GlobalWidgets" { + export class Widget3 { + name: string; + } + export function createWidget3(): Widget3; + + export module SpecializedGlobalWidget { + export class Widget4 { + name: string; + } + function createWidget4(): Widget4; + } + } + +==== tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_Widgets.ts (0 errors) ==== + export class Widget1 { + name = 'one'; + } + export function createWidget1() { + return new Widget1(); + } + + export module SpecializedWidget { + export class Widget2 { + name = 'one'; + } + export function createWidget2() { + return new Widget2(); + } + } + +==== tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile_exporter.ts (0 errors) ==== + /// + import Widgets = require("privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); + import Widgets1 = require("GlobalWidgets"); + export function createExportedWidget1() { + return Widgets.createWidget1(); + } + export function createExportedWidget2() { + return Widgets.SpecializedWidget.createWidget2(); + } + export function createExportedWidget3() { + return Widgets1.createWidget3(); + } + export function createExportedWidget4() { + return Widgets1.SpecializedGlobalWidget.createWidget4(); + } + \ No newline at end of file diff --git a/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.js b/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.js new file mode 100644 index 00000000000..3db10b3da1a --- /dev/null +++ b/tests/baselines/reference/privacyFunctionCannotNameParameterTypeDeclFile.js @@ -0,0 +1,424 @@ +//// [tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile.ts] //// + +//// [privacyFunctionCannotNameParameterTypeDeclFile_GlobalWidgets.ts] + + +declare module "GlobalWidgets" { + export class Widget3 { + name: string; + } + export function createWidget3(): Widget3; + + export module SpecializedGlobalWidget { + export class Widget4 { + name: string; + } + function createWidget4(): Widget4; + } +} + +//// [privacyFunctionCannotNameParameterTypeDeclFile_Widgets.ts] +export class Widget1 { + name = 'one'; +} +export function createWidget1() { + return new Widget1(); +} + +export module SpecializedWidget { + export class Widget2 { + name = 'one'; + } + export function createWidget2() { + return new Widget2(); + } +} + +//// [privacyFunctionCannotNameParameterTypeDeclFile_exporter.ts] +/// +import Widgets = require("privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); +import Widgets1 = require("GlobalWidgets"); +export function createExportedWidget1() { + return Widgets.createWidget1(); +} +export function createExportedWidget2() { + return Widgets.SpecializedWidget.createWidget2(); +} +export function createExportedWidget3() { + return Widgets1.createWidget3(); +} +export function createExportedWidget4() { + return Widgets1.SpecializedGlobalWidget.createWidget4(); +} + +//// [privacyFunctionCannotNameParameterTypeDeclFile_consumer.ts] +import exporter = require("privacyFunctionCannotNameParameterTypeDeclFile_exporter"); +export class publicClassWithWithPrivateParmeterTypes { + static myPublicStaticMethod(param = exporter.createExportedWidget1()) { // Error + } + private static myPrivateStaticMethod(param = exporter.createExportedWidget1()) { + } + myPublicMethod(param = exporter.createExportedWidget1()) { // Error + } + private myPrivateMethod(param = exporter.createExportedWidget1()) { + } + constructor(param = exporter.createExportedWidget1(), private param1 = exporter.createExportedWidget1(), public param2 = exporter.createExportedWidget1()) { // Error + } +} +export class publicClassWithWithPrivateParmeterTypes1 { + static myPublicStaticMethod(param = exporter.createExportedWidget3()) { // Error + } + private static myPrivateStaticMethod(param = exporter.createExportedWidget3()) { + } + myPublicMethod(param = exporter.createExportedWidget3()) { // Error + } + private myPrivateMethod(param = exporter.createExportedWidget3()) { + } + constructor(param = exporter.createExportedWidget3(), private param1 = exporter.createExportedWidget3(), public param2 = exporter.createExportedWidget3()) { // Error + } +} + +class privateClassWithWithPrivateParmeterTypes { + static myPublicStaticMethod(param = exporter.createExportedWidget1()) { + } + private static myPrivateStaticMethod(param = exporter.createExportedWidget1()) { + } + myPublicMethod(param = exporter.createExportedWidget1()) { + } + private myPrivateMethod(param = exporter.createExportedWidget1()) { + } + constructor(param = exporter.createExportedWidget1(), private param1 = exporter.createExportedWidget1(), public param2 = exporter.createExportedWidget1()) { + } +} +class privateClassWithWithPrivateParmeterTypes2 { + static myPublicStaticMethod(param = exporter.createExportedWidget3()) { + } + private static myPrivateStaticMethod(param = exporter.createExportedWidget3()) { + } + myPublicMethod(param = exporter.createExportedWidget3()) { + } + private myPrivateMethod(param = exporter.createExportedWidget3()) { + } + constructor(param = exporter.createExportedWidget3(), private param1 = exporter.createExportedWidget3(), public param2 = exporter.createExportedWidget3()) { + } +} + +export function publicFunctionWithPrivateParmeterTypes(param = exporter.createExportedWidget1()) { // Error +} +function privateFunctionWithPrivateParmeterTypes(param = exporter.createExportedWidget1()) { +} +export function publicFunctionWithPrivateParmeterTypes1(param = exporter.createExportedWidget3()) { // Error +} +function privateFunctionWithPrivateParmeterTypes1(param = exporter.createExportedWidget3()) { +} + + +export class publicClassWithPrivateModuleParameterTypes { + static myPublicStaticMethod(param= exporter.createExportedWidget2()) { // Error + } + myPublicMethod(param= exporter.createExportedWidget2()) { // Error + } + constructor(param= exporter.createExportedWidget2(), private param1= exporter.createExportedWidget2(), public param2= exporter.createExportedWidget2()) { // Error + } +} +export class publicClassWithPrivateModuleParameterTypes2 { + static myPublicStaticMethod(param= exporter.createExportedWidget4()) { // Error + } + myPublicMethod(param= exporter.createExportedWidget4()) { // Error + } + constructor(param= exporter.createExportedWidget4(), private param1= exporter.createExportedWidget4(), public param2= exporter.createExportedWidget4()) { // Error + } +} +export function publicFunctionWithPrivateModuleParameterTypes(param= exporter.createExportedWidget2()) { // Error +} +export function publicFunctionWithPrivateModuleParameterTypes1(param= exporter.createExportedWidget4()) { // Error +} + + +class privateClassWithPrivateModuleParameterTypes { + static myPublicStaticMethod(param= exporter.createExportedWidget2()) { + } + myPublicMethod(param= exporter.createExportedWidget2()) { + } + constructor(param= exporter.createExportedWidget2(), private param1= exporter.createExportedWidget2(), public param2= exporter.createExportedWidget2()) { + } +} +class privateClassWithPrivateModuleParameterTypes1 { + static myPublicStaticMethod(param= exporter.createExportedWidget4()) { + } + myPublicMethod(param= exporter.createExportedWidget4()) { + } + constructor(param= exporter.createExportedWidget4(), private param1= exporter.createExportedWidget4(), public param2= exporter.createExportedWidget4()) { + } +} +function privateFunctionWithPrivateModuleParameterTypes(param= exporter.createExportedWidget2()) { +} +function privateFunctionWithPrivateModuleParameterTypes1(param= exporter.createExportedWidget4()) { +} + +//// [privacyFunctionCannotNameParameterTypeDeclFile_GlobalWidgets.js] +//// [privacyFunctionCannotNameParameterTypeDeclFile_Widgets.js] +var Widget1 = (function () { + function Widget1() { + this.name = 'one'; + } + return Widget1; +})(); +exports.Widget1 = Widget1; +function createWidget1() { + return new Widget1(); +} +exports.createWidget1 = createWidget1; +(function (SpecializedWidget) { + var Widget2 = (function () { + function Widget2() { + this.name = 'one'; + } + return Widget2; + })(); + SpecializedWidget.Widget2 = Widget2; + function createWidget2() { + return new Widget2(); + } + SpecializedWidget.createWidget2 = createWidget2; +})(exports.SpecializedWidget || (exports.SpecializedWidget = {})); +var SpecializedWidget = exports.SpecializedWidget; +//// [privacyFunctionCannotNameParameterTypeDeclFile_exporter.js] +var Widgets = require("privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); +var Widgets1 = require("GlobalWidgets"); +function createExportedWidget1() { + return Widgets.createWidget1(); +} +exports.createExportedWidget1 = createExportedWidget1; +function createExportedWidget2() { + return Widgets.SpecializedWidget.createWidget2(); +} +exports.createExportedWidget2 = createExportedWidget2; +function createExportedWidget3() { + return Widgets1.createWidget3(); +} +exports.createExportedWidget3 = createExportedWidget3; +function createExportedWidget4() { + return Widgets1.SpecializedGlobalWidget.createWidget4(); +} +exports.createExportedWidget4 = createExportedWidget4; +//// [privacyFunctionCannotNameParameterTypeDeclFile_consumer.js] +var exporter = require("privacyFunctionCannotNameParameterTypeDeclFile_exporter"); +var publicClassWithWithPrivateParmeterTypes = (function () { + function publicClassWithWithPrivateParmeterTypes(param, param1, param2) { + if (param === void 0) { param = exporter.createExportedWidget1(); } + if (param1 === void 0) { param1 = exporter.createExportedWidget1(); } + if (param2 === void 0) { param2 = exporter.createExportedWidget1(); } + this.param1 = param1; + this.param2 = param2; + } + publicClassWithWithPrivateParmeterTypes.myPublicStaticMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget1(); } + }; + publicClassWithWithPrivateParmeterTypes.myPrivateStaticMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget1(); } + }; + publicClassWithWithPrivateParmeterTypes.prototype.myPublicMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget1(); } + }; + publicClassWithWithPrivateParmeterTypes.prototype.myPrivateMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget1(); } + }; + return publicClassWithWithPrivateParmeterTypes; +})(); +exports.publicClassWithWithPrivateParmeterTypes = publicClassWithWithPrivateParmeterTypes; +var publicClassWithWithPrivateParmeterTypes1 = (function () { + function publicClassWithWithPrivateParmeterTypes1(param, param1, param2) { + if (param === void 0) { param = exporter.createExportedWidget3(); } + if (param1 === void 0) { param1 = exporter.createExportedWidget3(); } + if (param2 === void 0) { param2 = exporter.createExportedWidget3(); } + this.param1 = param1; + this.param2 = param2; + } + publicClassWithWithPrivateParmeterTypes1.myPublicStaticMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget3(); } + }; + publicClassWithWithPrivateParmeterTypes1.myPrivateStaticMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget3(); } + }; + publicClassWithWithPrivateParmeterTypes1.prototype.myPublicMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget3(); } + }; + publicClassWithWithPrivateParmeterTypes1.prototype.myPrivateMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget3(); } + }; + return publicClassWithWithPrivateParmeterTypes1; +})(); +exports.publicClassWithWithPrivateParmeterTypes1 = publicClassWithWithPrivateParmeterTypes1; +var privateClassWithWithPrivateParmeterTypes = (function () { + function privateClassWithWithPrivateParmeterTypes(param, param1, param2) { + if (param === void 0) { param = exporter.createExportedWidget1(); } + if (param1 === void 0) { param1 = exporter.createExportedWidget1(); } + if (param2 === void 0) { param2 = exporter.createExportedWidget1(); } + this.param1 = param1; + this.param2 = param2; + } + privateClassWithWithPrivateParmeterTypes.myPublicStaticMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget1(); } + }; + privateClassWithWithPrivateParmeterTypes.myPrivateStaticMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget1(); } + }; + privateClassWithWithPrivateParmeterTypes.prototype.myPublicMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget1(); } + }; + privateClassWithWithPrivateParmeterTypes.prototype.myPrivateMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget1(); } + }; + return privateClassWithWithPrivateParmeterTypes; +})(); +var privateClassWithWithPrivateParmeterTypes2 = (function () { + function privateClassWithWithPrivateParmeterTypes2(param, param1, param2) { + if (param === void 0) { param = exporter.createExportedWidget3(); } + if (param1 === void 0) { param1 = exporter.createExportedWidget3(); } + if (param2 === void 0) { param2 = exporter.createExportedWidget3(); } + this.param1 = param1; + this.param2 = param2; + } + privateClassWithWithPrivateParmeterTypes2.myPublicStaticMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget3(); } + }; + privateClassWithWithPrivateParmeterTypes2.myPrivateStaticMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget3(); } + }; + privateClassWithWithPrivateParmeterTypes2.prototype.myPublicMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget3(); } + }; + privateClassWithWithPrivateParmeterTypes2.prototype.myPrivateMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget3(); } + }; + return privateClassWithWithPrivateParmeterTypes2; +})(); +function publicFunctionWithPrivateParmeterTypes(param) { + if (param === void 0) { param = exporter.createExportedWidget1(); } +} +exports.publicFunctionWithPrivateParmeterTypes = publicFunctionWithPrivateParmeterTypes; +function privateFunctionWithPrivateParmeterTypes(param) { + if (param === void 0) { param = exporter.createExportedWidget1(); } +} +function publicFunctionWithPrivateParmeterTypes1(param) { + if (param === void 0) { param = exporter.createExportedWidget3(); } +} +exports.publicFunctionWithPrivateParmeterTypes1 = publicFunctionWithPrivateParmeterTypes1; +function privateFunctionWithPrivateParmeterTypes1(param) { + if (param === void 0) { param = exporter.createExportedWidget3(); } +} +var publicClassWithPrivateModuleParameterTypes = (function () { + function publicClassWithPrivateModuleParameterTypes(param, param1, param2) { + if (param === void 0) { param = exporter.createExportedWidget2(); } + if (param1 === void 0) { param1 = exporter.createExportedWidget2(); } + if (param2 === void 0) { param2 = exporter.createExportedWidget2(); } + this.param1 = param1; + this.param2 = param2; + } + publicClassWithPrivateModuleParameterTypes.myPublicStaticMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget2(); } + }; + publicClassWithPrivateModuleParameterTypes.prototype.myPublicMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget2(); } + }; + return publicClassWithPrivateModuleParameterTypes; +})(); +exports.publicClassWithPrivateModuleParameterTypes = publicClassWithPrivateModuleParameterTypes; +var publicClassWithPrivateModuleParameterTypes2 = (function () { + function publicClassWithPrivateModuleParameterTypes2(param, param1, param2) { + if (param === void 0) { param = exporter.createExportedWidget4(); } + if (param1 === void 0) { param1 = exporter.createExportedWidget4(); } + if (param2 === void 0) { param2 = exporter.createExportedWidget4(); } + this.param1 = param1; + this.param2 = param2; + } + publicClassWithPrivateModuleParameterTypes2.myPublicStaticMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget4(); } + }; + publicClassWithPrivateModuleParameterTypes2.prototype.myPublicMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget4(); } + }; + return publicClassWithPrivateModuleParameterTypes2; +})(); +exports.publicClassWithPrivateModuleParameterTypes2 = publicClassWithPrivateModuleParameterTypes2; +function publicFunctionWithPrivateModuleParameterTypes(param) { + if (param === void 0) { param = exporter.createExportedWidget2(); } +} +exports.publicFunctionWithPrivateModuleParameterTypes = publicFunctionWithPrivateModuleParameterTypes; +function publicFunctionWithPrivateModuleParameterTypes1(param) { + if (param === void 0) { param = exporter.createExportedWidget4(); } +} +exports.publicFunctionWithPrivateModuleParameterTypes1 = publicFunctionWithPrivateModuleParameterTypes1; +var privateClassWithPrivateModuleParameterTypes = (function () { + function privateClassWithPrivateModuleParameterTypes(param, param1, param2) { + if (param === void 0) { param = exporter.createExportedWidget2(); } + if (param1 === void 0) { param1 = exporter.createExportedWidget2(); } + if (param2 === void 0) { param2 = exporter.createExportedWidget2(); } + this.param1 = param1; + this.param2 = param2; + } + privateClassWithPrivateModuleParameterTypes.myPublicStaticMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget2(); } + }; + privateClassWithPrivateModuleParameterTypes.prototype.myPublicMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget2(); } + }; + return privateClassWithPrivateModuleParameterTypes; +})(); +var privateClassWithPrivateModuleParameterTypes1 = (function () { + function privateClassWithPrivateModuleParameterTypes1(param, param1, param2) { + if (param === void 0) { param = exporter.createExportedWidget4(); } + if (param1 === void 0) { param1 = exporter.createExportedWidget4(); } + if (param2 === void 0) { param2 = exporter.createExportedWidget4(); } + this.param1 = param1; + this.param2 = param2; + } + privateClassWithPrivateModuleParameterTypes1.myPublicStaticMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget4(); } + }; + privateClassWithPrivateModuleParameterTypes1.prototype.myPublicMethod = function (param) { + if (param === void 0) { param = exporter.createExportedWidget4(); } + }; + return privateClassWithPrivateModuleParameterTypes1; +})(); +function privateFunctionWithPrivateModuleParameterTypes(param) { + if (param === void 0) { param = exporter.createExportedWidget2(); } +} +function privateFunctionWithPrivateModuleParameterTypes1(param) { + if (param === void 0) { param = exporter.createExportedWidget4(); } +} + + +//// [privacyFunctionCannotNameParameterTypeDeclFile_GlobalWidgets.d.ts] +declare module "GlobalWidgets" { + class Widget3 { + name: string; + } + function createWidget3(): Widget3; + module SpecializedGlobalWidget { + class Widget4 { + name: string; + } + function createWidget4(): Widget4; + } +} +//// [privacyFunctionCannotNameParameterTypeDeclFile_Widgets.d.ts] +export declare class Widget1 { + name: string; +} +export declare function createWidget1(): Widget1; +export declare module SpecializedWidget { + class Widget2 { + name: string; + } + function createWidget2(): Widget2; +} +//// [privacyFunctionCannotNameParameterTypeDeclFile_exporter.d.ts] +/// +import Widgets = require("privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); +import Widgets1 = require("GlobalWidgets"); +export declare function createExportedWidget1(): Widgets.Widget1; +export declare function createExportedWidget2(): Widgets.SpecializedWidget.Widget2; +export declare function createExportedWidget3(): Widgets1.Widget3; +export declare function createExportedWidget4(): Widgets1.SpecializedGlobalWidget.Widget4; diff --git a/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.errors.txt b/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.errors.txt new file mode 100644 index 00000000000..834e3d783c6 --- /dev/null +++ b/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.errors.txt @@ -0,0 +1,186 @@ +==== tests/cases/compiler/privacyFunctionReturnTypeDeclFile_consumer.ts (12 errors) ==== + import exporter = require("privacyFunctionReturnTypeDeclFile_exporter"); + export class publicClassWithWithPrivateParmeterTypes { + static myPublicStaticMethod() { // Error + ~~~~~~~~~~~~~~~~~~~~ +!!! Return type of public static method from exported class has or is using name 'Widget1' from external module "tests/cases/compiler/privacyFunctionReturnTypeDeclFile_Widgets" but cannot be named. + return exporter.createExportedWidget1(); + } + private static myPrivateStaticMethod() { + return exporter.createExportedWidget1();; + } + myPublicMethod() { // Error + ~~~~~~~~~~~~~~ +!!! Return type of public method from exported class has or is using name 'Widget1' from external module "tests/cases/compiler/privacyFunctionReturnTypeDeclFile_Widgets" but cannot be named. + return exporter.createExportedWidget1();; + } + private myPrivateMethod() { + return exporter.createExportedWidget1();; + } + static myPublicStaticMethod1() { // Error + ~~~~~~~~~~~~~~~~~~~~~ +!!! Return type of public static method from exported class has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. + return exporter.createExportedWidget3(); + } + private static myPrivateStaticMethod1() { + return exporter.createExportedWidget3();; + } + myPublicMethod1() { // Error + ~~~~~~~~~~~~~~~ +!!! Return type of public method from exported class has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. + return exporter.createExportedWidget3();; + } + private myPrivateMethod1() { + return exporter.createExportedWidget3();; + } + } + + class privateClassWithWithPrivateParmeterTypes { + static myPublicStaticMethod() { + return exporter.createExportedWidget1(); + } + private static myPrivateStaticMethod() { + return exporter.createExportedWidget1();; + } + myPublicMethod() { + return exporter.createExportedWidget1();; + } + private myPrivateMethod() { + return exporter.createExportedWidget1();; + } + static myPublicStaticMethod1() { + return exporter.createExportedWidget3(); + } + private static myPrivateStaticMethod1() { + return exporter.createExportedWidget3();; + } + myPublicMethod1() { + return exporter.createExportedWidget3();; + } + private myPrivateMethod1() { + return exporter.createExportedWidget3();; + } + } + + export function publicFunctionWithPrivateParmeterTypes() { // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Return type of exported function has or is using name 'Widget1' from external module "tests/cases/compiler/privacyFunctionReturnTypeDeclFile_Widgets" but cannot be named. + return exporter.createExportedWidget1(); + } + function privateFunctionWithPrivateParmeterTypes() { + return exporter.createExportedWidget1(); + } + export function publicFunctionWithPrivateParmeterTypes1() { // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Return type of exported function has or is using name 'Widget3' from external module "GlobalWidgets" but cannot be named. + return exporter.createExportedWidget3(); + } + function privateFunctionWithPrivateParmeterTypes1() { + return exporter.createExportedWidget3(); + } + + export class publicClassWithPrivateModuleReturnTypes { + static myPublicStaticMethod() { // Error + ~~~~~~~~~~~~~~~~~~~~ +!!! Return type of public static method from exported class has or is using name 'SpecializedWidget.Widget2' from external module "tests/cases/compiler/privacyFunctionReturnTypeDeclFile_Widgets" but cannot be named. + return exporter.createExportedWidget2(); + } + myPublicMethod() { // Error + ~~~~~~~~~~~~~~ +!!! Return type of public method from exported class has or is using name 'SpecializedWidget.Widget2' from external module "tests/cases/compiler/privacyFunctionReturnTypeDeclFile_Widgets" but cannot be named. + return exporter.createExportedWidget2(); + } + static myPublicStaticMethod1() { // Error + ~~~~~~~~~~~~~~~~~~~~~ +!!! Return type of public static method from exported class has or is using name 'SpecializedGlobalWidget.Widget4' from external module "GlobalWidgets" but cannot be named. + return exporter.createExportedWidget4(); + } + myPublicMethod1() { // Error + ~~~~~~~~~~~~~~~ +!!! Return type of public method from exported class has or is using name 'SpecializedGlobalWidget.Widget4' from external module "GlobalWidgets" but cannot be named. + return exporter.createExportedWidget4(); + } + } + export function publicFunctionWithPrivateModuleReturnTypes() { // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Return type of exported function has or is using name 'SpecializedWidget.Widget2' from external module "tests/cases/compiler/privacyFunctionReturnTypeDeclFile_Widgets" but cannot be named. + return exporter.createExportedWidget2(); + } + export function publicFunctionWithPrivateModuleReturnTypes1() { // Error + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! Return type of exported function has or is using name 'SpecializedGlobalWidget.Widget4' from external module "GlobalWidgets" but cannot be named. + return exporter.createExportedWidget4(); + } + + class privateClassWithPrivateModuleReturnTypes { + static myPublicStaticMethod() { + return exporter.createExportedWidget2(); + } + myPublicMethod() { + return exporter.createExportedWidget2(); + } + static myPublicStaticMethod1() { // Error + return exporter.createExportedWidget4(); + } + myPublicMethod1() { // Error + return exporter.createExportedWidget4(); + } + } + function privateFunctionWithPrivateModuleReturnTypes() { + return exporter.createExportedWidget2(); + } + function privateFunctionWithPrivateModuleReturnTypes1() { + return exporter.createExportedWidget4(); + } + +==== tests/cases/compiler/privacyFunctionReturnTypeDeclFile_GlobalWidgets.ts (0 errors) ==== + + + declare module "GlobalWidgets" { + export class Widget3 { + name: string; + } + export function createWidget3(): Widget3; + + export module SpecializedGlobalWidget { + export class Widget4 { + name: string; + } + function createWidget4(): Widget4; + } + } + +==== tests/cases/compiler/privacyFunctionReturnTypeDeclFile_Widgets.ts (0 errors) ==== + export class Widget1 { + name = 'one'; + } + export function createWidget1() { + return new Widget1(); + } + + export module SpecializedWidget { + export class Widget2 { + name = 'one'; + } + export function createWidget2() { + return new Widget2(); + } + } + +==== tests/cases/compiler/privacyFunctionReturnTypeDeclFile_exporter.ts (0 errors) ==== + /// + import Widgets = require("privacyFunctionReturnTypeDeclFile_Widgets"); + import Widgets1 = require("GlobalWidgets"); + export function createExportedWidget1() { + return Widgets.createWidget1(); + } + export function createExportedWidget2() { + return Widgets.SpecializedWidget.createWidget2(); + } + export function createExportedWidget3() { + return Widgets1.createWidget3(); + } + export function createExportedWidget4() { + return Widgets1.SpecializedGlobalWidget.createWidget4(); + } + \ No newline at end of file diff --git a/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.js b/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.js new file mode 100644 index 00000000000..603a51467e8 --- /dev/null +++ b/tests/baselines/reference/privacyFunctionCannotNameReturnTypeDeclFile.js @@ -0,0 +1,381 @@ +//// [tests/cases/compiler/privacyFunctionCannotNameReturnTypeDeclFile.ts] //// + +//// [privacyFunctionReturnTypeDeclFile_GlobalWidgets.ts] + + +declare module "GlobalWidgets" { + export class Widget3 { + name: string; + } + export function createWidget3(): Widget3; + + export module SpecializedGlobalWidget { + export class Widget4 { + name: string; + } + function createWidget4(): Widget4; + } +} + +//// [privacyFunctionReturnTypeDeclFile_Widgets.ts] +export class Widget1 { + name = 'one'; +} +export function createWidget1() { + return new Widget1(); +} + +export module SpecializedWidget { + export class Widget2 { + name = 'one'; + } + export function createWidget2() { + return new Widget2(); + } +} + +//// [privacyFunctionReturnTypeDeclFile_exporter.ts] +/// +import Widgets = require("privacyFunctionReturnTypeDeclFile_Widgets"); +import Widgets1 = require("GlobalWidgets"); +export function createExportedWidget1() { + return Widgets.createWidget1(); +} +export function createExportedWidget2() { + return Widgets.SpecializedWidget.createWidget2(); +} +export function createExportedWidget3() { + return Widgets1.createWidget3(); +} +export function createExportedWidget4() { + return Widgets1.SpecializedGlobalWidget.createWidget4(); +} + +//// [privacyFunctionReturnTypeDeclFile_consumer.ts] +import exporter = require("privacyFunctionReturnTypeDeclFile_exporter"); +export class publicClassWithWithPrivateParmeterTypes { + static myPublicStaticMethod() { // Error + return exporter.createExportedWidget1(); + } + private static myPrivateStaticMethod() { + return exporter.createExportedWidget1();; + } + myPublicMethod() { // Error + return exporter.createExportedWidget1();; + } + private myPrivateMethod() { + return exporter.createExportedWidget1();; + } + static myPublicStaticMethod1() { // Error + return exporter.createExportedWidget3(); + } + private static myPrivateStaticMethod1() { + return exporter.createExportedWidget3();; + } + myPublicMethod1() { // Error + return exporter.createExportedWidget3();; + } + private myPrivateMethod1() { + return exporter.createExportedWidget3();; + } +} + +class privateClassWithWithPrivateParmeterTypes { + static myPublicStaticMethod() { + return exporter.createExportedWidget1(); + } + private static myPrivateStaticMethod() { + return exporter.createExportedWidget1();; + } + myPublicMethod() { + return exporter.createExportedWidget1();; + } + private myPrivateMethod() { + return exporter.createExportedWidget1();; + } + static myPublicStaticMethod1() { + return exporter.createExportedWidget3(); + } + private static myPrivateStaticMethod1() { + return exporter.createExportedWidget3();; + } + myPublicMethod1() { + return exporter.createExportedWidget3();; + } + private myPrivateMethod1() { + return exporter.createExportedWidget3();; + } +} + +export function publicFunctionWithPrivateParmeterTypes() { // Error + return exporter.createExportedWidget1(); +} +function privateFunctionWithPrivateParmeterTypes() { + return exporter.createExportedWidget1(); +} +export function publicFunctionWithPrivateParmeterTypes1() { // Error + return exporter.createExportedWidget3(); +} +function privateFunctionWithPrivateParmeterTypes1() { + return exporter.createExportedWidget3(); +} + +export class publicClassWithPrivateModuleReturnTypes { + static myPublicStaticMethod() { // Error + return exporter.createExportedWidget2(); + } + myPublicMethod() { // Error + return exporter.createExportedWidget2(); + } + static myPublicStaticMethod1() { // Error + return exporter.createExportedWidget4(); + } + myPublicMethod1() { // Error + return exporter.createExportedWidget4(); + } +} +export function publicFunctionWithPrivateModuleReturnTypes() { // Error + return exporter.createExportedWidget2(); +} +export function publicFunctionWithPrivateModuleReturnTypes1() { // Error + return exporter.createExportedWidget4(); +} + +class privateClassWithPrivateModuleReturnTypes { + static myPublicStaticMethod() { + return exporter.createExportedWidget2(); + } + myPublicMethod() { + return exporter.createExportedWidget2(); + } + static myPublicStaticMethod1() { // Error + return exporter.createExportedWidget4(); + } + myPublicMethod1() { // Error + return exporter.createExportedWidget4(); + } +} +function privateFunctionWithPrivateModuleReturnTypes() { + return exporter.createExportedWidget2(); +} +function privateFunctionWithPrivateModuleReturnTypes1() { + return exporter.createExportedWidget4(); +} + + +//// [privacyFunctionReturnTypeDeclFile_GlobalWidgets.js] +//// [privacyFunctionReturnTypeDeclFile_Widgets.js] +var Widget1 = (function () { + function Widget1() { + this.name = 'one'; + } + return Widget1; +})(); +exports.Widget1 = Widget1; +function createWidget1() { + return new Widget1(); +} +exports.createWidget1 = createWidget1; +(function (SpecializedWidget) { + var Widget2 = (function () { + function Widget2() { + this.name = 'one'; + } + return Widget2; + })(); + SpecializedWidget.Widget2 = Widget2; + function createWidget2() { + return new Widget2(); + } + SpecializedWidget.createWidget2 = createWidget2; +})(exports.SpecializedWidget || (exports.SpecializedWidget = {})); +var SpecializedWidget = exports.SpecializedWidget; +//// [privacyFunctionReturnTypeDeclFile_exporter.js] +var Widgets = require("privacyFunctionReturnTypeDeclFile_Widgets"); +var Widgets1 = require("GlobalWidgets"); +function createExportedWidget1() { + return Widgets.createWidget1(); +} +exports.createExportedWidget1 = createExportedWidget1; +function createExportedWidget2() { + return Widgets.SpecializedWidget.createWidget2(); +} +exports.createExportedWidget2 = createExportedWidget2; +function createExportedWidget3() { + return Widgets1.createWidget3(); +} +exports.createExportedWidget3 = createExportedWidget3; +function createExportedWidget4() { + return Widgets1.SpecializedGlobalWidget.createWidget4(); +} +exports.createExportedWidget4 = createExportedWidget4; +//// [privacyFunctionReturnTypeDeclFile_consumer.js] +var exporter = require("privacyFunctionReturnTypeDeclFile_exporter"); +var publicClassWithWithPrivateParmeterTypes = (function () { + function publicClassWithWithPrivateParmeterTypes() { + } + publicClassWithWithPrivateParmeterTypes.myPublicStaticMethod = function () { + return exporter.createExportedWidget1(); + }; + publicClassWithWithPrivateParmeterTypes.myPrivateStaticMethod = function () { + return exporter.createExportedWidget1(); + ; + }; + publicClassWithWithPrivateParmeterTypes.prototype.myPublicMethod = function () { + return exporter.createExportedWidget1(); + ; + }; + publicClassWithWithPrivateParmeterTypes.prototype.myPrivateMethod = function () { + return exporter.createExportedWidget1(); + ; + }; + publicClassWithWithPrivateParmeterTypes.myPublicStaticMethod1 = function () { + return exporter.createExportedWidget3(); + }; + publicClassWithWithPrivateParmeterTypes.myPrivateStaticMethod1 = function () { + return exporter.createExportedWidget3(); + ; + }; + publicClassWithWithPrivateParmeterTypes.prototype.myPublicMethod1 = function () { + return exporter.createExportedWidget3(); + ; + }; + publicClassWithWithPrivateParmeterTypes.prototype.myPrivateMethod1 = function () { + return exporter.createExportedWidget3(); + ; + }; + return publicClassWithWithPrivateParmeterTypes; +})(); +exports.publicClassWithWithPrivateParmeterTypes = publicClassWithWithPrivateParmeterTypes; +var privateClassWithWithPrivateParmeterTypes = (function () { + function privateClassWithWithPrivateParmeterTypes() { + } + privateClassWithWithPrivateParmeterTypes.myPublicStaticMethod = function () { + return exporter.createExportedWidget1(); + }; + privateClassWithWithPrivateParmeterTypes.myPrivateStaticMethod = function () { + return exporter.createExportedWidget1(); + ; + }; + privateClassWithWithPrivateParmeterTypes.prototype.myPublicMethod = function () { + return exporter.createExportedWidget1(); + ; + }; + privateClassWithWithPrivateParmeterTypes.prototype.myPrivateMethod = function () { + return exporter.createExportedWidget1(); + ; + }; + privateClassWithWithPrivateParmeterTypes.myPublicStaticMethod1 = function () { + return exporter.createExportedWidget3(); + }; + privateClassWithWithPrivateParmeterTypes.myPrivateStaticMethod1 = function () { + return exporter.createExportedWidget3(); + ; + }; + privateClassWithWithPrivateParmeterTypes.prototype.myPublicMethod1 = function () { + return exporter.createExportedWidget3(); + ; + }; + privateClassWithWithPrivateParmeterTypes.prototype.myPrivateMethod1 = function () { + return exporter.createExportedWidget3(); + ; + }; + return privateClassWithWithPrivateParmeterTypes; +})(); +function publicFunctionWithPrivateParmeterTypes() { + return exporter.createExportedWidget1(); +} +exports.publicFunctionWithPrivateParmeterTypes = publicFunctionWithPrivateParmeterTypes; +function privateFunctionWithPrivateParmeterTypes() { + return exporter.createExportedWidget1(); +} +function publicFunctionWithPrivateParmeterTypes1() { + return exporter.createExportedWidget3(); +} +exports.publicFunctionWithPrivateParmeterTypes1 = publicFunctionWithPrivateParmeterTypes1; +function privateFunctionWithPrivateParmeterTypes1() { + return exporter.createExportedWidget3(); +} +var publicClassWithPrivateModuleReturnTypes = (function () { + function publicClassWithPrivateModuleReturnTypes() { + } + publicClassWithPrivateModuleReturnTypes.myPublicStaticMethod = function () { + return exporter.createExportedWidget2(); + }; + publicClassWithPrivateModuleReturnTypes.prototype.myPublicMethod = function () { + return exporter.createExportedWidget2(); + }; + publicClassWithPrivateModuleReturnTypes.myPublicStaticMethod1 = function () { + return exporter.createExportedWidget4(); + }; + publicClassWithPrivateModuleReturnTypes.prototype.myPublicMethod1 = function () { + return exporter.createExportedWidget4(); + }; + return publicClassWithPrivateModuleReturnTypes; +})(); +exports.publicClassWithPrivateModuleReturnTypes = publicClassWithPrivateModuleReturnTypes; +function publicFunctionWithPrivateModuleReturnTypes() { + return exporter.createExportedWidget2(); +} +exports.publicFunctionWithPrivateModuleReturnTypes = publicFunctionWithPrivateModuleReturnTypes; +function publicFunctionWithPrivateModuleReturnTypes1() { + return exporter.createExportedWidget4(); +} +exports.publicFunctionWithPrivateModuleReturnTypes1 = publicFunctionWithPrivateModuleReturnTypes1; +var privateClassWithPrivateModuleReturnTypes = (function () { + function privateClassWithPrivateModuleReturnTypes() { + } + privateClassWithPrivateModuleReturnTypes.myPublicStaticMethod = function () { + return exporter.createExportedWidget2(); + }; + privateClassWithPrivateModuleReturnTypes.prototype.myPublicMethod = function () { + return exporter.createExportedWidget2(); + }; + privateClassWithPrivateModuleReturnTypes.myPublicStaticMethod1 = function () { + return exporter.createExportedWidget4(); + }; + privateClassWithPrivateModuleReturnTypes.prototype.myPublicMethod1 = function () { + return exporter.createExportedWidget4(); + }; + return privateClassWithPrivateModuleReturnTypes; +})(); +function privateFunctionWithPrivateModuleReturnTypes() { + return exporter.createExportedWidget2(); +} +function privateFunctionWithPrivateModuleReturnTypes1() { + return exporter.createExportedWidget4(); +} + + +//// [privacyFunctionReturnTypeDeclFile_GlobalWidgets.d.ts] +declare module "GlobalWidgets" { + class Widget3 { + name: string; + } + function createWidget3(): Widget3; + module SpecializedGlobalWidget { + class Widget4 { + name: string; + } + function createWidget4(): Widget4; + } +} +//// [privacyFunctionReturnTypeDeclFile_Widgets.d.ts] +export declare class Widget1 { + name: string; +} +export declare function createWidget1(): Widget1; +export declare module SpecializedWidget { + class Widget2 { + name: string; + } + function createWidget2(): Widget2; +} +//// [privacyFunctionReturnTypeDeclFile_exporter.d.ts] +/// +import Widgets = require("privacyFunctionReturnTypeDeclFile_Widgets"); +import Widgets1 = require("GlobalWidgets"); +export declare function createExportedWidget1(): Widgets.Widget1; +export declare function createExportedWidget2(): Widgets.SpecializedWidget.Widget2; +export declare function createExportedWidget3(): Widgets1.Widget3; +export declare function createExportedWidget4(): Widgets1.SpecializedGlobalWidget.Widget4; diff --git a/tests/cases/compiler/privacyCannotNameAccessorDeclFile.ts b/tests/cases/compiler/privacyCannotNameAccessorDeclFile.ts new file mode 100644 index 00000000000..1150cf963bf --- /dev/null +++ b/tests/cases/compiler/privacyCannotNameAccessorDeclFile.ts @@ -0,0 +1,138 @@ +// @target: ES5 +// @module: commonjs +// @declaration: true + +// @Filename: privacyCannotNameAccessorDeclFile_GlobalWidgets.ts +declare module "GlobalWidgets" { + export class Widget3 { + name: string; + } + export function createWidget3(): Widget3; + + export module SpecializedGlobalWidget { + export class Widget4 { + name: string; + } + function createWidget4(): Widget4; + } +} + +// @Filename: privacyCannotNameAccessorDeclFile_Widgets.ts +export class Widget1 { + name = 'one'; +} +export function createWidget1() { + return new Widget1(); +} + +export module SpecializedWidget { + export class Widget2 { + name = 'one'; + } + export function createWidget2() { + return new Widget2(); + } +} + +// @Filename:privacyCannotNameAccessorDeclFile_exporter.ts +/// +import Widgets = require("privacyCannotNameAccessorDeclFile_Widgets"); +import Widgets1 = require("GlobalWidgets"); +export function createExportedWidget1() { + return Widgets.createWidget1(); +} +export function createExportedWidget2() { + return Widgets.SpecializedWidget.createWidget2(); +} +export function createExportedWidget3() { + return Widgets1.createWidget3(); +} +export function createExportedWidget4() { + return Widgets1.SpecializedGlobalWidget.createWidget4(); +} + +// @Filename:privacyCannotNameAccessorDeclFile_consumer.ts +import exporter = require("privacyCannotNameAccessorDeclFile_exporter"); +export class publicClassWithWithPrivateGetAccessorTypes { + static get myPublicStaticMethod() { // Error + return exporter.createExportedWidget1(); + } + private static get myPrivateStaticMethod() { + return exporter.createExportedWidget1(); + } + get myPublicMethod() { // Error + return exporter.createExportedWidget1(); + } + private get myPrivateMethod() { + return exporter.createExportedWidget1(); + } + static get myPublicStaticMethod1() { // Error + return exporter.createExportedWidget3(); + } + private static get myPrivateStaticMethod1() { + return exporter.createExportedWidget3(); + } + get myPublicMethod1() { // Error + return exporter.createExportedWidget3(); + } + private get myPrivateMethod1() { + return exporter.createExportedWidget3(); + } +} + +class privateClassWithWithPrivateGetAccessorTypes { + static get myPublicStaticMethod() { + return exporter.createExportedWidget1(); + } + private static get myPrivateStaticMethod() { + return exporter.createExportedWidget1(); + } + get myPublicMethod() { + return exporter.createExportedWidget1(); + } + private get myPrivateMethod() { + return exporter.createExportedWidget1(); + } + static get myPublicStaticMethod1() { + return exporter.createExportedWidget3(); + } + private static get myPrivateStaticMethod1() { + return exporter.createExportedWidget3(); + } + get myPublicMethod1() { + return exporter.createExportedWidget3(); + } + private get myPrivateMethod1() { + return exporter.createExportedWidget3(); + } +} + +export class publicClassWithPrivateModuleGetAccessorTypes { + static get myPublicStaticMethod() { // Error + return exporter.createExportedWidget2(); + } + get myPublicMethod() { // Error + return exporter.createExportedWidget2(); + } + static get myPublicStaticMethod1() { // Error + return exporter.createExportedWidget4(); + } + get myPublicMethod1() { // Error + return exporter.createExportedWidget4(); + } +} + +class privateClassWithPrivateModuleGetAccessorTypes { + static get myPublicStaticMethod() { + return exporter.createExportedWidget2(); + } + get myPublicMethod() { + return exporter.createExportedWidget2(); + } + static get myPublicStaticMethod1() { + return exporter.createExportedWidget4(); + } + get myPublicMethod1() { + return exporter.createExportedWidget4(); + } +} \ No newline at end of file diff --git a/tests/cases/compiler/privacyCannotNameVarTypeDeclFile.ts b/tests/cases/compiler/privacyCannotNameVarTypeDeclFile.ts new file mode 100644 index 00000000000..e49d31946c6 --- /dev/null +++ b/tests/cases/compiler/privacyCannotNameVarTypeDeclFile.ts @@ -0,0 +1,101 @@ +// @module: commonjs +// @declaration: true + + +// @Filename: privacyCannotNameVarTypeDeclFile_GlobalWidgets.ts +declare module "GlobalWidgets" { + export class Widget3 { + name: string; + } + export function createWidget3(): Widget3; + + export module SpecializedGlobalWidget { + export class Widget4 { + name: string; + } + function createWidget4(): Widget4; + } +} + +// @Filename: privacyCannotNameVarTypeDeclFile_Widgets.ts +export class Widget1 { + name = 'one'; +} +export function createWidget1() { + return new Widget1(); +} + +export module SpecializedWidget { + export class Widget2 { + name = 'one'; + } + export function createWidget2() { + return new Widget2(); + } +} + +// @Filename:privacyCannotNameVarTypeDeclFile_exporter.ts +/// +import Widgets = require("privacyCannotNameVarTypeDeclFile_Widgets"); +import Widgets1 = require("GlobalWidgets"); +export function createExportedWidget1() { + return Widgets.createWidget1(); +} +export function createExportedWidget2() { + return Widgets.SpecializedWidget.createWidget2(); +} +export function createExportedWidget3() { + return Widgets1.createWidget3(); +} +export function createExportedWidget4() { + return Widgets1.SpecializedGlobalWidget.createWidget4(); +} + +// @Filename:privacyCannotNameVarTypeDeclFile_consumer.ts +import exporter = require("privacyCannotNameVarTypeDeclFile_exporter"); +export class publicClassWithWithPrivatePropertyTypes { + static myPublicStaticProperty = exporter.createExportedWidget1(); // Error + private static myPrivateStaticProperty = exporter.createExportedWidget1(); + myPublicProperty = exporter.createExportedWidget1(); // Error + private myPrivateProperty = exporter.createExportedWidget1(); + + static myPublicStaticProperty1 = exporter.createExportedWidget3(); // Error + private static myPrivateStaticProperty1 = exporter.createExportedWidget3(); + myPublicProperty1 = exporter.createExportedWidget3(); // Error + private myPrivateProperty1 = exporter.createExportedWidget3(); +} + +class privateClassWithWithPrivatePropertyTypes { + static myPublicStaticProperty = exporter.createExportedWidget1(); + private static myPrivateStaticProperty = exporter.createExportedWidget1(); + myPublicProperty = exporter.createExportedWidget1(); + private myPrivateProperty = exporter.createExportedWidget1(); + + static myPublicStaticProperty1 = exporter.createExportedWidget3(); + private static myPrivateStaticProperty1 = exporter.createExportedWidget3(); + myPublicProperty1 = exporter.createExportedWidget3(); + private myPrivateProperty1 = exporter.createExportedWidget3(); +} + +export var publicVarWithPrivatePropertyTypes= exporter.createExportedWidget1(); // Error +var privateVarWithPrivatePropertyTypes= exporter.createExportedWidget1(); +export var publicVarWithPrivatePropertyTypes1 = exporter.createExportedWidget3(); // Error +var privateVarWithPrivatePropertyTypes1 = exporter.createExportedWidget3(); + +export class publicClassWithPrivateModulePropertyTypes { + static myPublicStaticProperty= exporter.createExportedWidget2(); // Error + myPublicProperty = exporter.createExportedWidget2(); // Error + static myPublicStaticProperty1 = exporter.createExportedWidget4(); // Error + myPublicProperty1 = exporter.createExportedWidget4(); // Error +} +export var publicVarWithPrivateModulePropertyTypes= exporter.createExportedWidget2(); // Error +export var publicVarWithPrivateModulePropertyTypes1 = exporter.createExportedWidget4(); // Error + +class privateClassWithPrivateModulePropertyTypes { + static myPublicStaticProperty= exporter.createExportedWidget2(); + myPublicProperty= exporter.createExportedWidget2(); + static myPublicStaticProperty1 = exporter.createExportedWidget4(); + myPublicProperty1 = exporter.createExportedWidget4(); +} +var privateVarWithPrivateModulePropertyTypes= exporter.createExportedWidget2(); +var privateVarWithPrivateModulePropertyTypes1 = exporter.createExportedWidget4(); \ No newline at end of file diff --git a/tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile.ts b/tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile.ts new file mode 100644 index 00000000000..f24ed8ea32b --- /dev/null +++ b/tests/cases/compiler/privacyFunctionCannotNameParameterTypeDeclFile.ts @@ -0,0 +1,157 @@ +// @module: commonjs +// @declaration: true + + +// @Filename: privacyFunctionCannotNameParameterTypeDeclFile_GlobalWidgets.ts +declare module "GlobalWidgets" { + export class Widget3 { + name: string; + } + export function createWidget3(): Widget3; + + export module SpecializedGlobalWidget { + export class Widget4 { + name: string; + } + function createWidget4(): Widget4; + } +} + +// @Filename: privacyFunctionCannotNameParameterTypeDeclFile_Widgets.ts +export class Widget1 { + name = 'one'; +} +export function createWidget1() { + return new Widget1(); +} + +export module SpecializedWidget { + export class Widget2 { + name = 'one'; + } + export function createWidget2() { + return new Widget2(); + } +} + +// @Filename:privacyFunctionCannotNameParameterTypeDeclFile_exporter.ts +/// +import Widgets = require("privacyFunctionCannotNameParameterTypeDeclFile_Widgets"); +import Widgets1 = require("GlobalWidgets"); +export function createExportedWidget1() { + return Widgets.createWidget1(); +} +export function createExportedWidget2() { + return Widgets.SpecializedWidget.createWidget2(); +} +export function createExportedWidget3() { + return Widgets1.createWidget3(); +} +export function createExportedWidget4() { + return Widgets1.SpecializedGlobalWidget.createWidget4(); +} + +// @Filename:privacyFunctionCannotNameParameterTypeDeclFile_consumer.ts +import exporter = require("privacyFunctionCannotNameParameterTypeDeclFile_exporter"); +export class publicClassWithWithPrivateParmeterTypes { + static myPublicStaticMethod(param = exporter.createExportedWidget1()) { // Error + } + private static myPrivateStaticMethod(param = exporter.createExportedWidget1()) { + } + myPublicMethod(param = exporter.createExportedWidget1()) { // Error + } + private myPrivateMethod(param = exporter.createExportedWidget1()) { + } + constructor(param = exporter.createExportedWidget1(), private param1 = exporter.createExportedWidget1(), public param2 = exporter.createExportedWidget1()) { // Error + } +} +export class publicClassWithWithPrivateParmeterTypes1 { + static myPublicStaticMethod(param = exporter.createExportedWidget3()) { // Error + } + private static myPrivateStaticMethod(param = exporter.createExportedWidget3()) { + } + myPublicMethod(param = exporter.createExportedWidget3()) { // Error + } + private myPrivateMethod(param = exporter.createExportedWidget3()) { + } + constructor(param = exporter.createExportedWidget3(), private param1 = exporter.createExportedWidget3(), public param2 = exporter.createExportedWidget3()) { // Error + } +} + +class privateClassWithWithPrivateParmeterTypes { + static myPublicStaticMethod(param = exporter.createExportedWidget1()) { + } + private static myPrivateStaticMethod(param = exporter.createExportedWidget1()) { + } + myPublicMethod(param = exporter.createExportedWidget1()) { + } + private myPrivateMethod(param = exporter.createExportedWidget1()) { + } + constructor(param = exporter.createExportedWidget1(), private param1 = exporter.createExportedWidget1(), public param2 = exporter.createExportedWidget1()) { + } +} +class privateClassWithWithPrivateParmeterTypes2 { + static myPublicStaticMethod(param = exporter.createExportedWidget3()) { + } + private static myPrivateStaticMethod(param = exporter.createExportedWidget3()) { + } + myPublicMethod(param = exporter.createExportedWidget3()) { + } + private myPrivateMethod(param = exporter.createExportedWidget3()) { + } + constructor(param = exporter.createExportedWidget3(), private param1 = exporter.createExportedWidget3(), public param2 = exporter.createExportedWidget3()) { + } +} + +export function publicFunctionWithPrivateParmeterTypes(param = exporter.createExportedWidget1()) { // Error +} +function privateFunctionWithPrivateParmeterTypes(param = exporter.createExportedWidget1()) { +} +export function publicFunctionWithPrivateParmeterTypes1(param = exporter.createExportedWidget3()) { // Error +} +function privateFunctionWithPrivateParmeterTypes1(param = exporter.createExportedWidget3()) { +} + + +export class publicClassWithPrivateModuleParameterTypes { + static myPublicStaticMethod(param= exporter.createExportedWidget2()) { // Error + } + myPublicMethod(param= exporter.createExportedWidget2()) { // Error + } + constructor(param= exporter.createExportedWidget2(), private param1= exporter.createExportedWidget2(), public param2= exporter.createExportedWidget2()) { // Error + } +} +export class publicClassWithPrivateModuleParameterTypes2 { + static myPublicStaticMethod(param= exporter.createExportedWidget4()) { // Error + } + myPublicMethod(param= exporter.createExportedWidget4()) { // Error + } + constructor(param= exporter.createExportedWidget4(), private param1= exporter.createExportedWidget4(), public param2= exporter.createExportedWidget4()) { // Error + } +} +export function publicFunctionWithPrivateModuleParameterTypes(param= exporter.createExportedWidget2()) { // Error +} +export function publicFunctionWithPrivateModuleParameterTypes1(param= exporter.createExportedWidget4()) { // Error +} + + +class privateClassWithPrivateModuleParameterTypes { + static myPublicStaticMethod(param= exporter.createExportedWidget2()) { + } + myPublicMethod(param= exporter.createExportedWidget2()) { + } + constructor(param= exporter.createExportedWidget2(), private param1= exporter.createExportedWidget2(), public param2= exporter.createExportedWidget2()) { + } +} +class privateClassWithPrivateModuleParameterTypes1 { + static myPublicStaticMethod(param= exporter.createExportedWidget4()) { + } + myPublicMethod(param= exporter.createExportedWidget4()) { + } + constructor(param= exporter.createExportedWidget4(), private param1= exporter.createExportedWidget4(), public param2= exporter.createExportedWidget4()) { + } +} +function privateFunctionWithPrivateModuleParameterTypes(param= exporter.createExportedWidget2()) { +} +function privateFunctionWithPrivateModuleParameterTypes1(param= exporter.createExportedWidget4()) { +} \ No newline at end of file diff --git a/tests/cases/compiler/privacyFunctionCannotNameReturnTypeDeclFile.ts b/tests/cases/compiler/privacyFunctionCannotNameReturnTypeDeclFile.ts new file mode 100644 index 00000000000..2eff22327b5 --- /dev/null +++ b/tests/cases/compiler/privacyFunctionCannotNameReturnTypeDeclFile.ts @@ -0,0 +1,163 @@ +// @module: commonjs +// @declaration: true + + +// @Filename: privacyFunctionReturnTypeDeclFile_GlobalWidgets.ts +declare module "GlobalWidgets" { + export class Widget3 { + name: string; + } + export function createWidget3(): Widget3; + + export module SpecializedGlobalWidget { + export class Widget4 { + name: string; + } + function createWidget4(): Widget4; + } +} + +// @Filename: privacyFunctionReturnTypeDeclFile_Widgets.ts +export class Widget1 { + name = 'one'; +} +export function createWidget1() { + return new Widget1(); +} + +export module SpecializedWidget { + export class Widget2 { + name = 'one'; + } + export function createWidget2() { + return new Widget2(); + } +} + +// @Filename:privacyFunctionReturnTypeDeclFile_exporter.ts +/// +import Widgets = require("privacyFunctionReturnTypeDeclFile_Widgets"); +import Widgets1 = require("GlobalWidgets"); +export function createExportedWidget1() { + return Widgets.createWidget1(); +} +export function createExportedWidget2() { + return Widgets.SpecializedWidget.createWidget2(); +} +export function createExportedWidget3() { + return Widgets1.createWidget3(); +} +export function createExportedWidget4() { + return Widgets1.SpecializedGlobalWidget.createWidget4(); +} + +// @Filename:privacyFunctionReturnTypeDeclFile_consumer.ts +import exporter = require("privacyFunctionReturnTypeDeclFile_exporter"); +export class publicClassWithWithPrivateParmeterTypes { + static myPublicStaticMethod() { // Error + return exporter.createExportedWidget1(); + } + private static myPrivateStaticMethod() { + return exporter.createExportedWidget1();; + } + myPublicMethod() { // Error + return exporter.createExportedWidget1();; + } + private myPrivateMethod() { + return exporter.createExportedWidget1();; + } + static myPublicStaticMethod1() { // Error + return exporter.createExportedWidget3(); + } + private static myPrivateStaticMethod1() { + return exporter.createExportedWidget3();; + } + myPublicMethod1() { // Error + return exporter.createExportedWidget3();; + } + private myPrivateMethod1() { + return exporter.createExportedWidget3();; + } +} + +class privateClassWithWithPrivateParmeterTypes { + static myPublicStaticMethod() { + return exporter.createExportedWidget1(); + } + private static myPrivateStaticMethod() { + return exporter.createExportedWidget1();; + } + myPublicMethod() { + return exporter.createExportedWidget1();; + } + private myPrivateMethod() { + return exporter.createExportedWidget1();; + } + static myPublicStaticMethod1() { + return exporter.createExportedWidget3(); + } + private static myPrivateStaticMethod1() { + return exporter.createExportedWidget3();; + } + myPublicMethod1() { + return exporter.createExportedWidget3();; + } + private myPrivateMethod1() { + return exporter.createExportedWidget3();; + } +} + +export function publicFunctionWithPrivateParmeterTypes() { // Error + return exporter.createExportedWidget1(); +} +function privateFunctionWithPrivateParmeterTypes() { + return exporter.createExportedWidget1(); +} +export function publicFunctionWithPrivateParmeterTypes1() { // Error + return exporter.createExportedWidget3(); +} +function privateFunctionWithPrivateParmeterTypes1() { + return exporter.createExportedWidget3(); +} + +export class publicClassWithPrivateModuleReturnTypes { + static myPublicStaticMethod() { // Error + return exporter.createExportedWidget2(); + } + myPublicMethod() { // Error + return exporter.createExportedWidget2(); + } + static myPublicStaticMethod1() { // Error + return exporter.createExportedWidget4(); + } + myPublicMethod1() { // Error + return exporter.createExportedWidget4(); + } +} +export function publicFunctionWithPrivateModuleReturnTypes() { // Error + return exporter.createExportedWidget2(); +} +export function publicFunctionWithPrivateModuleReturnTypes1() { // Error + return exporter.createExportedWidget4(); +} + +class privateClassWithPrivateModuleReturnTypes { + static myPublicStaticMethod() { + return exporter.createExportedWidget2(); + } + myPublicMethod() { + return exporter.createExportedWidget2(); + } + static myPublicStaticMethod1() { // Error + return exporter.createExportedWidget4(); + } + myPublicMethod1() { // Error + return exporter.createExportedWidget4(); + } +} +function privateFunctionWithPrivateModuleReturnTypes() { + return exporter.createExportedWidget2(); +} +function privateFunctionWithPrivateModuleReturnTypes1() { + return exporter.createExportedWidget4(); +}