I have this
<code>interface MyType {id: string; label: string };
const t = [
{id: 'a' as const, label: 'A'},
{id: 'b' as const, label: 'B'}
] satisfies MyType;
</code>
<code>interface MyType {id: string; label: string };
const t = [
{id: 'a' as const, label: 'A'},
{id: 'b' as const, label: 'B'}
] satisfies MyType;
</code>
interface MyType {id: string; label: string };
const t = [
{id: 'a' as const, label: 'A'},
{id: 'b' as const, label: 'B'}
] satisfies MyType;
so that I can later do
<code>type Ids = (typeof t)[number]['id'];
</code>
<code>type Ids = (typeof t)[number]['id'];
</code>
type Ids = (typeof t)[number]['id'];
so Ids will be ‘a’ | ‘b’;
This works well. But I would like to do it in a way that I don’t need to define as const in each id. Also ‘label’ should be mutable, so
<code>const t = [
{id: 'a', label: 'A'},
{id: 'b', label: 'B'}
] as const satisfies MyType;
</code>
<code>const t = [
{id: 'a', label: 'A'},
{id: 'b', label: 'B'}
] as const satisfies MyType;
</code>
const t = [
{id: 'a', label: 'A'},
{id: 'b', label: 'B'}
] as const satisfies MyType;
is not a solution for me.
How can I do it?