Closed PinkaminaDianePie closed 9 years ago
Yes, we need to expand the grammar to allow computed field names. I'm going to try and work on updating the proposal this week (in prep for the meeting next week) and I'll include this in those updates.
(leaving this issue open as a tracker)
@jeffmo What needs to be expanded? The PropertyName
production is being used currently, and that allows computed names.
Oh you're right, I forgot that was changed already :p
So then my comment above is outdated and this is already possible as specified here: https://github.com/jeffmo/es-class-static-properties-and-fields#145-class-definitions
Need more description about computed properties. It's a very important thing for class instance fields, case it only way to use
Symbol
. Ill explain it on usecase in my project. I'm writing simple orm with java-like declarations, i.e. in Hibernate framework. In this case all fields in data model and links between them are described as instance fields with decorators:What about
ActiveRecord
class? it needs to store computed metadata about DB schema, about fields, changed by user and needed to save (for example this information can be collected by proxy object). But i dont want to show this metadata bytoString()
orJSON.stringify()
methods. I want to show user only its own data. So ill store this metadata inSymbol
, and this metadata needed for each model instance. SoActiveRecord
needs to be something like this:As instance fields is declarative way to describe fields, they will be often used with class decorators in libraries and frameworks, so many people will used them with symbols to hide frameworks metadata. I request better description with using instance fields with computed properties.