Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a project global variable in Typescript

in my main html file I have defined the following which I want to be a project global variable :

<script type="text/javascript" charset="utf-8">var path='/';
    path=path.substr(0, path.length - 1);
</script>

I am then using the variable path in several different ts files and it works fine. However, I do get a compilation warning saying that path is not defined. How can I prevent this warning from happening ?

like image 488
Scipion Avatar asked Jan 05 '23 21:01

Scipion


1 Answers

Create a something.d.ts file (.d.ts is the file extension for type declarataion) and make sure that it's included or not excluded in your tsconfig.json:

something.d.ts

declare var path: string;
like image 145
Ivan Zlatev Avatar answered Jan 18 '23 22:01

Ivan Zlatev