How to call typescript function from JavaScript?
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.
BY Best Interview Question ON 25 May 2020
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.