I am defining a type as follows:
type Period = 'Monthly' | 'Yearly'
type Cycle = {
period: Period,
price: number
}
Now, I am looking to modify this type so that the 'period' property can also accept an empty string:
type Period = 'Monthly' | 'Yearly'
type EditableCycle = {
period: Period | '',
price: number
}
My initial idea was to use this hypothetical syntax:
type EditableCycle = Extend<Cycle, { period: '' }>
Can anyone provide guidance on how to implement this change?
The rationale behind this modification is to allow users to leave the 'period' field empty during editing, while ensuring that a valid Period will be assigned after validation.
Please note that the actual type structure is more intricate than Cycle, involving arrays and other complex elements. This is just a simplified example.