🔎 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
🔎 Search Terms
"readonly", "iife"
🕗 Version & Regression Information
⏯ Playground Link
No response
💻 Code
🙁 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:
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