MCPcopy Create free account
hub / github.com/angular/angular / reexportCollision

Function reexportCollision

packages/compiler-cli/src/ngtsc/scope/src/local.ts:791–812  ·  view source on GitHub ↗

* Produce a `ts.Diagnostic` for a collision in re-export names between two directives/pipes.

(
  module: ClassDeclaration,
  refA: Reference<ClassDeclaration>,
  refB: Reference<ClassDeclaration>,
)

Source from the content-addressed store, hash-verified

789 * Produce a `ts.Diagnostic` for a collision in re-export names between two directives/pipes.
790 */
791function reexportCollision(
792 module: ClassDeclaration,
793 refA: Reference<ClassDeclaration>,
794 refB: Reference<ClassDeclaration>,
795): ts.Diagnostic {
796 const childMessageText = `This directive/pipe is part of the exports of '${module.name.text}' and shares the same name as another exported directive/pipe.`;
797 return makeDiagnostic(
798 ErrorCode.NGMODULE_REEXPORT_NAME_COLLISION,
799 module.name,
800 `
801 There was a name collision between two classes named '${refA.node.name.text}', which are both part of the exports of '${module.name.text}'.
802
803 Angular generates re-exports of an NgModule's exported directives/pipes from the module's source file in certain cases, using the declared name of the class. If two classes of the same name are exported, this automatic naming does not work.
804
805 To fix this problem please re-export one or both classes directly from this file.
806 `.trim(),
807 [
808 makeRelatedInformation(refA.node.name, childMessageText),
809 makeRelatedInformation(refB.node.name, childMessageText),
810 ],
811 );
812}
813
814export interface DeclarationData {
815 ngModule: ClassDeclaration;

Callers 1

addReexportMethod · 0.85

Calls 2

makeDiagnosticFunction · 0.90
makeRelatedInformationFunction · 0.90

Tested by

no test coverage detected