Примерно так
type ToDo = {title: 'ToDo', cardList: []}
type Testing = {title: 'Testing', cardList: []}
interface StateType {
user: string,
columns: (ToDo | Testing)[]
}
const state: StateType = {
user: 'User',
columns: [
{title: 'ToDo', cardList: []},
{title: 'Testing', cardList: []},
],
}
https://www.typescriptlang.org/play?#code/C4TwDgpg...
Или даже так:
enum kinds {
ToDo = 'ToDo',
Testing = 'Testing',
}
type Column = {title: kinds, cardList: []}
interface StateType {
user: string,
columns: Column[]
}
const state: StateType = {
user: 'User',
columns: [
{title: kinds.ToDo, cardList: []},
{title: kinds.Testing, cardList: []},
],
}
https://www.typescriptlang.org/play?ssl=19&ssc=2&p...