ts-copyable
Type-safe .copy() for TypeScript inspired by Scala case-class
How to install
$ npm install --save ts-copyable
How to use
Before
After
;
Then your Person
class is copyable!
; p1.copy;// => Person("jack", 2) p1.mapCopy;// => Person("jack", 11)
How about type-safety?
; p1.copy;// Compile error (GOOD!) p1.copy;// Compile error (GOOD!) p1.mapCopy;// Compile error (GOOD!)