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!

1 Answer 1

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.