Closed
Description
TypeScript Version: 2.4.2
Code
class Environment {
readonly [key: string]: Domain;
constructor (domains: Domain[]) {
for (let domain of domains) {
this[domain.name] = domain;
}
}
}
Expected behavior:
I'm assigning the values in the constructor, so I would assume that the readonly modifier would not take effect yet.
Actual behavior:
Index signature in type 'Environment' only permits reading.
(property) Domain.name: string
Is this a bug or does TypeScript disallow assignment to readonly indexers due to implementation difficulties?