radash icon indicating copy to clipboard operation
radash copied to clipboard

Improve the type coverage of clone function

Open mertdy opened this issue 2 years ago • 0 comments

  • The current clone function throws an error when the parameter is 'undefined' or 'null', even though 'null' is considered as 'object' by TS.

  • Since the current clone function creates an empty object and assign the old props, the new object is actually not an copy of the given object when the given object is a class instance. It loses the parameter's class definition.

  • The current clone function can only clone objects and arrays but not primitive types or functions. By adding a primitive check, its type coverage can be increased.

mertdy avatar Sep 03 '22 00:09 mertdy