I have a function in my TypeScript file:
public test(): string[] {
return new Array("Mary", "Tom", "Jack", "Jill");
}
How do I call this function from JavaScript?
I have a function in my TypeScript file:
public test(): string[] {
return new Array("Mary", "Tom", "Jack", "Jill");
}
How do I call this function from JavaScript?
TypeScript files are source files that are not run directly, they are transpiled to JavaScript before they can be run. Normally project using TypeScript have some sort of build pipeline setup using something like Webpack, you cannot just use a TypeScript file directly with a JavaScrpt project.
TypeScript is compiled to JavaScript before anything else happens - so once it's compiled, you call it later in your project just like you would any other function:
test();