Open WinterSmileSB101 opened 1 year ago
No, no plans, and that line is essential.
Would I like to support structuredClone? Yes. Am I going to investigate this matter right now or in the near future? Probably not.
OK, thanks.
Just landed here as structured clone is finally becoming the goto for deep cloning an object.
@WinterSmileSB101 what did you end up doing to get around this?
For now here's my painful "fix" that conforms to typing.
Here's a simple example without crazy nesting involved:
const { decimalOne, decimalTwo, ...withoutDecimals } = originalObject // originalObject satisfies SomeType
const newObjectWithoutDecimals = structuredClone(withoutDecimals)
const newObject: SomeType = {
...newObjectWithoutDecimals,
decimalOne: new Decimal(decimalOne),
decimaltwo: new Decimal(decimalTwo),
}
Decimal.js seems to not support structuredClone, this method will throw DataCloneError because of decimal instance contains a function(
constructor
) due to this line code: https://github.com/MikeMcl/decimal.js/blob/master/decimal.js#L4294Any plans to support it?