1

I have an angular universal project which is using azure application insights to log exceptions.

When using angular universal I get an error because the library uses a shim, which expects 2 global variables to be declared. I understand the declare keyword is used to declare a variable which references a global variable, that way you can write code relying on a global that isnt known in your library.

Here is the shim: https://github.com/microsoft/ApplicationInsights-JS/blob/master/tools/shims/src/applicationinsights-shims.ts

It has these lines:

declare var __extends:(d: any, b: any) => any;
declare var __assign:(t: any) => any;

And here is the error I get:

ReferenceError: __assign is not defined

Supposedly these two variables are default globals for typescript but I cant find any information on that, clearly something is going wrong with the server side render. If I dont use Angular Universal I dont get the error.

Edit: I realised I was using a package named domino to polyfill the global window object, and I guess the polyfill was missing something. I removed it because Angular comes with ways to handle cross-platform execution with such a polyfill.

Craig
  • 1,648
  • 1
  • 20
  • 45
  • In the Edit section of you post, after removing it, does the code work? – Ivan Glasenberg Aug 25 '20 at 07:50
  • @IvanYang yes it does work, but the question still holds true. What to do if a library declares something which isnt there? That would be a bug in the library (or running the library on a different environment than supported), but I wonder if there are workarounds. – Craig Aug 25 '20 at 08:13

0 Answers0