Home > Software design >  Duplicate index signature for type 'number' using Typescript
Duplicate index signature for type 'number' using Typescript

Time:10-19

I have a nested array inside another array and keep getting the following error Duplicate index signature for type 'number' using Typescript this is my interface. If I remove

[assets: number]: {
          ratio: string,
          uri: number,
        }

The error is gone. Any thoughts on how to get around this?

export interface EventsProgramState {
  status: string,
  tmsId: string,
  endpoint: string,
  [programs: number]: {
    TMSId: string,
    rootId: number,
    connectorId: string,
    seriesId: number,
    updateId: number,
    updateDate: string,
    programTitle: string,
    eventTitle: string,
    description: string,
    gameDate: string,
    gameTime: string,
    gameTimeZone: string,
    venue: string,
    venueId: number,
    season: string,
    seasonType: string,
    [teams: number]: {
      team: string,
      teamBrandId: number,
      isHome: boolean
    },
    [assets: number]: {
      ratio: string,
      uri: number,
    }
  }  
}

CodePudding user response:

What are your trying to achieve ?

Wouldn't array be what you are looking for ?

export interface EventsProgramState {
  status: string,
  tmsId: string,
  endpoint: string,
  [programs: number]: {
    TMSId: string,
    rootId: number,
    connectorId: string,
    seriesId: number,
    updateId: number,
    updateDate: string,
    programTitle: string,
    eventTitle: string,
    description: string,
    gameDate: string,
    gameTime: string,
    gameTimeZone: string,
    venue: string,
    venueId: number,
    season: string,
    seasonType: string,
    teams: Array<{
      team: string,
      teamBrandId: number,
      isHome: boolean
    }>,
    assets: Array<{
      ratio: string,
      uri: number,
    }>
  }  
}
  • Related