Skip to content
Advertisement

How to use a TypeScript function in Javascript

I want to use the below given function called “translate” in a JavaScript file. I have seen a answer on stackoverflow regarding this, but couldn’t get what I had to do. Definitely the normal calling of function isn’t working in this case

JavaScript

Advertisement

Answer

If you’re using a typescript project then you can do:

JavaScript

However even if you import it this way typescript will still need to compile your code before it can be used.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement