@@ -411,7 +411,12 @@ namespace ts.server {
411411 this . send ( ev ) ;
412412 }
413413
414- public output ( info : { } | undefined , cmdName : string , reqSeq : number , success : boolean , message ?: string ) {
414+ // For backwards-compatibility only.
415+ public output ( info : any , cmdName : string , reqSeq ?: number , errorMsg ?: string ) : void {
416+ this . doOutput ( info , cmdName , reqSeq , /*success*/ ! errorMsg , errorMsg ) ;
417+ }
418+
419+ private doOutput ( info : { } | undefined , cmdName : string , reqSeq : number , success : boolean , message ?: string ) : void {
415420 const res : protocol . Response = {
416421 seq : 0 ,
417422 type : "response" ,
@@ -1299,7 +1304,7 @@ namespace ts.server {
12991304 this . changeSeq ++ ;
13001305 // make sure no changes happen before this one is finished
13011306 if ( project . reloadScript ( file , tempFileName ) ) {
1302- this . output ( undefined , CommandNames . Reload , reqSeq , /*success*/ true ) ;
1307+ this . doOutput ( /*info*/ undefined , CommandNames . Reload , reqSeq , /*success*/ true ) ;
13031308 }
13041309 }
13051310
@@ -1539,7 +1544,7 @@ namespace ts.server {
15391544
15401545 private applyCodeActionCommand ( commandName : string , requestSeq : number , args : protocol . ApplyCodeActionCommandRequestArgs ) : void {
15411546 const { file, project } = this . getFileAndProject ( args ) ;
1542- const output = ( success : boolean , message : string ) => this . output ( { } , commandName , requestSeq , success , message ) ;
1547+ const output = ( success : boolean , message : string ) => this . doOutput ( { } , commandName , requestSeq , success , message ) ;
15431548 const command = args . command as CodeActionCommand ; // They should be sending back the command we sent them.
15441549 project . getLanguageService ( ) . applyCodeActionCommand ( file , command ) . then (
15451550 ( { successMessage } ) => { output ( /*success*/ true , successMessage ) ; } ,
@@ -1845,7 +1850,7 @@ namespace ts.server {
18451850 } ,
18461851 [ CommandNames . Configure ] : ( request : protocol . ConfigureRequest ) => {
18471852 this . projectService . setHostConfiguration ( request . arguments ) ;
1848- this . output ( undefined , CommandNames . Configure , request . seq , /*success*/ true ) ;
1853+ this . doOutput ( /*info*/ undefined , CommandNames . Configure , request . seq , /*success*/ true ) ;
18491854 return this . notRequired ( ) ;
18501855 } ,
18511856 [ CommandNames . Reload ] : ( request : protocol . ReloadRequest ) => {
@@ -1966,7 +1971,7 @@ namespace ts.server {
19661971 }
19671972 else {
19681973 this . logger . msg ( `Unrecognized JSON command: ${ JSON . stringify ( request ) } ` , Msg . Err ) ;
1969- this . output ( undefined , CommandNames . Unknown , request . seq , /*success*/ false , `Unrecognized JSON command: ${ request . command } ` ) ;
1974+ this . doOutput ( /*info*/ undefined , CommandNames . Unknown , request . seq , /*success*/ false , `Unrecognized JSON command: ${ request . command } ` ) ;
19701975 return { responseRequired : false } ;
19711976 }
19721977 }
@@ -1997,21 +2002,21 @@ namespace ts.server {
19972002 }
19982003
19992004 if ( response ) {
2000- this . output ( response , request . command , request . seq , /*success*/ true ) ;
2005+ this . doOutput ( response , request . command , request . seq , /*success*/ true ) ;
20012006 }
20022007 else if ( responseRequired ) {
2003- this . output ( undefined , request . command , request . seq , /*success*/ false , "No content available." ) ;
2008+ this . doOutput ( /*info*/ undefined , request . command , request . seq , /*success*/ false , "No content available." ) ;
20042009 }
20052010 }
20062011 catch ( err ) {
20072012 if ( err instanceof OperationCanceledException ) {
20082013 // Handle cancellation exceptions
2009- this . output ( { canceled : true } , request . command , request . seq , /*success*/ true ) ;
2014+ this . doOutput ( { canceled : true } , request . command , request . seq , /*success*/ true ) ;
20102015 return ;
20112016 }
20122017 this . logError ( err , message ) ;
2013- this . output (
2014- undefined ,
2018+ this . doOutput (
2019+ /*info*/ undefined ,
20152020 request ? request . command : CommandNames . Unknown ,
20162021 request ? request . seq : 0 ,
20172022 /*success*/ false ,
0 commit comments