Say I have the following object array:
const shapes = [
{ name: 'circle', color: 'blue' },
{ name: 'square', size: 42 },
{ name: 'rectangle', color: 'blue' }
];
type ShapeName = typeof shapes[number]['name']; // ShapeName is type 'string' but I would want: 'circle'|'square'|'rectangle'
I would like to have a type "ShapeName" that contains the values of the name properties of my objects. However, attempting to do so just gives me the 'string' as type. Is there a way to narrow it down to 'circle'|'square'|'rectangle'.