Currently facing a challenge with my Angular application development. I have created a TS File that interacts with my API (imported in the index.html using a script tag) and exported some functions from this file to be used in my components. Despite everything working fine, an error keeps popping up in my browser. Surprisingly, IntelliJ is not flagging any errors either. Here's a snippet of my code:
declare var AirConsole:any;
let airconsole: any;
export const enum MessageClass {
ERROR,
LOGIN,
ANNOUNCEMENT
}
export function InitAirConsole(){
airconsole = new AirConsole();
console.log("Created AirConsole Controller:" );
console.log(airconsole);
airconsole.onMessage = function(from:number,data:any){
switch(data.messageClass){
case MessageClass.ERROR:
console.log("Error Code: " + data.errorCode + "\nDetails: " + data.errorDetails);
break;
case MessageClass.ANNOUNCEMENT:
console.log("Announcement from Screen\nHeader: " + data.header + "\nMessage:" + data.message);
break;
}
}
}
export function SendMessageToScreen(data:any){
airconsole.message(AirConsole.SCREEN, data);
console.log("Data sent to Screen. Data: ");
console.log(data);
}
The issue seems to be on line 1 where I am getting
Uncaught SyntaxError: Unexpected token 'var'
https://i.sstatic.net/EaHsT.png