简体   繁体   中英

how to define interface for the following date type

I am trying to define interface type for this.usedPercentageFilterOptions . Do you know if the following declaration of interface is correct?

`

  interface Item {
     filterPillValue: string,
     id: string,
    label: string
}
interface Items {
    radio: Item,
    checkbox: Item
}
   public usedPercentageFilterOptions: Items[]

   this.usedPercentageFilterOptions = [
        {
          radio:  { filterPillValue: 'used%', id:'filter-used-%', label: 'Used %' },
          checkbox: [
            { filterPillValue: 'Full', id:'filter-full', label: 'Full' },
            { filterPillValue: 'Reached Critical threshold', id:'filter-critical-threshold', label: 'Reached Critical threshold' },
            { filterPillValue: 'Reached Warning threshold', id:'filter-warning-threshold', label: 'Reached Warning threshold' },
            { filterPillValue: 'Not reached threshold', id:'filter-not-reached-threshold', label: 'Not reached threshold' }
          ]
        }
    ];`

Try this

 export interface Cb {
       filterPillValue?: string;
       id?: string;
       label?: string
    }

And

export interface UsedPer {
       radio?: Cb;
       checkbox?: Cb[]
   }

Hope useful

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM