Typescript: index signature is missing in type when extending interface

Declare Test like so:

interface Test extends T {
  relationships: {
    [key: string]: Relationship;
    dcs: Relationship;
  };
}

However, as you've noticed you end up having to declare the indexer again when you actually implement the interface. You could save some typing by doing this:

interface T {
  relationships: {
    [key: string]: Relationship;
  };
}

interface TestRelationships {
   [key: string]: Relationship;
   dcs: Relationship;
}

interface Test extends T {
  relationships: TestRelationships;
}

class T1 implements Test {
  relationships: TestRelationships;
}

Tags:

Typescript