You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Write-only properties have not been the most type-checked area of the language (#21759), but in some cases though we can almost always tell it's not what's intended and throw some error messages in there.
π Motivating Example
The example below (playground link here) demonstrates a peculiar case that could definitely benefit from some type error messages, but the suitable situations may go well beyond this simple case and are open for discussion.
classA{private_v=[0];setv0(v: number){this._v[0]=v;}getarray(): Readonly<number[]>{returnthis._v;}}constx=newA();x.v0=10;// correct usagex.v0+=10;// incorrect usage (results in NaNs), which should not pass type check!
π» Use Cases
The text was updated successfully, but these errors were encountered:
@andrewbranch would you consider reopening this in light of the introduction of Variant Accessors, or at least include it if/when #43662 comes along? Should we just update that ticket to make sure that the write-only use case is considered?
Suggestion
π Search Terms
write-only properties
strict type check
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
Write-only properties have not been the most type-checked area of the language (#21759), but in some cases though we can almost always tell it's not what's intended and throw some error messages in there.
π Motivating Example
The example below (playground link here) demonstrates a peculiar case that could definitely benefit from some type error messages, but the suitable situations may go well beyond this simple case and are open for discussion.
π» Use Cases
The text was updated successfully, but these errors were encountered: