@@ -467,12 +467,12 @@ namespace ts.projectSystem {
467467        verifyDiagnostics ( actual ,  [ ] ) ; 
468468    } 
469469
470-     function  checkErrorMessage ( session : TestSession ,  eventName : "syntaxDiag"   |   "semanticDiag" ,  diagnostics : protocol . DiagnosticEventBody )  { 
471-         checkNthEvent ( session ,  ts . server . toEvent ( eventName ,  diagnostics ) ,  0 ,  /* isMostRecent*/   false ) ; 
470+     function  checkErrorMessage ( session : TestSession ,  eventName : protocol . DiagnosticEventKind ,  diagnostics : protocol . DiagnosticEventBody ,   isMostRecent   =   false ) :  void   { 
471+         checkNthEvent ( session ,  ts . server . toEvent ( eventName ,  diagnostics ) ,  0 ,  isMostRecent ) ; 
472472    } 
473473
474-     function  checkCompleteEvent ( session : TestSession ,  numberOfCurrentEvents : number ,  expectedSequenceId : number )  { 
475-         checkNthEvent ( session ,  ts . server . toEvent ( "requestCompleted" ,  {  request_seq : expectedSequenceId  } ) ,  numberOfCurrentEvents  -  1 ,  /* isMostRecent*/   true ) ; 
474+     function  checkCompleteEvent ( session : TestSession ,  numberOfCurrentEvents : number ,  expectedSequenceId : number ,   isMostRecent   =   true ) :  void   { 
475+         checkNthEvent ( session ,  ts . server . toEvent ( "requestCompleted" ,  {  request_seq : expectedSequenceId  } ) ,  numberOfCurrentEvents  -  1 ,  isMostRecent ) ; 
476476    } 
477477
478478    function  checkProjectUpdatedInBackgroundEvent ( session : TestSession ,  openFiles : string [ ] )  { 
@@ -3076,8 +3076,13 @@ namespace ts.projectSystem {
30763076                host . runQueuedImmediateCallbacks ( ) ; 
30773077                assert . isFalse ( hasError ( ) ) ; 
30783078                checkErrorMessage ( session ,  "semanticDiag" ,  {  file : untitledFile ,  diagnostics : [ ]  } ) ; 
3079+                 session . clearMessages ( ) ; 
30793080
3081+                 host . runQueuedImmediateCallbacks ( 1 ) ; 
3082+                 assert . isFalse ( hasError ( ) ) ; 
3083+                 checkErrorMessage ( session ,  "suggestionDiag" ,  {  file : untitledFile ,  diagnostics : [ ]  } ) ; 
30803084                checkCompleteEvent ( session ,  2 ,  expectedSequenceId ) ; 
3085+                 session . clearMessages ( ) ; 
30813086            } 
30823087
30833088            it ( "has projectRoot" ,  ( )  =>  { 
@@ -3136,6 +3141,10 @@ namespace ts.projectSystem {
31363141
31373142                host . runQueuedImmediateCallbacks ( ) ; 
31383143                checkErrorMessage ( session ,  "semanticDiag" ,  {  file : app . path ,  diagnostics : [ ]  } ) ; 
3144+                 session . clearMessages ( ) ; 
3145+ 
3146+                 host . runQueuedImmediateCallbacks ( 1 ) ; 
3147+                 checkErrorMessage ( session ,  "suggestionDiag" ,  {  file : app . path ,  diagnostics : [ ]  } ) ; 
31393148                checkCompleteEvent ( session ,  2 ,  expectedSequenceId ) ; 
31403149                session . clearMessages ( ) ; 
31413150            } 
@@ -3934,18 +3943,17 @@ namespace ts.projectSystem {
39343943            session . clearMessages ( ) ; 
39353944
39363945            host . runQueuedImmediateCallbacks ( ) ; 
3937-             const  moduleNotFound  =  Diagnostics . Cannot_find_module_0 ; 
39383946            const  startOffset  =  file1 . content . indexOf ( '"' )  +  1 ; 
39393947            checkErrorMessage ( session ,  "semanticDiag" ,  { 
3940-                 file : file1 . path ,  diagnostics : [ { 
3941-                     start : {  line : 1 ,  offset : startOffset  } , 
3942-                     end : {  line : 1 ,  offset : startOffset  +  '"pad"' . length  } , 
3943-                     text : formatStringFromArgs ( moduleNotFound . message ,  [ "pad" ] ) , 
3944-                     code : moduleNotFound . code , 
3945-                     category : DiagnosticCategory [ moduleNotFound . category ] . toLowerCase ( ) , 
3946-                     source : undefined 
3947-                 } ] 
3948+                 file : file1 . path , 
3949+                 diagnostics : [ 
3950+                     createDiagnostic ( {  line : 1 ,  offset : startOffset  } ,  {  line : 1 ,  offset : startOffset  +  '"pad"' . length  } ,  Diagnostics . Cannot_find_module_0 ,  [ "pad" ] ) 
3951+                 ] , 
39483952            } ) ; 
3953+             session . clearMessages ( ) ; 
3954+ 
3955+             host . runQueuedImmediateCallbacks ( 1 ) ; 
3956+             checkErrorMessage ( session ,  "suggestionDiag" ,  {  file : file1 . path ,  diagnostics : [ ]  } ) ; 
39493957            checkCompleteEvent ( session ,  2 ,  expectedSequenceId ) ; 
39503958            session . clearMessages ( ) ; 
39513959
@@ -3966,6 +3974,63 @@ namespace ts.projectSystem {
39663974            host . runQueuedImmediateCallbacks ( ) ; 
39673975            checkErrorMessage ( session ,  "semanticDiag" ,  {  file : file1 . path ,  diagnostics : [ ]  } ) ; 
39683976        } ) ; 
3977+ 
3978+         it ( "info diagnostics" ,  ( )  =>  { 
3979+             const  file : FileOrFolder  =  { 
3980+                 path : "/a.js" , 
3981+                 content : 'require("b")' , 
3982+             } ; 
3983+ 
3984+             const  host  =  createServerHost ( [ file ] ) ; 
3985+             const  session  =  createSession ( host ,  {  canUseEvents : true  } ) ; 
3986+             const  service  =  session . getProjectService ( ) ; 
3987+ 
3988+             session . executeCommandSeq < protocol . OpenRequest > ( { 
3989+                 command : server . CommandNames . Open , 
3990+                 arguments : {  file : file . path ,  fileContent : file . content  } , 
3991+             } ) ; 
3992+ 
3993+             checkNumberOfProjects ( service ,  {  inferredProjects : 1  } ) ; 
3994+             session . clearMessages ( ) ; 
3995+             const  expectedSequenceId  =  session . getNextSeq ( ) ; 
3996+             host . checkTimeoutQueueLengthAndRun ( 2 ) ; 
3997+ 
3998+             checkProjectUpdatedInBackgroundEvent ( session ,  [ file . path ] ) ; 
3999+             session . clearMessages ( ) ; 
4000+ 
4001+             session . executeCommandSeq < protocol . GeterrRequest > ( { 
4002+                 command : server . CommandNames . Geterr , 
4003+                 arguments : { 
4004+                     delay : 0 , 
4005+                     files : [ file . path ] , 
4006+                 } 
4007+             } ) ; 
4008+ 
4009+             host . checkTimeoutQueueLengthAndRun ( 1 ) ; 
4010+ 
4011+             checkErrorMessage ( session ,  "syntaxDiag" ,  {  file : file . path ,  diagnostics : [ ]  } ,  /*isMostRecent*/  true ) ; 
4012+             session . clearMessages ( ) ; 
4013+ 
4014+             host . runQueuedImmediateCallbacks ( 1 ) ; 
4015+ 
4016+             checkErrorMessage ( session ,  "semanticDiag" ,  {  file : file . path ,  diagnostics : [ ]  } ) ; 
4017+             session . clearMessages ( ) ; 
4018+ 
4019+             host . runQueuedImmediateCallbacks ( 1 ) ; 
4020+ 
4021+             checkErrorMessage ( session ,  "suggestionDiag" ,  { 
4022+                 file : file . path , 
4023+                 diagnostics : [ 
4024+                     createDiagnostic ( {  line : 1 ,  offset : 1  } ,  {  line : 1 ,  offset : 13  } ,  Diagnostics . File_is_a_CommonJS_module_it_may_be_converted_to_an_ES6_module ) 
4025+                 ] , 
4026+             } ) ; 
4027+             checkCompleteEvent ( session ,  2 ,  expectedSequenceId ) ; 
4028+             session . clearMessages ( ) ; 
4029+         } ) ; 
4030+ 
4031+         function  createDiagnostic ( start : protocol . Location ,  end : protocol . Location ,  message : DiagnosticMessage ,  args : ReadonlyArray < string >  =  [ ] ) : protocol . Diagnostic  { 
4032+             return  {  start,  end,  text : formatStringFromArgs ( message . message ,  args ) ,  code : message . code ,  category : diagnosticCategoryName ( message ) ,  source : undefined  } ; 
4033+         } 
39694034    } ) ; 
39704035
39714036    describe ( "tsserverProjectSystem Configure file diagnostics events" ,  ( )  =>  { 
@@ -5154,9 +5219,15 @@ namespace ts.projectSystem {
51545219
51555220                // the semanticDiag message 
51565221                host . runQueuedImmediateCallbacks ( ) ; 
5157-                 assert . equal ( host . getOutput ( ) . length ,  2 ,   "expect 2 messages" ) ; 
5222+                 assert . equal ( host . getOutput ( ) . length ,  1 ) ; 
51585223                const  e2  =  < protocol . Event > getMessage ( 0 ) ; 
51595224                assert . equal ( e2 . event ,  "semanticDiag" ) ; 
5225+                 session . clearMessages ( ) ; 
5226+ 
5227+                 host . runQueuedImmediateCallbacks ( 1 ) ; 
5228+                 assert . equal ( host . getOutput ( ) . length ,  2 ) ; 
5229+                 const  e3  =  < protocol . Event > getMessage ( 0 ) ; 
5230+                 assert . equal ( e3 . event ,  "suggestionDiag" ) ; 
51605231                verifyRequestCompleted ( getErrId ,  1 ) ; 
51615232
51625233                cancellationToken . resetToken ( ) ; 
@@ -5194,6 +5265,7 @@ namespace ts.projectSystem {
51945265                return  JSON . parse ( server . extractMessage ( host . getOutput ( ) [ n ] ) ) ; 
51955266            } 
51965267        } ) ; 
5268+ 
51975269        it ( "Lower priority tasks are cancellable" ,  ( )  =>  { 
51985270            const  f1  =  { 
51995271                path : "/a/app.ts" , 
@@ -5495,7 +5567,7 @@ namespace ts.projectSystem {
54955567        } 
54965568        type  CalledMaps  =  CalledMapsWithSingleArg  |  CalledMapsWithFiveArgs ; 
54975569        function  createCallsTrackingHost ( host : TestServerHost )  { 
5498-             const  calledMaps : Record < CalledMapsWithSingleArg ,  MultiMap < true > >  &  Record < CalledMapsWithFiveArgs ,  MultiMap < [ ReadonlyArray < string > ,  ReadonlyArray < string > ,  ReadonlyArray < string > ,  number ] > >    =  { 
5570+             const  calledMaps : Record < CalledMapsWithSingleArg ,  MultiMap < true > >  &  Record < CalledMapsWithFiveArgs ,  MultiMap < [ ReadonlyArray < string > ,  ReadonlyArray < string > ,  ReadonlyArray < string > ,  number ] > >  =  { 
54995571                fileExists : setCallsTrackingWithSingleArgFn ( CalledMapsWithSingleArg . fileExists ) , 
55005572                directoryExists : setCallsTrackingWithSingleArgFn ( CalledMapsWithSingleArg . directoryExists ) , 
55015573                getDirectories : setCallsTrackingWithSingleArgFn ( CalledMapsWithSingleArg . getDirectories ) , 
0 commit comments