Skip to content

addEventListener beforeload --> No overload matches this call #1084

@bochove

Description

@bochove

Bug Report

Problem

var options = "location=yes,hidden=yes,beforeload=yes";
inAppBrowserRef = cordova.InAppBrowser.open(url, target, options);
inAppBrowserRef.addEventListener('beforeload', (params, callback) => {
    if (params.url.startsWith("http://www.example.com/")) {
        // Load this URL in the inAppBrowser.
        callback(params.url);
    } else {
        // The callback is not invoked, so the page will not be loaded.
        $('#status-message').text("This browser only opens pages on http://www.example.com/");
    }
});

What is expected to happen?

No typescript errors to be reported, as this is basically your own documentation example

What does actually happen?

No overload matches this call.
Overload 1 of 2, '(type: channel, callback: InAppBrowserEventListenerOrEventListenerObject): void', gave the following error.
Argument of type '"beforeload"' is not assignable to parameter of type 'channel'.
Overload 2 of 2, '(type: string, callback: InAppBrowserEventListenerOrEventListenerObject): void', gave the following error.
Argument of type '(params: any, callback: any) => void' is not assignable to parameter of type 'InAppBrowserEventListenerOrEventListenerObject'.
Type '(params: any, callback: any) => void' is not assignable to type 'InAppBrowserEventListener'.
Target signature provides too few arguments. Expected 2 or more, but got 1.ts(2769)

Version information

latest version

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions