I'm curious to know if I can have a type that would be unique when used in an array.
Let's say I have this type:
type Book = {
name: string
author: string
}
const books: Book[] = [
{
name: 'Nature',
author: 'Tom',
},
{
name: 'Nature',
author: 'Jake',
},
]
I want Typescript to throw an error/warning on the name because the value Nature is duplicated in the array.
Is there a way to achieve that ?
