'How to call window.parent or window.opener 's function in typescript

Parent window

const popup = () => {
    window.open(
        "/fe/product/productSelectLayerPopUp",
        "popup",
        "width=800,height=800,left=200,top=200");
};

const test = () => {
    alert();
};

productSelectLayerPopUp.tsx

const selectProduct = (productIndex: Number) => {
   // call Parent Window's test() function
   (window.parent as any).test();
}

I want to call parent's test() function but it occurred

TypeError: window.opener.test is not a function

Is there another way to call parent's function? Please help me



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source