One important concept I need to convey is that if one of these fields exists, then the other must also exist. When these two fields are peers within the same scope, it can be challenging to clearly communicate this connection.
Consider the example of defining a Pipeline
:
type Status = 'running' | 'finished' | 'error' | 'inherited'
type Pipeline = Array<{
name: string
status: Status
parent?: string // problematic. only needed for 'inherited'.
}>
In this scenario, how could you effectively demonstrate that the parent
field should always be specified when status='inherited'
?