Closed
Description
TypeScript Version: 2.4.2
Code
type Foo = Readonly<{
[n: number]: string;
}>;
type Bar = {
readonly [n: number]: string;
};
function foobar(): void {
const x: Foo = {
[0]: 'asdf',
[1]: 'fdsa',
[-1]: 'dddd',
};
const y: Bar = {
[0]: 'qwer',
[1]: 'rewq',
[-1]: 'eeee',
};
const z: string = x[0] + y[0];
}
Expected behavior:
No Error
Actual behavior:
Shows error Element implicitly has an 'any' type because type 'Readonly<{ [n: number]: string; }>' has no index signature.
for x[0]
.