Closed
Description
π Search Terms
"readonly", "iife"
π Version & Regression Information
- This is the behavior in every version I tried
β― Playground Link
No response
π» Code
class Foo {
readonly bar: string = "";
constructor() {
(() => { this.bar = "test"; })();
}
}
π Actual behavior
Fails with Cannot assign to 'bar' because it is a read-only property.
error
π Expected behavior
Should work in exactly same way as:
class Foo {
readonly bar: string = "";
constructor() {
this.bar = "test";
}
}
Additional information about the issue
I assume that's expected for some reason, and I'd love to learn what are the logical grounds for that