-
Notifications
You must be signed in to change notification settings - Fork 16
refactor(tracked): minimally invasive stage 2 decorators support #22
refactor(tracked): minimally invasive stage 2 decorators support #22
Conversation
@@ -90,15 +90,13 @@ function installTrackedProperty(_target: object, key: string | symbol, descripto | |||
} | |||
|
|||
return { | |||
configurable: true, | |||
// TODO: correcting a misspelling caused chrome to error | |||
// writable: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW this is intentional. I fixed the same problem in this PR with a detailed analysis: salsify/ember-css-modules#118
btw, this is actually semantically incorrect: sparkles-component/addon/tracked.ts Lines 76 to 86 in e320c6f
Initializers are evaluated eagerly. This initializer is only first run, when the field is accessed. |
type TrackedDecorator = TSDecorator & ((...args: string[]) => TSDecorator); | ||
|
||
export const tracked: TrackedDecorator = decoratorWithParams((desc, params = []) => { | ||
assert(`@tracked - Can only be used on class fields.`, desc.kind === 'field' || desc.kind === 'method'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you wanna be really correct.
assert(`@tracked - Can only be used on class fields.`, desc.kind === 'field' || desc.kind === 'method'); | |
assert( | |
`@tracked - Can only be used on class fields.`, | |
desc.kind === 'field' || desc.kind === 'method' && ( | |
typeof desc.descriptor.get === 'function' || | |
typeof desc.descriptor.set === 'function' | |
) | |
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to confirm things still work properly, I'd like to get ember-try scenarios for ember-cli-typescript@1 as well.
@rwjblue I was already working on these scenarios and even found some bugs (upstream 😜). Didn't yet get to push it here though. |
This PR is pending approval and release of ember-decorators/ember-decorators#336, so I can replace 02546ae with the proper release of But other than that, I am done. Would love another round of 👀 on this! |
@rwjblue ember-decorators/ember-decorators#336 is merged. If you can find time to release it, I can update this PR and you can merge and release it as well. 🚀 |
@buschtoens there is a conflict o.o |
but also, I can confirm this branch is 💯 |
Once there's a new release of ember-decorators, I can update this PR and remove the merge conflict in |
Co-Authored-By: buschtoens <[email protected]>
Co-Authored-By: buschtoens <[email protected]>
Co-Authored-By: buschtoens <[email protected]>
Co-Authored-By: buschtoens <[email protected]>
d22743c
to
d0f93f6
Compare
@rwjblue I've updated to @ember-decorators v4.0.0 and rebased onto the latest master. |
While trying to pre-publish this as
I've submitted ember-cli/ember-compatibility-helpers#31 in an attempt to generate the types upstream. In the meantime, I've added declaration file for it here. For the |
I don't understand, why did #26 pass CI if it broke things? |
It passed CI, because we do not lint types in CI. If you check the logs, you can see that ember-cli-typescript does in fact complain about it, but does not fail the build: https://travis-ci.com/rwjblue/sparkles-component/jobs/167248765#L559-L572 However, |
Gotcha! We should add this to prevent exactly this kind of regression... |
Released in 1.3.0 |
Closes #16.
Supersedes #17.
Relates to #21.
This adds support for stage 2 decorators and the latest
@ember-decorators/babel-transforms
while changing as few things as possible. It also upgrades to the latestember-cli-typescript@beta
.In theory, this should be compatible with
ember-cli-typescript@1
, since this PR uses@ember-decorators/utils
, but I would like to add tests for that before merging./cc @rwjblue