Skip to content

Commit

Permalink
refactor(language-service): Allow language service diagnostics to be …
Browse files Browse the repository at this point in the history
…ignored

Add a check to the language service that ignores specified diagnostic codes.

This can be patched in g3 as needed, to ignore codes that are not relevant for g3 (or otherwise not compatible).
  • Loading branch information
dylhunn committed Sep 5, 2024
1 parent 68e5370 commit 70caeb7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/language-service/src/language_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ import {ActiveRefactoring, allRefactorings} from './refactorings/refactoring';

type LanguageServiceConfig = Omit<PluginConfig, 'angularOnly'>;

const ignoredAngularDiagnostics: number[] = [
// A list of diagnostic codes that are suppressed.
// This is especially useful for diagnostics that should be disabled in g3.
];

export class LanguageService {
private options: CompilerOptions;
readonly compilerFactory: CompilerFactory;
Expand Down Expand Up @@ -88,7 +93,10 @@ 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);
ngDiagnostics = ngDiagnostics.filter(
(diag) => !ignoredAngularDiagnostics.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

0 comments on commit 70caeb7

Please sign in to comment.