I have a global variable declared in the html header and want to reference it from a class inside a module. How can I prevent compiler error:
error TS2095: Could not find symbol 'selfGlobal'.
<html>
    <head>
        <script>
        var selfGlobal = this;
        var globalVariable = 1;
        </script>
    </head>
    <body>   
    <script src="test.js"></script>
    </body>
</html>
In test.ts
module Test{
    export class TestClass {
        private _privateVariable:any; 
        constructor() {
            this._privateVariable = selfGlobal.globalVariable; // compile error throws here, but the code can run
        }
    }
}
Thanks! Mars
Just import the config module in all modules of your application; the module then becomes available as a global name.
To define a Global variable in java, the keyword static is used. Java actually doesn't have the concept of Global variable, it is known as class variable ( static field ). These are the variables that can be used by the entire class. // constructer used to initialise a Student object.
You need to tell the compiler it has been declared:
declare var selfGlobal: any;
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With