Search code examples
angulartypescriptnpmhandsontable

Error in handsontable numbro library, which happens only in production build


I am getting the following error when adding a row to my handsontable instance:

core.js.pre-build-optimizer.js:15724 ERROR RangeError: toFixed() digits argument must be between 0 and 100 at Number.toFixed () at h (numbro.min.js.pre-build-optimizer.js:1) at numbro.min.js.pre-build-optimizer.js:1

Full error: enter image description here

The weird thing is, that I only get this error on ng build -prod (or with the --optimization flag).

Using the debugger is therefore tricky, as the js has been compiled, however using console.log() I narrowed it down to this handsontable call:

hot.alter('insert_row');

After reading about this handsontable compilation issue, I'm in the process of refactoring the project to enable strict:true in tsconfig.json but this is turning out to be quite a bit of work.

Has anyone experienced a similar issue?

versions:

  • Angular 7.2
  • Handsontable 7.0.0 (but issue also happens in v6)
  • Typescript 3.2.4

I do not use the numbro library anywhere in my code, it is purely a dependency of handsontable (no other libraries in my project use it either).


Solution

  • You're right, it's not releated to Handsontable version. One of the dependencies Numbro in v2.1.2 have introduced conflict[1] with Webpack TerserPlugin (the default minfier).

    Handsontable v7.0.1 will fix this issue by downgrading numbro dependency. Or you can install it right now: npm i numbro@2.1.1 and Handsontable will use your version.

    [1] https://github.com/BenjaminVanRyseghem/numbro/issues/402#issuecomment-471586507