There is a way to declare the type of dynamic class property if it's accessed by [] operator, like on the following example:
class Foo {
[key: string]: number;
}
let a = new Foo();
let b = a['bar']; //Here, the compiler knows that b is a number
But is there a way to declare the same thing, without [] operator?
A way to write this:
let a = new Foo();
let b = a.someProperty;
And letting TypeScript knows that someProperty is of type number, because we say to it: All unknown properties on Foo are of type number.