framework7
framework7 copied to clipboard
Improve types
<!-- svelte -->
<!-- same -->
<Button large={true} small={true}>Button</Button>
<Button small={true}>Button</Button>
<!-- same -->
<Button outline={true} fill={true}>Button</Button>
<Button fill={true}>Button</Button>
This applies to many components.
Is your feature request related to a problem? Please describe. No.
Describe the solution you'd like Use unions, intersection, etc. so that the types match the code.
type OldButton = {
text: string;
/* ...other */
large: boolean;
small: boolean;
};
let old_button: OldButton = {
text: "",
/* ...other */
large: true,
small: true,
};
type NewButton = {
text: string;
/* ...other */
} & ({ large: true; small?: false } | { large?: false; small: true });
let new_button1: NewButton = { //error
text: "",
/* ...other */
large: true,
small: true,
};
let new_button2: NewButton = {
text: "",
/* ...other */
large: true,
};
let new_button3: NewButton = {
text: "",
/* ...other */
small: true,
};
let new_button4: NewButton = {
text: "",
/* ...other */
large: false,
small: true,
};
Describe alternatives you've considered Write about all such cases in the documentation.
Additional context This will help us better understand how the framework works and what properties components need.