I have object properties being looped through generically, some of the number props needed additional calculations, and I ended up with this (simplified) situation. Any help would be greatly appreciated: I get an "unassignable" compile error on both lines in the main function.
interface Data {
a: number,
b: number,
c: number
}
const data = {
"a": 1,
"b": 2,
"c": 3
}
const ar: (keyof Data)[] = ["a", "b", "c"]
type Allowed = Omit<Data, "c">
var allowedAr: (keyof Allowed)[] = [ "a", "b" ]
function main(key: keyof Data) {
if (allowedAr.includes(key))
allowedFn(key)
}
function allowedFn(key: keyof Allowed) {}