Is there a way to dynamically pass a value to the Grid size props like XL in TypeScript?
For instance, *Update for further clarification
import Grid, { GridSize } from "@material-ui/core/Grid";
let value: GridSize = 12/4;
xl={value}
Error: Type 'number' is not assignable to type 'GridSize'
If I define a custom type as,
type gridSize = boolean | "auto" | 1 | 2 | 12 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | undefined
Error: Type 'number' is not assignable to type 'boolean | "auto" | 1 | 2 | 12 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | undefined'.ts(2769)
The issue remains the same - how can a number be converted to this type?
** Answer Marked Below that helped, In the end I cast it as GridSize and added some unit tests around it for edgecases.
let value = 12/4 as GridSize