Remove remaining traces of wrapComputed.#152
Conversation
This is likely not correct, you would need to convert the macro function to detect whether or not it is being called as a decorator also. // this function cannot be called as a decorator
function someComputedMacro() {
// the function this `computed` returns can
return computed();
}Unless |
|
|
||
| const decoratorExpr = instanceProp.modifiers.reduce( | ||
| let decoratorExpression = | ||
| ['computed', 'service', 'controller'].includes(decoratorName) && decoratorArgs.length === 0 |
There was a problem hiding this comment.
Should we check against hard coded decorator names? Would it work in case they are imported with different local name? For example service is imported as inject or some other local name
There was a problem hiding this comment.
The deocratorName here is the name that it was imported from not what is named in the module. I'll add a specific test case for that.
| decoratorExpression | ||
| ); | ||
|
|
||
| if (!instanceProp.modifiers.length) { |
There was a problem hiding this comment.
I think we can move this before the reduce statement above
| import Service, { service as injectService } from '@ember/service'; | ||
|
|
||
| export default Service.extend({ | ||
| something: service(), |
There was a problem hiding this comment.
Should this be something: injectService()?
|
|
||
| export default Service.extend({ | ||
| something: service(), | ||
| otherThing: service('some-thing') |
* Moves `setRuntimeData` _before_ `setDecorators` so that we can more easily setup local state in `setDecorators` * Removes remaining references to `wrapComputed` * Adds `.isComputed` boolean to `EOProp` class to allow us to track when the runtime data indicates that a given property was a computed property. * Update decorator building code to avoid creating a call expression for decorators that are returning computed properties without arguments (e.g. use `@someComputedMacro` vs `@someComputedMacro()`)
f14077e to
3e7962a
Compare
|
Going to merge this now that tests are green and keep working, there's a fair amount more to do/cleanup in general |
setRuntimeDatabeforesetDecoratorsso that we can more easily setup local state insetDecoratorswrapComputed* Adds.isComputedboolean toEOPropclass to allow us to track when the runtime data indicates that a given property was a computed property.@someComputedMacrovs@someComputedMacro())First step in addressing #142 and #144