Reputation: 323
How make a relative required (only make required when other attribute is true)?
Example:
interface ITesteProps {
required: boolean
content{!required && '?'}: string
}
I know it's not a valid code. How make the content required only when the required === true? Is it possible?
Upvotes: 1
Views: 155
Reputation:
you can do it like that:
type ITesteProps = { requred: true; content: string; } | {required: false; }
Upvotes: 3