When registering the decorators it is assumed that if global is undefined then window must be defined. However this is not always the case. In Web Workers global and window throw the following error (at least under TypeScript)
Error: apps/samples/basic/src/app/app.worker.ts:3:1 - error TS2304: Cannot find name 'window'.
Error: apps/samples/basic/src/app/app.worker.ts:4:1 - error TS2304: Cannot find name 'global'.
globalThis is defined however.
I know we did look at globalThis back when setting up the angular-register and we decided not to because of backwards compatibility. Maybe we should look at using/creating a globalThis polyfill so we can use globalThis instead of window or global and support Web Workers
When registering the decorators it is assumed that if
global
is undefined thenwindow
must be defined. However this is not always the case. In Web Workersglobal
andwindow
throw the following error (at least under TypeScript)globalThis
is defined however.I know we did look at
globalThis
back when setting up theangular-register
and we decided not to because of backwards compatibility. Maybe we should look at using/creating aglobalThis
polyfill so we can useglobalThis
instead ofwindow
orglobal
and support Web WorkersHere is one such pollyfill I found: https://www.npmjs.com/package/globalthis
Another solution may be to simply offer an import that isn't attached to the global for cases like this.