2

i have one typescript file with name 'abc.ts' having a method call 'ScanCode()'. i have one separate js file "sample.js" having a method foo(). i want to call the scancode method of typescript in this sample js' foo method.

I tried to import ts file in javascript but its not able to idetify 'import' function.

  • You could refer [this answer](http://stackoverflow.com/a/12711586/2435473), Either just call a js function directly(you may see warning) or make it `declare` variable – Pankaj Parkar Sep 23 '16 at 09:44
  • 1
    Why don't you write your code in TypeScript too? I recommend it. – Tamas Hegedus Sep 23 '16 at 09:44
  • Actully i am calling my js function from Android activity, thats why i wanted to call the typescript methoda from this js method. – Ashish Maurya Sep 23 '16 at 10:02

1 Answers1

1

You have to compile the typescript file you have to javascript or if you want to import it use something like webpack. I think that the easiest way to call your typescript function is to make it global.

alex4o
  • 33
  • 1
  • 5