1.

How to call typescript function from JavaScript?

Answer»

Compiling Typescript into Javascript is done using a JS function. During this process of compiling, the code structure could be changed a BIT. If you have multiple modules or classes in the typescript, then they would become a PART of the path to call the specific function.

Example

class Foo{
     constructor(){}
     public Bar = () : string =>{
         return "This is a string";
     }
}
module FooModule {
     export var FooInstance = new Foo();
}
If you would want to call this in Typescript, USE this command:
FooModule.FooInstance.Bar();
Note: The PAGES mentioned above have to be imported in a proper MANNER to call in Typescript.



Discussion

No Comment Found