Right now, even simple getters trigger the "Enable unsafe getters" warning:
class 鈥
_isActive:boolean = false;
get isActive():boolean {
return this._isActive;
}
}
I understand that for complicated getters/setters, side effects are hard to track; however, simple getters (like the example) are a common pattern for exposing a read-only variable. Is it reasonable to make support for getters that don't contain function calls enabled by default?
Of course, if you get a property from another object and the other object's getter contains a side effect, that might be hard for Flow to track. (I imagine that's why support is currently in the state it is.) However, if Flow is also checking the source getter, it would report the potential side-effect there.
I'd even be OK with something like experimental.enable_simple_getters=true. It just makes me cringe that I'm enabling an unsafe flag for something that should be both common and harmless.
This is intentional. Getters/setters are unsafe because we treat them as regular object get/sets when they are used instead of function calls.
Most helpful comment
I'd even be OK with something like
experimental.enable_simple_getters=true. It just makes me cringe that I'm enabling anunsafeflag for something that should be both common and harmless.