I'm confused to why following errors, I have character interface
interface Character {
race: "ORC" | "ELF" | "HUMAN" | "DWARF"
}
And another interface tavern
interface Tavern {
races: Character['race'][]
}
Idea here is that races is an array of strings that can only be "ORC" | "ELF" | "HUMAN" | "DWARF"
For some reason I get an error when I use it like this
const tavern: Tavern = {
races: ["ORC", "ELF", "HUMAN", "DWARF"]
}
Error reads as follows
[ts] Type '{ races: string[] }' is not assignable to type 'Tavern'. Types of property 'races' are incompatible. Type 'string[]' is not assignable to type '("HUMAN" | "ORC" | "ELF" | "DWARF")[]'. Type 'string' is not assignable to type '"HUMAN" | "ORC" | "ELF" | "DWARF"'.
stringbut something este is at work typescriptlang.org/play/…