0

I am trying to call a javascript class from Typescript but the compiler (VS) is throwing a wobbly.

The class itself is InfoBox but unfortunately I cannot find a typescript definition for it.

When I try to use it from my TS class it complains that it cannot find name "InfoBox"

public showInfoWindow(latLng: google.maps.LatLng, map: google.maps.Map): InfoBox {
    var infobox = new InfoBox({
    // ...
    }

    return infobox;
}

In the InfoBox.js file it is defined using the prototype method like so

function InfoBox(opt_opts) { ... }
InfoBox.prototype = new google.maps.OverlayView();

1 Answer 1

1

You can declare the class yourself, for example in a file InfoBox.d.ts:

// InfoBox.d.ts
declare class InfoBox {
    constructor(obj: any);
    // Here the members of InfoBox you use
}

The documentation on declaration files is here.

Sign up to request clarification or add additional context in comments.

1 Comment

I tried this, I must have got the syntax wrong, thanks!

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.