ember-decorators / argument

Decorators for Component and Object arguments in Ember
MIT License
30 stars 18 forks source link

object.js:20 Uncaught TypeError: Cannot convert undefined or null to object at Function.getOwnPropertyDescriptor #98

Closed artemgurzhii closed 5 years ago

artemgurzhii commented 5 years ago

Versions:

Error Message:

Error being thrown from the addon/-private/utils/object.js#L9-L16 Here is an image

I'm having simple component with optional arguments

// component.hbs
<ComponentName />  {{!-- This throws error --}}

<ComponentName
  @someProp={{"some string"}}
/>  {{!-- This does not --}}
// component.js
import Component from '@ember/component';
import { argument } from '@ember-decorators/argument';
import { optional } from '@ember-decorators/argument/types';

export default class ComponentNameComponent extends Component {
  @argument(optional('string')) someProp;
}
willviles commented 5 years ago

I'm experiencing this too whilst trying to upgrade from 0.5.0.

alexlafroscia commented 5 years ago

Sorry to hear there's been some issues upgrading -- thanks for checking out the beta version!

I upgraded out app at work recently and haven't run into this issue yet... I'm really curious what's different here. I guess I need to check that target is neither undefined ornull, since we pretty explicitly ensure that target is not undefined before passing it to getOwnPropertyDescriptors

Is there any chance you can set your debugger in Chrome (or whatever) to pause on uncaught errors, trigger the problem, and check that target is in fact null when the exception is thrown? That would make me feel quite a bit more confident in adding that additional check as the solution.

artemgurzhii commented 5 years ago

@alexlafroscia target is not null or undefined at first run, but method getPropertyDescriptor calls itself recursively

alexlafroscia commented 5 years ago

Interesting... I'll try to reproduce in a new Ember app with the dependencies that you've mentioned.

If you have a reproduction you can point me to, that would really speed things along!