TS2339: Свойство '*' не существует в типе 'Window'. только в WebStorm - PullRequest
0 голосов
/ 02 ноября 2018

Win 10 Pro 64 бит

WebStorm: 2018.2.3

Ошибка:

enter image description here

enter image description here

в моем файле interfaces.ts:

declare global {
  interface Window {
    dataLayer?: Array<any>;
    gtag?: (...args) => void;
    ga?: (action: string, type: string, data: Object) => void;
  }
}

1 Ответ

0 голосов
/ 17 апреля 2019

Вы можете сделать:

const eventName = 'event';
const handlerName= doAction;
const target = ( <any>window ); // <===== THIS IS THE WORK AROUND

target.ga && target.ga(eventName, handlerName)
...