Extend Math with custom prototypes in Ionic 2


I want to extend Math with new custom prototypes e.g. lerp and clamp.
For example Math.prototype.lerp = function(…) {…}.
But Ionic and typescript has to know this new methods. When typing in editor (vs code) these new methods must not be recognized as an error.

What’s the best way to do this?


The ability to extend prototypes of standard language features is one of my least favorite “features” of JavaScript. Why can’t you just have these be ordinary utility functions?


Ok, does Ionic have utilities like lerp and clamp to import? (otherwise I have to write my own)
import { lerp } from 'util/util';
import { util } from 'util/util';
… util.lerp(…)


Not that I know of, but you can just copy some other implementation into:

Yes, I like that much better than polluting the standard Math.