0

I have the following interface:

interface AdvancedFilterState {
  customAttributesName1?: manualInputType,
  customAttributesValue1?: manualInputType,
  customAttributesName2?: manualInputType,
  customAttributesValue2?: manualInputType,

  ...and this can go forever
}

I want to have a key patter that matches customAttributesName and a number and customAttributesValue and a number.

To get this pass I use a way to generic patter like this

interface AdvancedFilterState {
  [key: string]: someType
}

can I do something like

type keytype = 'customAttributesName' + number;
interface AdvancedFilterState {
  [key: keytype]: someType
}

How to solve this in typescript?

0 Answers0