How can I define a type which either has block of extra properties (on top of isLocked
) or does not have them at all? Partial
guarantees all extra properties are optional. I want all of them to be required or not exist at all.
type AccountMetadata = {
roles: string[];
name: string;
}
type Account = {
isLocked: boolean;
} & (AccountMetadata | {})
type Account = {
isLocked: boolean;
} & (AccountMetadata | never)
Expected result
{ isLocked: boolean; roles: string[]; name: string } | { isLocked: boolean }