question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Better error message for undefined bound property

See original GitHub issue

Given the following:

<button :value.sync="missing">click</button>

results in the following error in the Chrome console:

Uncaught TypeError: Cannot read property 'length' of undefined

There is no mention:

  • that a bound property is missing
  • that its name is ‘missing’
  • that it’s on an element <button>
  • that it come from file foo.vue

An improvement would be to say:

Error: bound object 'missing' on element``<button>``can't be found in file foo.vue

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
matthiasgcommented, Dec 19, 2016

its also an issue when accessing sub properties of non-existing properties.

e.g. {{options.title}} where options is not yet defined. IMHO it would be better to follow the angular way and just resolve string interpolations with errors to empty string and only log this error in non-release mode

2reactions
davidmoshalcommented, Aug 1, 2016

Similarly, this error could be more useful if it showed which component was trying to reference this element.

vue.common.js?f9a0:1019[Vue warn]: Unknown custom element: <component-a> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

thanks for the awesome project!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Prevent the Error: Cannot Read Property '0' of Undefined
A guide on how to prevent the error "cannot Read Property '0' of Undefined", covering techniques such as try, catch, using const over...
Read more >
Uncaught TypeError: Cannot read property 'bind' of undefined ...
Uncaught TypeError: Cannot read property 'bind' of undefined, but I have bound the method and it is not undefined in the console.
Read more >
7 Tips to Handle undefined in JavaScript - Dmitri Pavlutin
A detailed article about 'undefined' keyword in JavaScript. 7 tips on how to handle correctly 'undefined' and increase code durability.
Read more >
How to Avoid Getting 'Cannot read property of undefined' in ...
Learn how you can avoid getting the famous 'Cannot read property of undefined' error in JavaScript with the logical OR operator.
Read more >
ERROR [app-router] TypeError: Cannot read property ... - GitHub
When I use @bindable to bind an array of strings in my custom ... TypeError: Cannot read property 'subscriberAdded' of undefined I've traced ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found