Slide 81
Slide 81 text
実験
:
クラスを分解するコンバータ
export type Point = {
x: number;
y: number;
};
export function Point$new(x: number, y: number): Point {
const self: Point = { x: x, y: y };
console.log("Point created", x, y);
return self;
}
export function Point$distance(self: Point, other: Point) {
return Math.sqrt(Math.pow(self.x - other.x, 2) + Math.pow(self.y - other.y, 2));
}
$ npm install @mizchi/declass
$ npx declass input.ts # -o output.ts