Is something like this possible? It works for objects, but what about arrays?
const myArray = ["foo", "bar"]
function pick(what: keyof myArray) { // keyof is obviously wrong
}
pick("foo") // okay
pick("inexistent") // error, "inexistent" does not exist in myArray