Is it possible to define a TypeScript type for an object where the key values are the literal key names themselves? For example:
declare const $: SpecialGenericType
$.prop // typed as the literal value "prop"
const values = [
$.a,
$.b,
$.c
] as const
// values has the type (and value) ["a", "b", "c"]
The $ object could be implemented using a Proxy, but I'm not sure how to implement the SpecialGenericType. The type would need to allow any string as a key, but the values would need to be typed as the string literal of its key name (so Record<string, string> does not work in this case). For example, values above would have the tuple type ["a", "b", "c"].