I am trying to use exceljs 4 in Angular 9 and I want to provide support on IE 11. I am trying to follow the instructions provided on the official page of exceljs. I tried to add the below code to polyfills.ts
file:
(window as any).global = window;
const rewritePattern = require('regexpu-core');
const {generateRegexpuOptions} = require('@babel/helper-create-regexp-features-plugin/lib/util');
const {RegExp} = global;
try {
new RegExp('a', 'u');
} catch (err) {
global.RegExp = function(pattern, flags) {
if (flags && flags.includes('u')) {
return new RegExp(rewritePattern(pattern, flags, generateRegexpuOptions({flags, pattern})));
}
return new RegExp(pattern, flags);
};
global.RegExp.prototype = RegExp;
}
but I am getting errors on global.RegExp: = function(pattern, flags) as
Type '(pattern: any, flags: any) => RegExp' is missing the following properties from type 'RegExpConstructor': $1, $2, $3, $4, and 7 more.
and on the last line global.RegExp.prototype = RegExp; as
Cannot assign to 'prototype' because it is a read-only property.