-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[BUGFIX beta] CPs check presence of getter function #12156
[BUGFIX beta] CPs check presence of getter function #12156
Conversation
Bugfix is probably not the best tag, but I couldn't find a better one. |
is a CP \w setter only considered valid? |
I wouldn't consider it valid. Does ES5 to have setters without getter? I think you can have readonly properties, but not writeonly, do you? |
yes |
@stefanpenner You can define only a setter, but that's because the getter will have a default (just getting the property). In other words, A computed property needs to execute something. |
Actually it doesn't, as the return value of the (I'm not trying to be pedantic, rather enumerating the possible scenarios this assertion without modification will cause grief for) I suspect we can just assert that either getter or setter exist, and my concerns are covered. |
That cache we are thinking we might remove? Seriously speaking, I can change the assertion to check that you either pass a getter or a setter, but think that a CP with only a setter is a case so weird that we should make it less ergonomic than the most common scenario, a brainfart on the line of: age: computed('years'),
// or
age: computed({
het() {},
set() {}
}); |
yes weird, but it is possible today. So we should work within the constraints our users currently have, not impose additional. If the assertion checks that at-least the getter or the setter is present, i think that is a win. |
age: computed({
het() {},
set() {}
}); We can also assert if we find any keys other than |
1d4a701
to
5b0ab81
Compare
good idea |
5b0ab81
to
8371c60
Compare
Ok, added assertions for:
computed('nothing')
computed('array', []);
computed('emptyobj', { })
computed('nothing', {
het() {},
set() {}
}) Any more idiomatic way of checking this last one. Also, is there any reason to use |
3ab6eb5
to
91232ec
Compare
Seems to die when loaded by Phantom (see Travis failures). Might be the |
91232ec
to
85d744f
Compare
85d744f
to
f50e6c4
Compare
[BUGFIX beta] CPs check presence of getter function
Today I spent some time tracking a cryptic stack trace.
It turns out that I typed
years: computed('age')
instead ofyears: computed.alias('age')
This will check the presence of the getter function in creation time, instead of failing when you try to access the property, usually 10 minutes after writing it when you have no idea where to look.