mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 10:41:56 -05:00
Report privacy errors on return types
This commit is contained in:
@@ -134,6 +134,20 @@ module ts {
|
||||
Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 2047, category: DiagnosticCategory.Error, key: "Parameter '{0}' of public method from exported class has or is using name '{1}' from private module '{2}'." },
|
||||
Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2: { code: 2048, category: DiagnosticCategory.Error, key: "Parameter '{0}' of method from exported interface has or is using name '{1}' from private module '{2}'." },
|
||||
Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 2049, category: DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." },
|
||||
Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 2052, category: DiagnosticCategory.Error, key: "Return type of constructor signature from exported interface has or is using private name '{0}'." },
|
||||
Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 2053, category: DiagnosticCategory.Error, key: "Return type of call signature from exported interface has or is using private name '{0}'." },
|
||||
Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0: { code: 2054, category: DiagnosticCategory.Error, key: "Return type of index signature from exported interface has or is using private name '{0}'." },
|
||||
Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0: { code: 2055, category: DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using private name '{0}'." },
|
||||
Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0: { code: 2056, category: DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using private name '{0}'." },
|
||||
Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0: { code: 2057, category: DiagnosticCategory.Error, key: "Return type of method from exported interface has or is using private name '{0}'." },
|
||||
Return_type_of_exported_function_has_or_is_using_private_name_0: { code: 2058, category: DiagnosticCategory.Error, key: "Return type of exported function has or is using private name '{0}'." },
|
||||
Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 2061, category: DiagnosticCategory.Error, key: "Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'." },
|
||||
Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 2062, category: DiagnosticCategory.Error, key: "Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'." },
|
||||
Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 2063, category: DiagnosticCategory.Error, key: "Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'." },
|
||||
Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 2064, category: DiagnosticCategory.Error, key: "Return type of public static method from exported class has or is using name '{0}' from private module '{1}'." },
|
||||
Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1: { code: 2065, category: DiagnosticCategory.Error, key: "Return type of public method from exported class has or is using name '{0}' from private module '{1}'." },
|
||||
Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1: { code: 2066, category: DiagnosticCategory.Error, key: "Return type of method from exported interface has or is using name '{0}' from private module '{1}'." },
|
||||
Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1: { code: 2067, category: DiagnosticCategory.Error, key: "Return type of exported function has or is using name '{0}' from private module '{1}'." },
|
||||
Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 2208, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'." },
|
||||
Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1: { code: 2209, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of call signature from exported interface has or is using private name '{1}'." },
|
||||
Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1: { code: 2210, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of public static method from exported class has or is using private name '{1}'." },
|
||||
|
||||
@@ -528,6 +528,62 @@
|
||||
"category": "Error",
|
||||
"code": 2049
|
||||
},
|
||||
"Return type of constructor signature from exported interface has or is using private name '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2052
|
||||
},
|
||||
"Return type of call signature from exported interface has or is using private name '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2053
|
||||
},
|
||||
"Return type of index signature from exported interface has or is using private name '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2054
|
||||
},
|
||||
"Return type of public static method from exported class has or is using private name '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2055
|
||||
},
|
||||
"Return type of public method from exported class has or is using private name '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2056
|
||||
},
|
||||
"Return type of method from exported interface has or is using private name '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2057
|
||||
},
|
||||
"Return type of exported function has or is using private name '{0}'.": {
|
||||
"category": "Error",
|
||||
"code": 2058
|
||||
},
|
||||
"Return type of constructor signature from exported interface has or is using name '{0}' from private module '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2061
|
||||
},
|
||||
"Return type of call signature from exported interface has or is using name '{0}' from private module '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2062
|
||||
},
|
||||
"Return type of index signature from exported interface has or is using name '{0}' from private module '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2063
|
||||
},
|
||||
"Return type of public static method from exported class has or is using name '{0}' from private module '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2064
|
||||
},
|
||||
"Return type of public method from exported class has or is using name '{0}' from private module '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2065
|
||||
},
|
||||
"Return type of method from exported interface has or is using name '{0}' from private module '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2066
|
||||
},
|
||||
"Return type of exported function has or is using name '{0}' from private module '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2067
|
||||
},
|
||||
"Type parameter '{0}' of constructor signature from exported interface has or is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
"code": 2208
|
||||
|
||||
@@ -1879,7 +1879,7 @@ module ts {
|
||||
var getSymbolVisibilityDiagnosticMessage: (symbolAccesibilityResult: SymbolAccessiblityResult) => {
|
||||
errorNode: Node;
|
||||
diagnosticMessage: DiagnosticMessage;
|
||||
typeName: Identifier
|
||||
typeName?: Identifier
|
||||
}
|
||||
|
||||
function writeSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags) {
|
||||
@@ -1909,11 +1909,19 @@ module ts {
|
||||
reportedDeclarationError = true;
|
||||
var errorInfo = getSymbolVisibilityDiagnosticMessage(symbolAccesibilityResult);
|
||||
if (errorInfo) {
|
||||
diagnostics.push(createDiagnosticForNode(errorInfo.errorNode,
|
||||
errorInfo.diagnosticMessage,
|
||||
getSourceTextOfLocalNode(errorInfo.typeName),
|
||||
symbolAccesibilityResult.errorSymbolName,
|
||||
symbolAccesibilityResult.errorModuleName));
|
||||
if (errorInfo.typeName) {
|
||||
diagnostics.push(createDiagnosticForNode(errorInfo.errorNode,
|
||||
errorInfo.diagnosticMessage,
|
||||
getSourceTextOfLocalNode(errorInfo.typeName),
|
||||
symbolAccesibilityResult.errorSymbolName,
|
||||
symbolAccesibilityResult.errorModuleName));
|
||||
}
|
||||
else {
|
||||
diagnostics.push(createDiagnosticForNode(errorInfo.errorNode,
|
||||
errorInfo.diagnosticMessage,
|
||||
symbolAccesibilityResult.errorSymbolName,
|
||||
symbolAccesibilityResult.errorModuleName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2394,10 +2402,70 @@ module ts {
|
||||
// If this is not a constructor and is not private, emit the return type
|
||||
if (node.kind !== SyntaxKind.Constructor && !(node.flags & NodeFlags.Private)) {
|
||||
write(": ");
|
||||
getSymbolVisibilityDiagnosticMessage = getReturnTypeVisibilityError;
|
||||
resolver.writeReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, TypeFormatFlags.None, writer);
|
||||
// TODO(shkamat) This is just till we get rest of the error reporting up
|
||||
getSymbolVisibilityDiagnosticMessage = undefined;
|
||||
}
|
||||
write(";");
|
||||
writeLine();
|
||||
|
||||
function getReturnTypeVisibilityError(symbolAccesibilityResult: SymbolAccessiblityResult) {
|
||||
// TODO(shkamat) Cannot access name errors
|
||||
var diagnosticMessage: DiagnosticMessage;
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ConstructSignature:
|
||||
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:
|
||||
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:
|
||||
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;
|
||||
break;
|
||||
|
||||
case SyntaxKind.Method:
|
||||
if (node.flags & NodeFlags.Static) {
|
||||
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
|
||||
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 ?
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
break;
|
||||
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
diagnosticMessage = symbolAccesibilityResult.errorModuleName ?
|
||||
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;
|
||||
|
||||
default:
|
||||
Debug.fail("This is unknown kind for signature: " + SyntaxKind[node.kind]);
|
||||
}
|
||||
|
||||
return {
|
||||
diagnosticMessage: diagnosticMessage,
|
||||
errorNode: <Node>node.name || node,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function emitParameterDeclaration(node: ParameterDeclaration) {
|
||||
|
||||
Reference in New Issue
Block a user