I have a javascript file called ui.js.
Inside ui.js is UI setup code.
if (!(\"ontouchstart\" in document.documentElement)) {
document.documentEle
But I have not been able to figure out how to do that.
Simply set allowJs
to true in your tsconfig.json compilerOptions
and then make sure the .js
file is included using files
/include
/exclude
etc.
I did a video on the subject as well https://www.youtube.com/watch?v=gmKXXI_ck7w
You can call JavaScript functions from external files with no worries. But you have to declare them so TypeScript knows about them. If you dont, your code will work, but you will get an error while compiling.
You can use an Anonymously-typed var:
declare var myFunction;
or an Interfaced-typed var:
interface __myFunction { }
declare var myFunction: __myFunction;
You may also write this into a declaration file(but its not required). See also TypeScript documentation.