0

I am trying to call a Javascript method from a TypeScript class. I tried this solution, but it did not work for me. I am getting the error

Uncaught Referenceerror : greet is not defined

Here is my code:

//Resources.js
function greet() {return "Hello";}

//Modifiers.ts
 declare function greet(): string;
  var hi = greet();

Any help appreciated!

Community
  • 1
  • 1
user1847624
  • 21
  • 2
  • 4

1 Answers1

3

You need to make sure your Resources.js file is loaded before Modifiers.js runs. This runtime error is normally caused by not adding the dependent script to the web page.

You should have both of these...

<script src="Resources.js"></script>
<script src="Modifiers.js"></script>
Fenton
  • 241,084
  • 71
  • 387
  • 401