Javascript function to typescript

Hello, I’m trying to port a javascript function into my custom extension but I have some difficulties to make it compatible with bokeh typescript compiler.
This is the function (it make the cartesian product of several arrays)

function cartesian_product(...arrays){
  return arrays.reduce((acc, curr) =>
      acc.flatMap(c => curr.map(n => [].concat(c, n)))
  );
}

I need also to reproduce the .flat method which is in ES20?? is there something already built in bokeh?

thks

Hi @Xavier_Artusi There is not a “Bokeh” Typescript compiler, there is just the standard Typescript compiler (which Bokeh happens to use). What difficulty are you actually seeing? Is there a compiler error you can report?

As for .flat there seem to be answers on StackOverflow:

In fact, I’d actually suggest the other question is also a TypeScript question, not specifically a Bokeh question, so StackOverflow might be a better place to ask.

Actually my question was more to know if in bokehjs there is already a function implemented which reproduce the .flat behavior.
For example I know there is already an implemention for linspace and several polyfills. I just don’t want to reinvent the wheel.

For the moment to find solething in bokehjs I use the search function of github.