mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
refactor(language-service): Allow language service diagnostics to be ignored (#57675)
Add a check to the language service that ignores specified diagnostic codes. This will be useful in g3. The codes to ignore are exposed as part of the PluginConfig. Fixes github.com/angular/vscode-ng-language-service/issues/1243 PR Close #57675
This commit is contained in:
parent
6f0d05fac0
commit
f063a75eae
2 changed files with 11 additions and 1 deletions
|
|
@ -41,6 +41,11 @@ export interface PluginConfig {
|
|||
* If false, disables parsing of `@let` declarations in the compiler.
|
||||
*/
|
||||
enableLetSyntax?: false;
|
||||
|
||||
/**
|
||||
* A list of diagnostic codes that should be supressed in the language service.
|
||||
*/
|
||||
suppressAngularDiagnosticCodes?: number[];
|
||||
}
|
||||
|
||||
export type GetTcbResponse = {
|
||||
|
|
|
|||
|
|
@ -88,7 +88,12 @@ export class LanguageService {
|
|||
const program = compiler.getCurrentProgram();
|
||||
const sourceFile = program.getSourceFile(fileName);
|
||||
if (sourceFile) {
|
||||
const ngDiagnostics = compiler.getDiagnosticsForFile(sourceFile, OptimizeFor.SingleFile);
|
||||
let ngDiagnostics = compiler.getDiagnosticsForFile(sourceFile, OptimizeFor.SingleFile);
|
||||
if (this.config.suppressAngularDiagnosticCodes) {
|
||||
ngDiagnostics = ngDiagnostics.filter(
|
||||
(diag) => !this.config.suppressAngularDiagnosticCodes!.includes(diag.code),
|
||||
);
|
||||
}
|
||||
// There are several kinds of diagnostics returned by `NgCompiler` for a source file:
|
||||
//
|
||||
// 1. Angular-related non-template diagnostics from decorated classes within that
|
||||
|
|
|
|||
Loading…
Reference in a new issue