0

In an object, I need to call out to a function on that page that is not part of the typescript file. As typescript doesn't know about it, it fails to compile.

How do I tell typescript that the call is fine and to let it through? function name is MY_PERSONAL_FUNCTION in this example

    var dataSource = new kendo.data.DataSource({
        error: (e) => { MY_PERSONAL_FUNCTION (e); },
4
  • You need to include a .d.ts file for Kendo. Commented May 23, 2018 at 17:35
  • I have included it, but MY_PERSONAL_FUNCTION is my function. Typescript fails on MY_PERSONAL_FUNCTION as it is not defined. Commented May 23, 2018 at 17:36
  • if you have written this file else where, you can export the function from your js file and import it in your typescript class. Commented May 23, 2018 at 17:38
  • How do I just ignore the typescript error. This is a function that is on the page that is added by another project magically. Commented May 23, 2018 at 17:40

1 Answer 1

1

If you are going for quick and dirty, you can just add declare function to the top of your script. This will tell TypeScript the function has been created somewhere else.

declare function MY_PERSONAL_FUNCTION(e: any);

var dataSource = new kendo.data.DataSource({
    error: (e) => { MY_PERSONAL_FUNCTION (e); },
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.