0

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.

Pritam Bohra
  • 3,912
  • 8
  • 41
  • 72
  • Did you try to check by adding the ES 5 imports and polyfills required by exceljs? [See here](https://www.npmjs.com/package/exceljs#es5-imports-) If not, then you can try to add it and check whether it helps to solve these errors. – Deepak-MSFT Aug 21 '20 at 08:23
  • @Deepak-MSFT I followed the instructions mentioned in the above link, but it didn't work – Pritam Bohra Aug 24 '20 at 17:25
  • Try to add a reference with implicit dependencies on core-js polyfills. [As shown here](https://github.com/exceljs/exceljs#browserify) If the issue persists then I suggest create a new issue on their [Github](https://github.com/exceljs/exceljs/issues) page. – Deepak-MSFT Aug 25 '20 at 05:25

0 Answers0