Global variables typescript not defined

Hi all,

I have a problem with typescript global variable.

I’m writing a piece of code to login with facebook in my ionic 3 app.

I have a global variable declared, but when the app runs, got me the error FB is not defined at the function FB.init({})

The code:

//all needed imports

declare const FB;

@Injectable()
export class AuthenticationProvider implements OnInit{

  //properties

  //constructor

   ngOnInit() {
     debugger
     if( FB != null && FB != 'undefined')
     {
       FB.init({
         appId: '***',
         cookie: false,access
         status: true,
         xfbml: true,
         version: 'v2.11'
       });
     }
   }

   //FB.login(){} inside an observable function
   //FB.getLoginStatus(){} inside an observable function
   //FB.api(){} inside an observable function

 }

Can someone help me?

Yeah, don’t do that. Don’t declare global variables, and fully type the variables you do declare. If you want a piece of data available globally, put it in a provider and inject that provider into components that need the data.