analytics-angular icon indicating copy to clipboard operation
analytics-angular copied to clipboard

Property 'analytics' does not exist on type 'Window & typeof globalThis'.

Open Carl-Meyer opened this issue 5 years ago • 4 comments

When running ng test I get the following error on all of my spec tests:

Property 'analytics' does not exist on type 'Window & typeof globalThis'.

This is strange as I did declare the analytics property as instructed?

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

Carl-Meyer avatar May 20 '20 13:05 Carl-Meyer

Hello all. I'm also hitting: property 'analytics' does not exist on type 'Window'. I also set the declare global { interface Window { analytics: any; } }. Any ideas? Thanks in advance!

realtysapient avatar Jan 16 '21 22:01 realtysapient

@Carl-Meyer @realtysapient try adding the keyword export, as in:

/* eslint-disable */
export declare global {
  interface Window {
    analytics?: any;
  }
}
/* eslint-enable */

does that work for you? another less ideal situation is to rename your use of window.analytics to globalThis.analytics

benjaminhoffman avatar Oct 12 '21 14:10 benjaminhoffman

@benjaminhoffman this doesn't work for me, and also causes another problem: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible.

shadyacres avatar Oct 28 '21 10:10 shadyacres

El tipo de archivo debe ser .d.ts para evitar el error de export.

@benjaminhoffman this doesn't work for me, and also causes another problem: 'export' modifier cannot be applied to ambient modules and module augmentations since they are always visible.

CarlosDevSanchez07 avatar Dec 27 '23 17:12 CarlosDevSanchez07