[Solved] Windows Variable packing error: Property ‘XXX‘ does not exist on type ‘Window‘

Scenario:

In the h5 of the app, the app injected a global window object to interact with the page in the webview, and an error was reported when it was packaged.

Solution:

method one:

(window as any).xxx

Change window.jigsaw.init(()); directly in the component to (window as any).jigsaw.init(());

Method Two:

declare global {
interface Window {xxx: any;}
}

window.xxx = window.xxx|| {};
Method three:

interface MyWindow extends Window {
xxx(): void;
}

declare var window: MyWindow;

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *