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
{{ message }}
Repository navigation
Flow is improperly narrowing getter valuesΒ #56899
A getter is a function, not a plain type, and should behave like one, even though it doesn't have wings.
The getter is converted to a readonly plain property (probably at point of declaration) as can be seen by tool tipping to x which shows (parameter) x: { readonly r: 1 | 2; readonly v: 1 | 2; f: () => 1 | 2; }. Related to setter inferred from union has incorrect varianceΒ #56894.
Oh what a shame. Now if #56894 is deemed a fixable bug, then setters will be acting like (and hopefully displayed as) functions, while getters will be acting like (and continue to be displayed as?) readonly plain properties. Maybe it would be best to do them as a pair, with a flag of course for back compatibility. Just thinking out loud. Pay no notice.
Activity
fatcerberus commentedon Dec 29, 2023
Duplicate of #56149. That TypeScript is βlossyβ and encodes the getter as a regular property in the type is more or less by design.
fatcerberus commentedon Dec 29, 2023
Maybe some day we could have a
volatilekeyword, like Cβ¦craigphicks commentedon Dec 30, 2023
Oh what a shame. Now if #56894 is deemed a fixable bug, then setters will be acting like (and hopefully displayed as) functions, while getters will be acting like (and continue to be displayed as?) readonly plain properties. Maybe it would be best to do them as a pair, with a flag of course for back compatibility. Just thinking out loud. Pay no notice.
typescript-bot commentedon Jan 5, 2024
This issue has been marked as "Working as Intended" and has seen no recent activity. It has been automatically closed for house-keeping purposes.