-
-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proof of concept for using the keyof operator instead of a function parser #486
base: master
Are you sure you want to change the base?
Conversation
the keyof operator. Calls to .ensure() allowed both a string and a function as argument. The function was never actually executed, but parsed to get the string property name. The same effect can be achieved by using the keyof operator. In this case, only strings can be provided that are a property of the given class. Initial version, requiring the programmer to explicitly state the object class each time .ensure() is executed. This is because .ensure() is a static function, so the type cannot be determined yet. Fixes aurelia#485.
the keyof operator. Calls to .ensure() allowed both a string and a function as argument. The function was never actually executed, but parsed to get the string property name. The same effect can be achieved by using the keyof operator. In this case, only strings can be provided that are a property of the given class. Initial version, requiring the programmer to explicitly state the object class each time .ensure() is executed. This is because .ensure() is a static function, so the type cannot be determined yet. Fixes aurelia#485.
TimVevida seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Note that this is a breaking change, the Aurelia Validation docs state:
So the expression syntax is encouraged. This patch would change this and allow only string property names, which are then checked using the |
@TimVevida awesome! Would it be feasible to ship |
That is a great idea. |
cool- any chance you could amend the PR with that change? |
I think using a string rather than a function for specifying the property is a great idea. However it should be noted that you loose a little bit of functionality: while the string value is checked by the transpiler against the list of properties on your object, the value is not updated if you use automatic refactoring to rename the property. When using a function, the rename can be automatically applied. Perhaps the recommendation should be switched from function to string, but the function syntax not be deprecated? EDIT: See also microsoft/TypeScript#11997 |
Calls to .ensure() allowed both a string and a function as argument. The function was never actually executed, but parsed to get the string property name. The same effect can be achieved by using the keyof operator. In this case, only strings can be provided that are a property of the given class.
Proof of concept, requiring the programmer to explicitly state the object class each time .ensure() is executed. This is because .ensure() is a static function, so the type cannot be determined yet.
Fixes #485.