0

I have the following ENUM:

enum AllowedVals {
   A = 'A'
   B = 'B'
   C = 'C'
}

Now I have a type as follows

type Descriptor = {
 [key in keyof typeof AllowedVals]?: {
      name: string
      computeAge: () => number
    }
}

What I want is to have another key adjacent [key in keyof typeof AllowedVals] in the Descriptor type like so...

type Descriptor = {
 [key in keyof typeof AllowedVals]?: {
      name: string
      computeAge: () => number
    }
 totalAge: number // <--- Additing this raises errors
}

How can I property type this scenario?

Pila
  • 5,460
  • 1
  • 19
  • 30

0 Answers0