mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-16 06:59:15 -05:00
Dont swallow declaration emit errors when issued on nodes without names (#44995)
This commit is contained in:
@@ -171,33 +171,40 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function errorDeclarationNameWithFallback() {
|
||||
return errorNameNode ? declarationNameToString(errorNameNode) :
|
||||
errorFallbackNode && getNameOfDeclaration(errorFallbackNode) ? declarationNameToString(getNameOfDeclaration(errorFallbackNode)) :
|
||||
errorFallbackNode && isExportAssignment(errorFallbackNode) ? errorFallbackNode.isExportEquals ? "export=" : "default" :
|
||||
"(Missing)"; // same fallback declarationNameToString uses when node is zero-width (ie, nameless)
|
||||
}
|
||||
|
||||
function reportInaccessibleUniqueSymbolError() {
|
||||
if (errorNameNode) {
|
||||
context.addDiagnostic(createDiagnosticForNode(errorNameNode, Diagnostics.The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary,
|
||||
declarationNameToString(errorNameNode),
|
||||
if (errorNameNode || errorFallbackNode) {
|
||||
context.addDiagnostic(createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary,
|
||||
errorDeclarationNameWithFallback(),
|
||||
"unique symbol"));
|
||||
}
|
||||
}
|
||||
|
||||
function reportCyclicStructureError() {
|
||||
if (errorNameNode) {
|
||||
context.addDiagnostic(createDiagnosticForNode(errorNameNode, Diagnostics.The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialized_A_type_annotation_is_necessary,
|
||||
declarationNameToString(errorNameNode)));
|
||||
if (errorNameNode || errorFallbackNode) {
|
||||
context.addDiagnostic(createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.The_inferred_type_of_0_references_a_type_with_a_cyclic_structure_which_cannot_be_trivially_serialized_A_type_annotation_is_necessary,
|
||||
errorDeclarationNameWithFallback()));
|
||||
}
|
||||
}
|
||||
|
||||
function reportInaccessibleThisError() {
|
||||
if (errorNameNode) {
|
||||
context.addDiagnostic(createDiagnosticForNode(errorNameNode, Diagnostics.The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary,
|
||||
declarationNameToString(errorNameNode),
|
||||
if (errorNameNode || errorFallbackNode) {
|
||||
context.addDiagnostic(createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.The_inferred_type_of_0_references_an_inaccessible_1_type_A_type_annotation_is_necessary,
|
||||
errorDeclarationNameWithFallback(),
|
||||
"this"));
|
||||
}
|
||||
}
|
||||
|
||||
function reportLikelyUnsafeImportRequiredError(specifier: string) {
|
||||
if (errorNameNode) {
|
||||
context.addDiagnostic(createDiagnosticForNode(errorNameNode, Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary,
|
||||
declarationNameToString(errorNameNode),
|
||||
if (errorNameNode || errorFallbackNode) {
|
||||
context.addDiagnostic(createDiagnosticForNode((errorNameNode || errorFallbackNode)!, Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary,
|
||||
errorDeclarationNameWithFallback(),
|
||||
specifier));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user