Is it any operator, or generic solution to take copy of nullable object, and the result should be the same nullable type?
Like here, but ...
spread operator will not retain type.
const [startPaymentIn, setStartPaymentIn] = useState<
StartPaymentIn | undefined
>(undefined);
let startPaymentIn2: StartPaymentIn | undefined = {
...startPaymentIn,
};
CodePudding user response:
This can retain the type...
startPaymentIn && {...startPaymentIn}