How to use custom polyfill functions with Angular 9 universal?

Viewed 73

Maybe I'm doing something completely wrong, but I've defined a bunch of custom functions in my polyfill.ts. Like this:

if (!Array.prototype['multisort']) {
    Object.defineProperty(Array.prototype, 'multisort', { ... }

When I do now compile my app for universal I get an output like this:

dc059394006a7a8ee0d5
Time: 9309ms
Built at: 2020-10-03 11:40:26
  Asset      Size  Chunks  Chunk Names
main.js  1.75 KiB       0  main
Entrypoint main = main.js
chunk    {0} main.js (main) 28 bytes [entry] [rendered]

ERROR in src/app/modules/services/title.service.ts:16:5 - error TS2339: Property 'multisort' does not exist on type 'any[]'.

It's the first time that I'm using to create an universal app and I'm not really familiar with it yet. So the question is how to import the polyfill in universal, or where to put my custom functions so that they are loaded.

0 Answers
Related