I am trying to use TypeScript to describe the interface for an object. Faced such a problem: How to set an opportunity with help of an interface, limited values in an array. Example:
export interface IChannel {
title: string
name: string,
signal: ["discrete", "analog", "text"] | ["discrete", "analog"] | ["discrete"] | ["analog"] | ["text"] | ["analog", "text"], // OMG... IT"S BAD !!!
enabled: boolean
"description": string,
"isChangeVisibility": boolean
}
Need filed signal
= ["discrete" OR/AND "analog" OR/AND "text"]
This field must contain only these values. Array length (may be 1, 2 or 3 elements)
Thanks for any help. I will sit experimenting.