Skip to content

Commit

Permalink
fix(language-service): The suppress diagnostics option should work fo…
Browse files Browse the repository at this point in the history
…r external templates

Previously, due to a bug, this option only worked for inline templates.
  • Loading branch information
dylhunn committed Sep 18, 2024
1 parent 4231e8f commit 85fe618
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/language-service/src/language_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,12 @@ export class LanguageService {

getSemanticDiagnostics(fileName: string): ts.Diagnostic[] {
return this.withCompilerAndPerfTracing(PerfPhase.LsDiagnostics, (compiler) => {
const diagnostics: ts.Diagnostic[] = [];
let diagnostics: ts.Diagnostic[] = [];
if (isTypeScriptFile(fileName)) {
const program = compiler.getCurrentProgram();
const sourceFile = program.getSourceFile(fileName);
if (sourceFile) {
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
Expand Down Expand Up @@ -130,6 +125,11 @@ export class LanguageService {
}
}
}
if (this.config.suppressAngularDiagnosticCodes) {
diagnostics = diagnostics.filter(
(diag) => !this.config.suppressAngularDiagnosticCodes!.includes(diag.code),
);
}
return diagnostics;
});
}
Expand Down

0 comments on commit 85fe618

Please sign in to comment.