Currently I am trying to write a prototype extension function. But it seems that nothing what I try works. Have for that reason also tried examples from others but they all give the same error:
TypeError: array.remove is not a function
Here is some code I put in my generic-utill file:
    export {};
    declare global {
        interface Array<T> {
            remove(elem: T): Array<T>;
        }
    }
    
    Array.prototype.remove = function<T>(elem: T): T[] {
        return this.filter(e => e !== elem);
    };
And this in my test for the generic utill:
    describe('generic-util', () => {
        describe('Array', () => {
            it('should return array correctly using remove', async () => {
                const array = [1, 2, 3, 4];
                const result = array.remove(4);
                expect([1, 2, 3]).toStrictEqual(result);
            });
        });
    });
Could someone maybe explain what I am doing wrong since I don't really understand what I am missing.
