I have a collection as follows:
var myData = [{ id: 'a', value: 1}, { id: 'b', value: 2 }, { id: 'c', value: 3}]
and I am trying to create a function that only accepts certain ids as parameters
function checkId(id: 'a' | 'b' | 'c') { /* */ }
I attempted the following:
var myData = [{ id: 'a', value: 1}, { id: 'b', value: 2 }, { id: 'c', value: 3}]
type Data = typeof myData;
type IdType = keyof Data[number]['id'];
but it resulted in the id being displayed as:
type IdType = number | typeof Symbol.iterator | "toString" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | ... 30 more ... | "padEnd"