@@ -6,7 +6,7 @@ import * as linuxTerm from '../linux/console';
66import * as net from "net" ;
77import * as fs from "fs" ;
88import * as path from "path" ;
9- import { Client } from "ssh2" ;
9+ import { Client , ClientChannel , ExecOptions } from "ssh2" ;
1010
1111export function escape ( str : string ) {
1212 return str . replace ( / \\ / g, "\\\\" ) . replace ( / " / g, "\\\"" ) ;
@@ -29,7 +29,7 @@ export class MI2 extends EventEmitter implements IBackend {
2929 super ( ) ;
3030
3131 if ( procEnv ) {
32- const env = { } ;
32+ const env : { [ key : string ] : string } = { } ;
3333 // Duplicate process.env so we don't override it
3434 for ( const key in process . env )
3535 if ( process . env . hasOwnProperty ( key ) )
@@ -57,8 +57,8 @@ export class MI2 extends EventEmitter implements IBackend {
5757 this . process = ChildProcess . spawn ( this . application , args , { cwd : cwd , env : this . procEnv } ) ;
5858 this . process . stdout . on ( "data" , this . stdout . bind ( this ) ) ;
5959 this . process . stderr . on ( "data" , this . stderr . bind ( this ) ) ;
60- this . process . on ( "exit" , ( ( ) => { this . emit ( "quit" ) ; } ) . bind ( this ) ) ;
61- this . process . on ( "error" , ( ( err ) => { this . emit ( "launcherror" , err ) ; } ) . bind ( this ) ) ;
60+ this . process . on ( "exit" , ( ) => this . emit ( "quit" ) ) ;
61+ this . process . on ( "error" , err => this . emit ( "launcherror" , err ) ) ;
6262 const promises = this . initCommands ( target , cwd ) ;
6363 if ( procArgs && procArgs . length )
6464 promises . push ( this . sendCommand ( "exec-arguments " + procArgs ) ) ;
@@ -137,7 +137,7 @@ export class MI2 extends EventEmitter implements IBackend {
137137
138138 this . sshConn . on ( "ready" , ( ) => {
139139 this . log ( "stdout" , "Running " + this . application + " over ssh..." ) ;
140- const execArgs : any = { } ;
140+ const execArgs : ExecOptions = { } ;
141141 if ( args . forwardX11 ) {
142142 execArgs . x11 = {
143143 single : false ,
@@ -150,7 +150,7 @@ export class MI2 extends EventEmitter implements IBackend {
150150 if ( err ) {
151151 this . log ( "stderr" , "Could not run " + this . application + "(" + sshCMD + ") over ssh!" ) ;
152152 if ( err === undefined ) {
153- err = "<reason unknown>" ;
153+ err = new Error ( "<reason unknown>" ) ;
154154 }
155155 this . log ( "stderr" , err . toString ( ) ) ;
156156 this . emit ( "quit" ) ;
@@ -161,10 +161,10 @@ export class MI2 extends EventEmitter implements IBackend {
161161 this . stream = stream ;
162162 stream . on ( "data" , this . stdout . bind ( this ) ) ;
163163 stream . stderr . on ( "data" , this . stderr . bind ( this ) ) ;
164- stream . on ( "exit" , ( ( ) => {
164+ stream . on ( "exit" , ( ) => {
165165 this . emit ( "quit" ) ;
166166 this . sshConn . end ( ) ;
167- } ) . bind ( this ) ) ;
167+ } ) ;
168168 const promises = this . initCommands ( target , cwd , attach ) ;
169169 promises . push ( this . sendCommand ( "environment-cd \"" + escape ( cwd ) + "\"" ) ) ;
170170 if ( attach ) {
@@ -181,7 +181,7 @@ export class MI2 extends EventEmitter implements IBackend {
181181 } ) . on ( "error" , ( err ) => {
182182 this . log ( "stderr" , "Error running " + this . application + " over ssh!" ) ;
183183 if ( err === undefined ) {
184- err = "<reason unknown>" ;
184+ err = new Error ( "<reason unknown>" ) ;
185185 }
186186 this . log ( "stderr" , err . toString ( ) ) ;
187187 this . emit ( "quit" ) ;
@@ -235,8 +235,8 @@ export class MI2 extends EventEmitter implements IBackend {
235235 this . process = ChildProcess . spawn ( this . application , args , { cwd : cwd , env : this . procEnv } ) ;
236236 this . process . stdout . on ( "data" , this . stdout . bind ( this ) ) ;
237237 this . process . stderr . on ( "data" , this . stderr . bind ( this ) ) ;
238- this . process . on ( "exit" , ( ( ) => { this . emit ( "quit" ) ; } ) . bind ( this ) ) ;
239- this . process . on ( "error" , ( ( err ) => { this . emit ( "launcherror" , err ) ; } ) . bind ( this ) ) ;
238+ this . process . on ( "exit" , ( ) => this . emit ( "quit" ) ) ;
239+ this . process . on ( "error" , err => this . emit ( "launcherror" , err ) ) ;
240240 const promises = this . initCommands ( target , cwd , true ) ;
241241 if ( target . startsWith ( "extended-remote" ) ) {
242242 promises . push ( this . sendCommand ( "target-select " + target ) ) ;
@@ -267,8 +267,8 @@ export class MI2 extends EventEmitter implements IBackend {
267267 this . process = ChildProcess . spawn ( this . application , args , { cwd : cwd , env : this . procEnv } ) ;
268268 this . process . stdout . on ( "data" , this . stdout . bind ( this ) ) ;
269269 this . process . stderr . on ( "data" , this . stderr . bind ( this ) ) ;
270- this . process . on ( "exit" , ( ( ) => { this . emit ( "quit" ) ; } ) . bind ( this ) ) ;
271- this . process . on ( "error" , ( ( err ) => { this . emit ( "launcherror" , err ) ; } ) . bind ( this ) ) ;
270+ this . process . on ( "exit" , ( ) => this . emit ( "quit" ) ) ;
271+ this . process . on ( "error" , err => this . emit ( "launcherror" , err ) ) ;
272272 const promises = this . initCommands ( target , cwd , true ) ;
273273 promises . push ( this . sendCommand ( "target-select remote " + target ) ) ;
274274 promises . push ( ...autorun . map ( value => { return this . sendUserInput ( value ) ; } ) ) ;
@@ -279,7 +279,7 @@ export class MI2 extends EventEmitter implements IBackend {
279279 } ) ;
280280 }
281281
282- stdout ( data ) {
282+ stdout ( data : any ) {
283283 if ( trace )
284284 this . log ( "stderr" , "stdout: " + data ) ;
285285 if ( typeof data == "string" )
@@ -298,7 +298,7 @@ export class MI2 extends EventEmitter implements IBackend {
298298 }
299299 }
300300
301- stderr ( data ) {
301+ stderr ( data : any ) {
302302 if ( typeof data == "string" )
303303 this . errbuf += data ;
304304 else
@@ -563,7 +563,7 @@ export class MI2 extends EventEmitter implements IBackend {
563563 loadBreakPoints ( breakpoints : Breakpoint [ ] ) : Thenable < [ boolean , Breakpoint ] [ ] > {
564564 if ( trace )
565565 this . log ( "stderr" , "loadBreakPoints" ) ;
566- const promisses = [ ] ;
566+ const promisses : Thenable < [ boolean , Breakpoint ] > [ ] = [ ] ;
567567 breakpoints . forEach ( breakpoint => {
568568 promisses . push ( this . addBreakPoint ( breakpoint ) ) ;
569569 } ) ;
@@ -651,7 +651,7 @@ export class MI2 extends EventEmitter implements IBackend {
651651 if ( trace )
652652 this . log ( "stderr" , "clearBreakPoints" ) ;
653653 return new Promise ( ( resolve , reject ) => {
654- const promises = [ ] ;
654+ const promises : Thenable < void | MINode > [ ] = [ ] ;
655655 const breakpoints = this . breakpoints ;
656656 this . breakpoints = new Map ( ) ;
657657 breakpoints . forEach ( ( k , index ) => {
@@ -709,7 +709,7 @@ export class MI2 extends EventEmitter implements IBackend {
709709
710710 const result = await this . sendCommand ( [ "stack-list-frames" ] . concat ( options ) . join ( " " ) ) ;
711711 const stack = result . result ( "stack" ) ;
712- return stack . map ( element => {
712+ return stack . map ( ( element : any ) => {
713713 const level = MINode . valueOf ( element , "@frame.level" ) ;
714714 const addr = MINode . valueOf ( element , "@frame.addr" ) ;
715715 const func = MINode . valueOf ( element , "@frame.func" ) ;
@@ -856,7 +856,7 @@ export class MI2 extends EventEmitter implements IBackend {
856856 //TODO: add `from` and `to` arguments
857857 const res = await this . sendCommand ( `var-list-children --all-values ${ this . quote ( name ) } ` ) ;
858858 const children = res . result ( "children" ) || [ ] ;
859- const omg : VariableObject [ ] = children . map ( child => new VariableObject ( child [ 1 ] ) ) ;
859+ const omg : VariableObject [ ] = children . map ( ( child : any ) => new VariableObject ( child [ 1 ] ) ) ;
860860 return omg ;
861861 }
862862
@@ -945,6 +945,6 @@ export class MI2 extends EventEmitter implements IBackend {
945945 protected buffer : string ;
946946 protected errbuf : string ;
947947 protected process : ChildProcess . ChildProcess ;
948- protected stream ;
949- protected sshConn ;
948+ protected stream : ClientChannel ;
949+ protected sshConn : Client ;
950950}
0 commit comments