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
Getter on class is present in inferred type from object-spreading instance #26279
I realize that spreading a class instance is not desirable.
I also realize (after searching for dupes and reading similar issues for a couple hours) that there are design limitations around TS not tracking own/enumerable properties.
But, from what I understand, it makes a guess and correctly omits methods on classes from the inferred type of spreading an instance of that class. Since getters on classes are also on the prototype, it seems like inconsistent behavior that methods are omitted from the inferred type but get/set accessors are not. Even though the compiler doesn’t really track what properties are own enumerable, it seems like it could use similar heuristics to determine, in this simple case, that the getter won’t be present on the spread object.
P.S. – thanks for your time, and apologies in advance if this does turn out to be a dupe that I couldn’t find 😬
Activity