refactor(compiler-cli): create diagnostics using ts.DiagnosticRelatedInformation
(#37587)
Previously, an anonymous type was used for creating a diagnostic with related information. The anonymous type would then be translated into the necessary `ts.DiagnosticRelatedInformation` shape within `makeDiagnostic`. This commit switches the `makeDiagnostic` signature over to taking `ts.DiagnosticRelatedInformation` directly and introduces `makeRelatedInformation` to easily create such objects. This is done to aid in making upcoming work more readable. PR Close #37587
This commit is contained in:
@ -9,7 +9,7 @@
|
||||
import {ExternalExpr, SchemaMetadata} from '@angular/compiler';
|
||||
import * as ts from 'typescript';
|
||||
|
||||
import {ErrorCode, makeDiagnostic} from '../../diagnostics';
|
||||
import {ErrorCode, makeDiagnostic, makeRelatedInformation} from '../../diagnostics';
|
||||
import {AliasingHost, Reexport, Reference, ReferenceEmitter} from '../../imports';
|
||||
import {DirectiveMeta, MetadataReader, MetadataRegistry, NgModuleMeta, PipeMeta} from '../../metadata';
|
||||
import {ClassDeclaration} from '../../reflection';
|
||||
@ -358,7 +358,8 @@ export class LocalModuleScopeRegistry implements MetadataRegistry, ComponentScop
|
||||
ngModule.ref.node.name
|
||||
.text}', but is not a directive, a component, or a pipe. ` +
|
||||
`Either remove it from the NgModule's declarations, or add an appropriate Angular decorator.`,
|
||||
[{node: decl.node.name, messageText: `'${decl.node.name.text}' is declared here.`}]));
|
||||
[makeRelatedInformation(
|
||||
decl.node.name, `'${decl.node.name.text}' is declared here.`)]));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -643,8 +644,8 @@ function reexportCollision(
|
||||
To fix this problem please re-export one or both classes directly from this file.
|
||||
`.trim(),
|
||||
[
|
||||
{node: refA.node.name, messageText: childMessageText},
|
||||
{node: refB.node.name, messageText: childMessageText},
|
||||
makeRelatedInformation(refA.node.name, childMessageText),
|
||||
makeRelatedInformation(refB.node.name, childMessageText),
|
||||
]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user