ember-deep-tracked icon indicating copy to clipboard operation
ember-deep-tracked copied to clipboard

Error if object is undefined

Open optikalefx opened this issue 4 years ago • 1 comments

With native @tracked you can defined your tracked properties with no default values.

@tracked foo;
@tracked bar;

Even though as objects ember won't track these, the user is used to write it this way. When you start to use this addon, without adding = {} you get the following error

image

vendor.js:172922 Uncaught (in promise) TypeError: initializer is not a function

desc.get = function get() {
      if (!value) {
        value = deepTracked(initializer());
      }

is where the error is.

I think if you're using this addon, and you're trying to track the properties of an object, perhaps it could default to empty object? Or fail with a warning instead.

optikalefx avatar Aug 28 '21 17:08 optikalefx

I think defaulting to {} sounds good 🎉

I'd gladly accept a PR that adds that, too <3

NullVoxPopuli avatar Aug 28 '21 18:08 NullVoxPopuli