Cannot convert object to primitive value
See original GitHub issueThis is similar to https://github.com/emberjs/ember.js/issues/14187, but I have a reproduction in Ember 2.10 with no addons:
https://ember-twiddle.com/4df2d62bf5f1c05bd74086dc79326020?openFiles=components.my-component.js%2C
The critical ingredient seems to be that I am taking an object created by the hash
helper, putting it inside an Array
, and passing the array into another component. When such an array hits toString
it causes an exception.
(It’s hitting toString
in the first place to support an assertion.)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:10
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Cannot convert object to primitive value - Stack Overflow
most of the Javascript objects have toString() method inherited from Object.prototype . but some of them that have a null prototype , not...
Read more >Object to primitive conversion - The Modern JavaScript Tutorial
These methods must return a primitive value. If toString or valueOf returns an object, then it's ignored (same as if there were no...
Read more >Cannot convert object to primitive value · Issue #309 - GitHub
In almanac you have debug lines like this: (0, _debug2.default)('almanac::constructor initialized runtime fact:' + fact.id + ' with ' + fact.value + '<'...
Read more >typeerror: cannot convert object to primitive value - You.com
Cannot convert object to primitive value error in react application? ... It is a breaking change that affects many plugins. Temporarily reverting to...
Read more >Cannot convert object to primitive value | The Node.js Master ...
Your browser can't play this video. ... Bonus Lecture - TypeError: Cannot convert object to primitive value | The Node.js Master Class.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have a similar problem when passing a hash into the
array
helper from https://github.com/DockYard/ember-composable-helpers.Twiddle that reproduces the issue (note how myComponent.totalLength can’t be computed!): https://ember-twiddle.com/b886a7c23774720188df41e9967aa443?openFiles=templates.application.hbs%2C
“Fixed” by replacing the
hash
helper with a very simplemy-hash
helper that returns a full object instead of the EmptyObject that Ember itself uses: (note how now totalLength is shown): https://ember-twiddle.com/208688934ca9599e8607045d3e067fde?openFiles=templates.application.hbs%2CEdit: The problem occurs in 2.10.2 but also in 2.11 (which is not available in Twiddle)
@gabrielgrant / @caseklim - Good spot, I didn’t notice that both were describing the same issue. I’ll close #14922 for now and we can track the issue here.