I need to use one global variable in typescript, that is defined at runtime.
I need this to transfer some config properties from server side language to javascript. I'm using typescript to generate my javascript files.
<script>
var globalProperties = {foo: 'bar', phpName: 'phpValue'};
</script>
<script src="/compiledTypeScriptFile.js"></script>
How can i use my globalProperties in compiledTypeScriptFile.ts? The globalProperties are automatically generated. So I cannot put them in a seperate ts file or something like this.
Im not using any client side lib except for jQuery.
Please consider globalProperties as type any[]
. The name value pairs will extend automatically in the future.
CodePudding user response:
Just declare
it:
declare var globalProperties: { [key: string]: any };