Skip to content

Index signature of object type, not supported by implementing class #5685

@Merott

Description

@Merott

With the following code, and the noImplicitAny flag on, I get the error TS7017: Index signature of object type implicitly has an 'any' type.

interface ICurrency {
  [key: string]: any;

  currencyId:number;
  // ...
}

class Currency implements ICurrency {
  public currencyId:number;
  // ...
}

let currency = new Currency();

let x = 'currencyId';
console.log(currency[x]);  // error

console.log(currency['currencyId']);  // ok

Surely that's a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions