First lock down your array items using <const>
assertion so they are the limited set.
Now you can play with type of index values. e.g.:
typeof valueOptions[0]
can only be "a"
typeof valueOptions[1]
can only be "b"
typeof valueOptions[number]
can be either of "a", "b", "c"
So for your context you would use number
as you are not looking for any specific index:
const valueOptions = <const>["a", "b", "c"]; // lock it down with const assertion
interface IContainerProps {
key: typeof valueOptions[number]; // typeof index members of valueOptions
}
const a: IContainerProps = {
key: "b"
};
So for small subsets you can create a union type:
interface IContainerProps {
key: typeof valueOptions[1] | typeof valueOptions[2];
}
const a: IContainerProps = {
key: "b"
};
const b: IContainerProps = {
key: "c"
};