adopted-ember-addons / ember-moment

MIT License
400 stars 122 forks source link

Import `computed.bool` from the right package #340

Closed aoumiri closed 2 years ago

aoumiri commented 3 years ago

With the latest release of ember 3.27.0, it's no longer possible to use computed.bool like that:

import { computed } from '@ember/object';

// ...
  someAttribute: computed.bool('someTrackedProperty'),
// ...

But instead we should do:

import { bool } from '@ember/object/computed';

// ...
  someAttribute: bool('someTrackedProperty'),
// ...

Otherwise, this is the error we get: Uncaught TypeError: Ember.computed.bool is not a function.

schorke commented 3 years ago

@aoumiri I don't understand why this error exists (we encountered the same error) while Ember.computed.bool is only deprecated in Ember 3.27.0 and should stay deprecated until Ember 4.0.0 , so it should not cause an error...

Did I miss something or am I completely dumb ?

timmyomahony commented 2 years ago

I'm encountering this with ember-moment 8.0.1 on ember-source 3.28.0 running the following in a template:

{{moment-format (now) 'YYYY'}}

Throws the error:

Uncaught TypeError: Ember.computed.bool is not a function
    at Module.callback (-base.js:10)
    at Module.exports (loader.js:106)
    at Module._reify (loader.js:143)
    at Module.reify (loader.js:130)
    at Module.exports (loader.js:104)
    at Module._reify (loader.js:143)
    at Module.reify (loader.js:130)
    at Module.exports (loader.js:104)
    at requireModule (loader.js:27)
    at Class._extractDefaultExport (index.js:462)

Which seems to relate to here:

https://github.com/stefanpenner/ember-moment/blob/382ddd1238c7bcab2f66225830d18aca5364c2f6/addon/helpers/-base.js#L9

timmyomahony commented 2 years ago

Just to note, the PR from here fixes this for me:

https://github.com/stefanpenner/ember-moment/pull/351

You can get it with:

yarn add stefanpenner/ember-moment#351/head
aoumiri commented 2 years ago

@jasonmit @stefanpenner can anyone of you have a look at this PR? Or any maintainer 🙏

Thanks 😊

robclancy commented 2 years ago

Isn't this an ember bug? I am getting these same errors from app code when it was just meant to be a deprecation.

aoumiri commented 2 years ago

Ember bug or not, I think it's still worth fixing now if it will be deprecated. Rather than waiting for the next major. WDYT ?

esbanarango commented 2 years ago

https://github.com/adopted-ember-addons/ember-moment/pull/351#issuecomment-914650169

NullVoxPopuli commented 2 years ago

Fix released in 8.0.2