I've the below simple code, in which I have 2 variables defines in the Main method, and I need to access them from another method.
but I got the variables are not defined, though I defined them in the declerations/main.d.ts file as:
declare let voiceReady:any;
declare let x:any;
the main.ts file is;
/// <reference path="../declerations/main.d.ts" />
namespace CORE{
export class Program {
public static Main(): void {
var voiceReady = new CORE.Listen(CORE.commands).commands;
console.log(voiceReady);
var x = 560;
Program.execute('anything');
}
public static execute(spokenText:string):void{
console.log('123');
console.log(x);
console.log(voiceReady);
}
}
}
UPDATE
If I removed the deceleration from the .d.ts file, and added them to the class itself, I get compilation error as shown below:
