@@ -168,11 +168,12 @@ namespace ts.projectSystem {
168168 readonly session : TestSession ;
169169 readonly service : server . ProjectService ;
170170 readonly host : TestServerHost ;
171- constructor ( files : FileOrFolder [ ] ) {
171+ constructor ( files : FileOrFolder [ ] , suppressDiagnosticEvents ?: boolean ) {
172172 this . host = createServerHost ( files ) ;
173173 this . session = createSession ( this . host , {
174174 canUseEvents : true ,
175175 eventHandler : event => this . events . push ( event ) ,
176+ suppressDiagnosticEvents,
176177 } ) ;
177178 this . service = this . session . getProjectService ( ) ;
178179 }
@@ -485,6 +486,12 @@ namespace ts.projectSystem {
485486 checkNthEvent ( session , server . toEvent ( "projectsUpdatedInBackground" , { openFiles } ) , 0 , /*isMostRecent*/ true ) ;
486487 }
487488
489+ function checkNoDiagnosticEvents ( session : TestSession ) {
490+ for ( const event of session . events ) {
491+ assert . isFalse ( event . event . endsWith ( "Diag" ) , JSON . stringify ( event ) ) ;
492+ }
493+ }
494+
488495 function checkNthEvent ( session : TestSession , expectedEvent : protocol . Event , index : number , isMostRecent : boolean ) {
489496 const events = session . events ;
490497 assert . deepEqual ( events [ index ] , expectedEvent ) ;
@@ -4074,6 +4081,63 @@ namespace ts.projectSystem {
40744081 session . clearMessages ( ) ;
40754082 } ) ;
40764083
4084+ it ( "suppressed diagnostic events" , ( ) => {
4085+ const file : FileOrFolder = {
4086+ path : "/a.ts" ,
4087+ content : "1 = 2;" ,
4088+ } ;
4089+
4090+ const host = createServerHost ( [ file ] ) ;
4091+ const session = createSession ( host , { canUseEvents : true , suppressDiagnosticEvents : true } ) ;
4092+ const service = session . getProjectService ( ) ;
4093+
4094+ session . executeCommandSeq < protocol . OpenRequest > ( {
4095+ command : server . CommandNames . Open ,
4096+ arguments : { file : file . path , fileContent : file . content } ,
4097+ } ) ;
4098+
4099+ checkNumberOfProjects ( service , { inferredProjects : 1 } ) ;
4100+
4101+ host . checkTimeoutQueueLength ( 0 ) ;
4102+ checkNoDiagnosticEvents ( session ) ;
4103+
4104+ session . clearMessages ( ) ;
4105+
4106+ let expectedSequenceId = session . getNextSeq ( ) ;
4107+
4108+ session . executeCommandSeq < protocol . GeterrRequest > ( {
4109+ command : server . CommandNames . Geterr ,
4110+ arguments : {
4111+ delay : 0 ,
4112+ files : [ file . path ] ,
4113+ }
4114+ } ) ;
4115+
4116+ host . checkTimeoutQueueLength ( 0 ) ;
4117+ checkNoDiagnosticEvents ( session ) ;
4118+
4119+ checkCompleteEvent ( session , 1 , expectedSequenceId ) ;
4120+
4121+ session . clearMessages ( ) ;
4122+
4123+ expectedSequenceId = session . getNextSeq ( ) ;
4124+
4125+ session . executeCommandSeq < protocol . GeterrForProjectRequest > ( {
4126+ command : server . CommandNames . Geterr ,
4127+ arguments : {
4128+ delay : 0 ,
4129+ file : file . path ,
4130+ }
4131+ } ) ;
4132+
4133+ host . checkTimeoutQueueLength ( 0 ) ;
4134+ checkNoDiagnosticEvents ( session ) ;
4135+
4136+ checkCompleteEvent ( session , 1 , expectedSequenceId ) ;
4137+
4138+ session . clearMessages ( ) ;
4139+ } ) ;
4140+
40774141 function createDiagnostic ( start : protocol . Location , end : protocol . Location , message : DiagnosticMessage , args : ReadonlyArray < string > = [ ] ) : protocol . Diagnostic {
40784142 return { start, end, text : formatStringFromArgs ( message . message , args ) , code : message . code , category : diagnosticCategoryName ( message ) , source : undefined } ;
40794143 }
@@ -4149,7 +4213,7 @@ namespace ts.projectSystem {
41494213 serverEventManager . checkSingleConfigFileDiagEvent ( configFile . path , configFile . path ) ;
41504214 } ) ;
41514215
4152- it ( "are not generated when the config file doesnot include file opened and config file has errors" , ( ) => {
4216+ it ( "are not generated when the config file does not include file opened and config file has errors" , ( ) => {
41534217 const file = {
41544218 path : "/a/b/app.ts" ,
41554219 content : "let x = 10"
@@ -4173,7 +4237,26 @@ namespace ts.projectSystem {
41734237 serverEventManager . hasZeroEvent ( "configFileDiag" ) ;
41744238 } ) ;
41754239
4176- it ( "are not generated when the config file doesnot include file opened and doesnt contain any errors" , ( ) => {
4240+ it ( "are not generated when the config file has errors but suppressDiagnosticEvents is true" , ( ) => {
4241+ const file = {
4242+ path : "/a/b/app.ts" ,
4243+ content : "let x = 10"
4244+ } ;
4245+ const configFile = {
4246+ path : "/a/b/tsconfig.json" ,
4247+ content : `{
4248+ "compilerOptions": {
4249+ "foo": "bar",
4250+ "allowJS": true
4251+ }
4252+ }`
4253+ } ;
4254+ const serverEventManager = new TestServerEventManager ( [ file , configFile ] , /*suppressDiagnosticEvents*/ true ) ;
4255+ openFilesForSession ( [ file ] , serverEventManager . session ) ;
4256+ serverEventManager . hasZeroEvent ( "configFileDiag" ) ;
4257+ } ) ;
4258+
4259+ it ( "are not generated when the config file does not include file opened and doesnt contain any errors" , ( ) => {
41774260 const file = {
41784261 path : "/a/b/app.ts" ,
41794262 content : "let x = 10"
0 commit comments