@@ -51,6 +51,16 @@ import {ActiveRefactoring, allRefactorings} from './refactorings/refactoring';
5151
5252type LanguageServiceConfig = Omit < PluginConfig , 'angularOnly' > ;
5353
54+ // Whether the language service should suppress the below for google3.
55+ const enableG3Suppression = false ;
56+
57+ // The Copybara config that syncs the language service into g3 will be patched to
58+ // always suppress any diagnostics in this list.
59+ // See `angular2/copy.bara.sky` for more information.
60+ const suppressDiagnosticsInG3 : number [ ] = [
61+ parseInt ( `-99${ ErrorCode . COMPONENT_RESOURCE_NOT_FOUND } ` ) ,
62+ ] ;
63+
5464export class LanguageService {
5565 private options : CompilerOptions ;
5666 readonly compilerFactory : CompilerFactory ;
@@ -83,17 +93,12 @@ export class LanguageService {
8393
8494 getSemanticDiagnostics ( fileName : string ) : ts . Diagnostic [ ] {
8595 return this . withCompilerAndPerfTracing ( PerfPhase . LsDiagnostics , ( compiler ) => {
86- const diagnostics : ts . Diagnostic [ ] = [ ] ;
96+ let diagnostics : ts . Diagnostic [ ] = [ ] ;
8797 if ( isTypeScriptFile ( fileName ) ) {
8898 const program = compiler . getCurrentProgram ( ) ;
8999 const sourceFile = program . getSourceFile ( fileName ) ;
90100 if ( sourceFile ) {
91101 let ngDiagnostics = compiler . getDiagnosticsForFile ( sourceFile , OptimizeFor . SingleFile ) ;
92- if ( this . config . suppressAngularDiagnosticCodes ) {
93- ngDiagnostics = ngDiagnostics . filter (
94- ( diag ) => ! this . config . suppressAngularDiagnosticCodes ! . includes ( diag . code ) ,
95- ) ;
96- }
97102 // There are several kinds of diagnostics returned by `NgCompiler` for a source file:
98103 //
99104 // 1. Angular-related non-template diagnostics from decorated classes within that
@@ -130,6 +135,14 @@ export class LanguageService {
130135 }
131136 }
132137 }
138+ if ( this . config . suppressAngularDiagnosticCodes ) {
139+ diagnostics = diagnostics . filter (
140+ ( diag ) => ! this . config . suppressAngularDiagnosticCodes ! . includes ( diag . code ) ,
141+ ) ;
142+ }
143+ if ( enableG3Suppression ) {
144+ diagnostics = diagnostics . filter ( ( diag ) => ! suppressDiagnosticsInG3 . includes ( diag . code ) ) ;
145+ }
133146 return diagnostics ;
134147 } ) ;
135148 }
0 commit comments