Расширения

class Point {
    x: number
    y: number

    constructor(x: number, y: number) {
        this.x = x;
        this.y = y;
    }
}

interface Point {
    distanceTo(p: Point): number
}

Point.prototype.distanceTo = function(p: Point) {
    let d1 = Math.pow(this.x - p.x2)
    let d2 = Math.pow(this.y - p.y2)
    return Math.sqrt(d1 + d2);
}

let p1 = new Point(12)
let p2 = new Point(23)
let distance = p1.distanceTo(p2)
//distance is 1.4142...

console.log(`distance is ${distance}`)