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
Existing libraries/frameworks that uses accessors and meta-programming to create classes from objects.
Uses mapped types, but mapped types don't preserve accessor-ness.
Could potentially have get/set modifiers in mapped types, just like readonly for readonlyness and ? for optionality.
{ +get [K in keyof T]: T[K] }
Proposal in TC39 that's championing get/set - probably should be mindful of that.
Set vs. Define? The error given here stemmed from adding "define property" semantics.
Unclear - the error is actually pretty useful.
Well...
Probably going to special-case this as a check for whether the property originates from a class.
Special-casing to classes seems okay - but this sounds like it's just a case of prototype vs. instance, and accessors are just a proxy for prototype vs. instance in this case.
virtual? Some sort of intention?
"I don't think Daniel is entirely incorrect" about prototype vs. instance
[[Editor's Note: This is a very proud day for me.]]
How do you track this?
prototype property of the class.
Maybe find a way to make that work for non-class things.
Could end up just being as bad of a heuristic of being on prototype as accessors
If you try to track the prototype property...
Breaks some code that takes advantage of futzing with .prototype
Potentially makes code "more nominal" - now have to differentiate between proto and instance?
Sounds like the safest thing is to do the class thing.
It's not safer!
It's safer for us to not get yelled at. 😄
How common are class factories nowadays?
Well... people end up writing functions and classes that wrap other classes.
One big problem is that people want safety, but you're not giving them the ability to "do the right thing" in a mapped type.
But then you also need to be able to declare get/set in object types - the original topic for today.
Curious to see what inferring getters/setters would do in terms of breaking changes, but not a trivial change.
As hard as it is to model, it would potentially be helpful.
Accessors in Object Types
#40733
get
/set
modifiers in mapped types, just likereadonly
for readonlyness and?
for optionality.{ +get [K in keyof T]: T[K] }
get
/set
- probably should be mindful of that.virtual
? Some sort of intention?prototype
property of the class.prototype
property....prototype
get
/set
in object types - the original topic for today.Reducing Bivariance Checks
#41979
strictFunctionTypes
, one would think that the original code snippet has an error.The text was updated successfully, but these errors were encountered: