If I have a type like
export interface MyObject {
id: number
title: string
}
and I create an array like this
const myArray: MyObject[] = [
{
id: 2358,
title: 'Item 1'
},
{
id: 85373,
title: 'Item 2'
}
]
Is there a way to define a type that only allows values that have appeared as an id in the array? So in this case it would look like.
type DesiredType = 2358 | 85373
Here is a link to a Codewich where I have tried a few things to no avail.