// 3rdparty type, cannot be changed
interface Foobar {
foo: number,
// due to exactOptionalPropertyTypes=true, undefined cannot be assigned
bar?: string
// there can be a lots of other optional props here
}
declare const input: Foobar;
const optional = 'foo' as string | undefined;
// This works, but what if there are many more optional types
const result = optional ? { ...input, bar: optional } : input;
// Maybe a new helper for Struct???
const result1 = Struct.setOptional(input, 'bar', optional);
// With pipe many optional props can be handled properly
const result2 = pipe(input, Struct.setOptional('bar', optional));
// 3rdparty type, cannot be changed
interface Foobar {
foo: number,
// due to exactOptionalPropertyTypes=true, undefined cannot be assigned
bar?: string
// there can be a lots of other optional props here
}
declare const input: Foobar;
const optional = 'foo' as string | undefined;
// This works, but what if there are many more optional types
const result = optional ? { ...input, bar: optional } : input;
// Maybe a new helper for Struct???
const result1 = Struct.setOptional(input, 'bar', optional);
// With pipe many optional props can be handled properly
const result2 = pipe(input, Struct.setOptional('bar', optional));