0

Why this definition is all right

interface ErrorContainerNum2 { 
  id: string;
  [prop: number]: number;
}

and this definition vscode complaints "Property 'id' of type 'number' is not assignable to 'string' index type 'string'"?

interface ErrorContainerNum3 { 
  id: number;
  [prop: string]: string;
}
william007
  • 17,375
  • 25
  • 118
  • 194
  • 1
    Is it https://stackoverflow.com/questions/61431397/how-to-define-typescript-type-as-a-dictionary-of-strings-but-with-one-numeric-i ? – b2f Apr 30 '22 at 06:41

0 Answers0