Is it possible to get the literal value from a type? For example:
const createRecord = <T>(type: T, data: number) => ({ type, data })
const r = createRecord<'TYPE_1'>('TYPE_1', 101)
// The type of `r` is { type: "TYPE_1"; data: number; }
But I would like to omit the first parameter and simply write:
const createRecord = <T>(data: number) => ({ type: typeof T, data })
const r = createRecord<'TYPE_1'>(101)
Of course the previous example doesn't work because typeof T is a type, not a value.