Saturday 11 March 2017

TypeScript warning => TS7017: Index signature of object type implicitly has any type

I am getting the following TypeScript warning -

Index signature of object type implicitly has any type

Here is the code that cases the warning:

Object.keys(events).forEach(function (k: string) {

  const ev: ISumanEvent = events[k]; // warning is for this line!!
  const toStr = String(ev);
  assert(ev.explanation.length > 20, ' => (collapsed).');

  if (toStr !== k) {
    throw new Error(' => (collapsed).');
  }
});

can anyone determine from this code block why the warning shows up? I cannot figure it out.

If it helps this is the definition for ISumanEvent:

interface ISumanEvent extends String {
  explanation: string,
  toString: TSumanToString
}



via Alexander Mills

No comments:

Post a Comment