Functional Programming Approach to Methods in TypeScript

Hi, have a question regarding functional programming in TS as a whole.
So I have usually created classes, and put methods inside of them to make intellisense easy.
For example,

export class Position extends Data.Class<{
    x: number;
    y: number;
}> {
    toString(): string {
        return `(${this.x}, ${this.y})`;
    }

    getManhattanDistanceTo(other: Position): number {
        return Math.abs(this.x - other.x) + Math.abs(this.y - other.y);
    }

    isAdjacentTo(other: Position): boolean {
        return Math.abs(this.x - other.x) + Math.abs(this.y - other.y) === 1;
    }
}



I would call the methods on the class. However, I do not believe this is very idiomatic, especially in the FP realm.
How would most people do this?
Just defining it as an interface, and exporting functions from the same file?
Wouldn't the codebase then be littered with functions of the same name, such as toString() ?
Was this page helpful?