I have the following directory structure:
/Admin/Grid
abc.ts // this file contains the one function abc()
xxx.ts // this file contains the one function xxx()
/Admin/Dialog
abc.ts // this file contains the one function abc()
I load both all three javascripts into my browser.
The function xxx() looks like this:
function xxx() {
// do abc
abc();
}
Is there a way using typescript that I can tell the function xxx to execute the function abc that’s inside the file in the /Admin/Dialog directory?
If you are referencing all of these files and your functions are all in the global scope (it looks like they are from your question) then you can call the functions from anywhere.
One benefit of TypeScript that you may want to investigate is the use of modules and classes to encapsulate groups of functions and data, which helps you to organise your program and keep the global scope clear of your own functions and variables.
So going back to your question, if you want two functions with the same name, you can’t put them both into the same scope – you need to either:
Here is an example based on your question.