class A implements Inspectable.Inspectable {
constructor(readonly x: number) {}
toString(): string {
return 'foo';
}
toJSON(): unknown {
return { x: this.x };
}
[Inspectable.NodeInspectSymbol](): unknown {
return this.toJSON();
}
}
export const make = ({x}:{readonly x: number}): A => new A(x);
// Ouch I forgot to call make(). The compiler does not warn me
export const addOne = (a: A): A => pipe(a, Struct.evolve({ x: Number.sum(1) }));
const a = new A(1);
const a1 = addOne(a);
// [object Object] instead of foo. Can lead to bugs hard to identify
console.log(a1.toString());
class A implements Inspectable.Inspectable {
constructor(readonly x: number) {}
toString(): string {
return 'foo';
}
toJSON(): unknown {
return { x: this.x };
}
[Inspectable.NodeInspectSymbol](): unknown {
return this.toJSON();
}
}
export const make = ({x}:{readonly x: number}): A => new A(x);
// Ouch I forgot to call make(). The compiler does not warn me
export const addOne = (a: A): A => pipe(a, Struct.evolve({ x: Number.sum(1) }));
const a = new A(1);
const a1 = addOne(a);
// [object Object] instead of foo. Can lead to bugs hard to identify
console.log(a1.toString());